summaryrefslogtreecommitdiff
path: root/src/test/java/org/javacs/Fixtures.java
blob: f3c6db6b0c76eca4ba8a2fe98514120d2f1e33fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package org.javacs;

import org.eclipse.lsp4j.InitializeParams;
import org.junit.BeforeClass;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Set;

public class Fixtures {

    public static void init() { }

    static JavaLanguageServer getJavaLanguageServer() {
        Set<Path> classPath = Collections.emptySet();
        Set<Path> sourcePath = Collections.singleton(Paths.get("src/test/resources").toAbsolutePath());
        Path outputDirectory = Paths.get("out").toAbsolutePath();
        JavacHolder javac = new JavacHolder(classPath, sourcePath, outputDirectory);
        JavaLanguageServer server = new JavaLanguageServer(javac);

        InitializeParams init = new InitializeParams();
        String workspaceRoot = Paths.get(".").toAbsolutePath().toString();

        init.setRootPath(workspaceRoot);

        server.initialize(init);
        return server;
    }
}