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());
}
Aggregations