Java Code Examples for org.eclipse.lsp4j.ClientCapabilities#setWorkspace()

The following examples show how to use org.eclipse.lsp4j.ClientCapabilities#setWorkspace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractIdeTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/** Connects, initializes and waits for the initial build of the test project. */
protected void startLspServer(File root) {
	ClientCapabilities capabilities = new ClientCapabilities();
	WorkspaceClientCapabilities wcc = new WorkspaceClientCapabilities();
	wcc.setExecuteCommand(new ExecuteCommandCapabilities());
	capabilities.setWorkspace(wcc);
	InitializeParams initParams = new InitializeParams();
	initParams.setCapabilities(capabilities);
	initParams.setRootUri(new FileURI(root).toString());

	languageClient.addListener(this);

	languageServer.connect(languageClient);
	languageServer.initialize(initParams);
	languageServer.initialized(null);
	joinServerRequests();
}
 
Example 2
Source File: InitHandlerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private InitializeResult initialize(boolean dynamicRegistration) throws InterruptedException, ExecutionException {
	InitializeParams params = new InitializeParams();
	ClientCapabilities capabilities = new ClientCapabilities();
	WorkspaceClientCapabilities workspaceCapabilities = new WorkspaceClientCapabilities();
	workspaceCapabilities.setDidChangeConfiguration(new DidChangeConfigurationCapabilities(dynamicRegistration));
	ExecuteCommandCapabilities executeCommand = new ExecuteCommandCapabilities(dynamicRegistration);
	workspaceCapabilities.setExecuteCommand(executeCommand);
	capabilities.setWorkspace(workspaceCapabilities);
	TextDocumentClientCapabilities textDocument = new TextDocumentClientCapabilities();
	SynchronizationCapabilities synchronizationCapabilities = new SynchronizationCapabilities();
	synchronizationCapabilities.setWillSave(Boolean.TRUE);
	synchronizationCapabilities.setWillSaveWaitUntil(Boolean.TRUE);
	capabilities.setTextDocument(textDocument);
	params.setCapabilities(capabilities);
	CompletableFuture<InitializeResult> result = server.initialize(params);
	return result.get();
}
 
Example 3
Source File: InitHandlerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testMissingResourceOperations() throws Exception {
	ClientCapabilities capabilities = new ClientCapabilities();
	WorkspaceClientCapabilities worspaceCapabilities = new WorkspaceClientCapabilities();
	worspaceCapabilities.setWorkspaceEdit(new WorkspaceEditCapabilities());
	capabilities.setWorkspace(worspaceCapabilities);
	ClientPreferences preferences = new ClientPreferences(capabilities);
	assertFalse(preferences.isResourceOperationSupported());
}
 
Example 4
Source File: CommandRegistryTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testRegistration() {
	ExecutableCommandRegistry reg = new ExecutableCommandRegistry();
	ClientCapabilities cap = new ClientCapabilities();
	WorkspaceClientCapabilities workspaceClientCapabilities = new WorkspaceClientCapabilities();
	ExecuteCommandCapabilities executeCommandCapabilities = new ExecuteCommandCapabilities();
	executeCommandCapabilities.setDynamicRegistration(true);
	workspaceClientCapabilities.setExecuteCommand(executeCommandCapabilities);
	cap.setWorkspace(workspaceClientCapabilities);

	reg.initialize(Collections.unmodifiableList(Lists.newArrayList(this)), cap, this);
	Assert.assertEquals("static-command", Iterables.getFirst(reg.getCommands(), null));
	ExecuteCommandParams staticCommandParams = new ExecuteCommandParams();
	staticCommandParams.setCommand("static-command");
	reg.executeCommand(staticCommandParams, null, null);

	ExecuteCommandParams dynamicCommandParams = new ExecuteCommandParams();
	dynamicCommandParams.setCommand("dynamic-command");
	reg.executeCommand(dynamicCommandParams, null, null);
	Assert.assertEquals(Collections.unmodifiableSet(Sets.newHashSet("static-command")), commandsExecuted);
	commandsExecuted.clear();
	IDisposable disposable = register.apply("dynamic-command");

	ExecuteCommandParams dynamicCommandParams2 = new ExecuteCommandParams();
	dynamicCommandParams2.setCommand("dynamic-command");
	reg.executeCommand(dynamicCommandParams2, null, null);
	Assert.assertEquals(Collections.unmodifiableSet(Sets.newHashSet("dynamic-command")), commandsExecuted);
	commandsExecuted.clear();
	disposable.dispose();
	
	ExecuteCommandParams dynamicCommandParams3 = new ExecuteCommandParams();
	dynamicCommandParams3.setCommand("dynamic-command");
	reg.executeCommand(dynamicCommandParams3, null, null);
	Assert.assertEquals(Collections.unmodifiableSet(new HashSet<>()), commandsExecuted);
}