Search in sources :

Example 1 with DidChangeWorkspaceFoldersParams

use of org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams in project xtext-core by eclipse.

the class WorkspaceFoldersTest method testInitialize.

@Test
public void testInitialize() throws Exception {
    File rootFolder1 = temporaryFolder.newFolder("root1");
    File rootFolder2 = temporaryFolder.newFolder("root2");
    writeFile(rootFolder1, "one.testlang", "type Foo { Bar bar }");
    String twoUri = writeFile(rootFolder2, "two.testlang", "type Bar { Foo foo }");
    initialize((InitializeParams it) -> {
        it.setWorkspaceFolders(Lists.newArrayList(new WorkspaceFolder(uriExtensions.toUriString(rootFolder1.toURI()), "root1"), new WorkspaceFolder(uriExtensions.toUriString(rootFolder2.toURI()), "root2")));
    });
    Assert.assertEquals(2, getDiagnostics().size());
    Assert.assertEquals(1, getDiagnostics().get(twoUri).size());
    withBuild(() -> {
        DidChangeWorkspaceFoldersParams didChangeWorkspaceFoldersParams = new DidChangeWorkspaceFoldersParams();
        WorkspaceFoldersChangeEvent workspaceFoldersChangeEvent = new WorkspaceFoldersChangeEvent();
        workspaceFoldersChangeEvent.setRemoved(Lists.newArrayList(new WorkspaceFolder(uriExtensions.toUriString(rootFolder2.toURI()), "root2")));
        didChangeWorkspaceFoldersParams.setEvent(workspaceFoldersChangeEvent);
        languageServer.didChangeWorkspaceFolders(didChangeWorkspaceFoldersParams);
    });
    Assert.assertEquals(0, getDiagnostics().get(twoUri).size());
    withBuild(() -> {
        DidChangeWorkspaceFoldersParams didChangeWorkspaceFoldersParams = new DidChangeWorkspaceFoldersParams();
        WorkspaceFoldersChangeEvent workspaceFoldersChangeEvent = new WorkspaceFoldersChangeEvent();
        workspaceFoldersChangeEvent.setAdded(Lists.newArrayList(new WorkspaceFolder(uriExtensions.toUriString(rootFolder2.toURI()), "root2")));
        didChangeWorkspaceFoldersParams.setEvent(workspaceFoldersChangeEvent);
        languageServer.didChangeWorkspaceFolders(didChangeWorkspaceFoldersParams);
    });
    Assert.assertEquals(1, getDiagnostics().get(twoUri).size());
}
Also used : WorkspaceFoldersChangeEvent(org.eclipse.lsp4j.WorkspaceFoldersChangeEvent) InitializeParams(org.eclipse.lsp4j.InitializeParams) File(java.io.File) DidChangeWorkspaceFoldersParams(org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder) Test(org.junit.Test)

Aggregations

File (java.io.File)1 DidChangeWorkspaceFoldersParams (org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams)1 InitializeParams (org.eclipse.lsp4j.InitializeParams)1 WorkspaceFolder (org.eclipse.lsp4j.WorkspaceFolder)1 WorkspaceFoldersChangeEvent (org.eclipse.lsp4j.WorkspaceFoldersChangeEvent)1 Test (org.junit.Test)1