org.eclipse.lsp4j.InitializeParams Java Examples
The following examples show how to use
org.eclipse.lsp4j.InitializeParams.
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: ProjectsManagerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testCancelInitJob() throws Exception { File workspaceDir = copyFiles("maven/salut", true); String rootPathURI = workspaceDir.toURI().toString(); Collection<IPath> rootPaths = Collections.singleton(ResourceUtils.canonicalFilePathFromURI(rootPathURI)); InitializeParams params = new InitializeParams(); params.setRootUri(rootPathURI); server.initialize(params); Job[] initWorkspaceJobs = Job.getJobManager().find(rootPaths); assertEquals(1, initWorkspaceJobs.length); Job initWorkspaceJob = initWorkspaceJobs[0]; assertNotNull(initWorkspaceJob); projectsManager.updateWorkspaceFolders(Collections.emptySet(), rootPaths); waitForBackgroundJobs(); assertTrue("the init job hasn't been cancelled, status is: " + initWorkspaceJob.getResult().getSeverity(), initWorkspaceJob.getResult().matches(IStatus.CANCEL)); }
Example #2
Source File: AbstractIdeTest.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** 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 #3
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 6 votes |
@Test public void diagnosticsClose() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); DidCloseTextDocumentParams closeParams = new DidCloseTextDocumentParams(); closeParams.setTextDocument(new TextDocumentIdentifier()); closeParams.getTextDocument() .setUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath + "/needtrim.rdf")); lsp.didClose(closeParams); verify(client, times(2)).publishDiagnostics(any()); }
Example #4
Source File: XLanguageServerImpl.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public CompletableFuture<InitializeResult> initialize(InitializeParams params) { if (initializeParams != null) { throw new IllegalStateException("This language server has already been initialized."); } URI baseDir = getBaseDir(params); if (languagesRegistry.getExtensionToFactoryMap().isEmpty()) { throw new IllegalStateException( "No Xtext languages have been registered. Please make sure you have added the languages\'s setup class in \'/META-INF/services/org.eclipse.xtext.ISetup\'"); } this.initializeParams = params; openFilesManager.setIssueRegistry(issueRegistry); openFilesManager.addListener(this); lspBuilder.getIndexRaw().addListener(this); Stopwatch sw = Stopwatch.createStarted(); LOG.info("Start server initialization in workspace directory " + baseDir); lspBuilder.initialize(baseDir, issueRegistry); LOG.info("Server initialization done after " + sw); initializeResult = new InitializeResult(); initializeResult.setCapabilities(createServerCapabilities(params)); return CompletableFuture.completedFuture(initializeResult); }
Example #5
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 6 votes |
@Test public void diagnosticsNoTarget() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); lsp.refreshFileTripleSet(); verify(client, never()).publishDiagnostics(any()); }
Example #6
Source File: XSDPlugin.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Override public void start(InitializeParams params, XMLExtensionsRegistry registry) { // Register resolver uiResolver = new XSDURIResolverExtension(registry.getDocumentProvider()); registry.getResolverExtensionManager().registerResolver(uiResolver); // register XSD content model provider ContentModelProvider modelProvider = new CMXSDContentModelProvider(registry.getResolverExtensionManager()); modelManager = registry.getComponent(ContentModelManager.class); modelManager.registerModelProvider(modelProvider); // register completion, diagnostic participant registry.registerCompletionParticipant(completionParticipant); registry.registerDefinitionParticipant(definitionParticipant); registry.registerDiagnosticsParticipant(diagnosticsParticipant); registry.registerReferenceParticipant(referenceParticipant); registry.registerCodeLensParticipant(codeLensParticipant); registry.registerHighlightingParticipant(highlightingParticipant); registry.registerRenameParticipant(renameParticipant); registry.registerDocumentLinkParticipant(documentLinkParticipant); }
Example #7
Source File: DTDPlugin.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Override public void start(InitializeParams params, XMLExtensionsRegistry registry) { // register DTD content model provider ContentModelProvider modelProvider = new CMDTDContentModelProvider(registry.getResolverExtensionManager()); ContentModelManager modelManager = registry.getComponent(ContentModelManager.class); modelManager.registerModelProvider(modelProvider); // register diagnostic participant registry.registerDiagnosticsParticipant(diagnosticsParticipant); // register definition participant registry.registerDefinitionParticipant(definitionParticipant); // register highlighting participant registry.registerHighlightingParticipant(highlightingParticipant); // register reference participant registry.registerReferenceParticipant(referenceParticipant); // register codelens participant registry.registerCodeLensParticipant(codeLensParticipant); }
Example #8
Source File: InitHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
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 #9
Source File: SettingsTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Test public void symbolSettingsTest() { //Tests that when the settings are updated the shared settings are also updated correctly InitializeParams params = createInitializeParams(json); Object initializationOptionsSettings = InitializationOptionsSettings.getSettings(params); XMLLanguageServer languageServer = new XMLLanguageServer(); languageServer.updateSettings(initializationOptionsSettings); // This should set/update the sharedSettings XMLExcludedSymbolFile xsdFile = new XMLExcludedSymbolFile("**\\*.xsd"); XMLExcludedSymbolFile xmlFile = new XMLExcludedSymbolFile("**\\*.xml"); XMLExcludedSymbolFile[] expectedExcludedFiles = new XMLExcludedSymbolFile[] {xsdFile, xmlFile}; XMLExcludedSymbolFile[] actualExpectedFiles = languageServer.getSettings().getSymbolSettings().getExcludedFiles(); assertArrayEquals(expectedExcludedFiles, actualExpectedFiles); }
Example #10
Source File: CamelLanguageServer.java From camel-language-server with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<InitializeResult> initialize(InitializeParams params) { Integer processId = params.getProcessId(); if(processId != null) { setParentProcessId(processId.longValue()); } else { LOGGER.info("Missing Parent process ID!!"); setParentProcessId(0); } new SettingsManager(getTextDocumentService()).apply(params); ServerCapabilities capabilities = createServerCapabilities(); InitializeResult result = new InitializeResult(capabilities); return CompletableFuture.completedFuture(result); }
Example #11
Source File: XMLLanguageServer.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Override public CompletableFuture<InitializeResult> initialize(InitializeParams params) { LOGGER.info("Initializing XML Language server" + System.lineSeparator() + new ServerInfo().details()); this.parentProcessId = params.getProcessId(); // Update XML language service extensions with InitializeParams xmlLanguageService.initializeParams(params); ExtendedClientCapabilities extendedClientCapabilities = InitializationOptionsExtendedClientCapabilities .getExtendedClientCapabilities(params); capabilityManager.setClientCapabilities(params.getCapabilities(), extendedClientCapabilities); xmlTextDocumentService.updateClientCapabilities(capabilityManager.getClientCapabilities().capabilities, capabilityManager.getClientCapabilities().getExtendedCapabilities()); updateSettings(InitializationOptionsSettings.getSettings(params)); ServerCapabilities nonDynamicServerCapabilities = ServerCapabilitiesInitializer.getNonDynamicServerCapabilities( capabilityManager.getClientCapabilities(), xmlTextDocumentService.isIncrementalSupport()); return CompletableFuture.completedFuture(new InitializeResult(nonDynamicServerCapabilities)); }
Example #12
Source File: XLanguageServerImpl.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Deprecated private URI deprecatedToBaseDir(InitializeParams params) { String rootPath = params.getRootPath(); if (rootPath != null) { return uriExtensions.toUri(uriExtensions.toUriString(URI.createFileURI(rootPath))); } return null; }
Example #13
Source File: RdfLintLanguageServer.java From rdflint with MIT License | 5 votes |
@Override public CompletableFuture<InitializeResult> initialize(InitializeParams params) { // initialize rdflint String rootPath = convertUri2FilePath(params.getRootUri()); String configPath = ConfigurationLoader.searchConfigPath(rootPath); try { rdflintParams = ConfigurationLoader.loadConfig(configPath); rdflintParams.setTargetDir(rootPath); rdflintParams.setOutputDir(rootPath); if (rdflintParams.getSuppressPath() == null) { rdflintParams.setSuppressPath(ConfigurationLoader.searchSuppressPath(rootPath)); } } catch (IOException ex) { showException("Error cannot initialize rdflint", ex); } validators = new LinkedList<>(); validators.add(new TrimValidator()); validators.add(new UndefinedSubjectValidator()); validators.add(new ShaclValidator()); validators.forEach(v -> v.setParameters(rdflintParams) ); refreshFileTripleSet(); ServerCapabilities capabilities = new ServerCapabilities(); capabilities.setTextDocumentSync(TextDocumentSyncKind.Full); InitializeResult result = new InitializeResult(capabilities); return CompletableFuture.completedFuture(result); }
Example #14
Source File: AbstractCamelLanguageServerTest.java From camel-language-server with Apache License 2.0 | 5 votes |
private InitializeParams getInitParams() throws URISyntaxException { InitializeParams params = new InitializeParams(); params.setProcessId(new Random().nextInt()); params.setRootUri(getTestResource("/workspace/").toURI().toString()); params.setInitializationOptions(getInitializationOptions()); return params; }
Example #15
Source File: AbstractCamelLanguageServerTest.java From camel-language-server with Apache License 2.0 | 5 votes |
private void initializeLanguageServer(InitializeParams params) throws ExecutionException, InterruptedException { camelLanguageServer = new CamelLanguageServer(); camelLanguageServer.connect(new DummyLanguageClient()); camelLanguageServer.startServer(); CompletableFuture<InitializeResult> initialize = camelLanguageServer.initialize(params); assertThat(initialize).isCompleted(); assertThat(initialize.get().getCapabilities().getCompletionProvider().getResolveProvider()).isTrue(); }
Example #16
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 5 votes |
@Test public void diagnosticsOpen() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); DidOpenTextDocumentParams openParams = new DidOpenTextDocumentParams(); openParams.setTextDocument(new TextDocumentItem()); openParams.getTextDocument() .setUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath + "/needtrim.rdf")); openParams.getTextDocument().setText("<rdf:RDF\n" + " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + " xmlns:schema=\"http://schema.org/\"\n" + " >\n" + "\n" + " <rdf:Description rdf:about=\"something\">\n" + " <schema:familyName xml:lang=\"ja\">familyName </schema:familyName>\n" + " </rdf:Description>\n" + "\n" + "</rdf:RDF>"); lsp.didOpen(openParams); verify(client, times(1)).publishDiagnostics(any()); }
Example #17
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 5 votes |
@Test public void diagnosticsChange() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams(); changeParams.setTextDocument(new VersionedTextDocumentIdentifier()); changeParams.getTextDocument() .setUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath + "/needtrim.rdf")); List<TextDocumentContentChangeEvent> changeEvents = new LinkedList<>(); changeParams.setContentChanges(changeEvents); changeEvents.add(new TextDocumentContentChangeEvent()); changeEvents.get(0).setText("<rdf:RDF\n" + " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + " xmlns:schema=\"http://schema.org/\"\n" + " >\n" + "\n" + " <rdf:Description rdf:about=\"something\">\n" + " <schema:familyName xml:lang=\"ja\">familyName </schema:familyName>\n" + " </rdf:Description>\n" + "\n" + "</rdf:RDF>"); lsp.didChange(changeParams); verify(client, times(1)).publishDiagnostics(any()); }
Example #18
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 5 votes |
@Test public void diagnosticsChangeParseError() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams(); changeParams.setTextDocument(new VersionedTextDocumentIdentifier()); changeParams.getTextDocument() .setUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath + "/needtrim.rdf")); List<TextDocumentContentChangeEvent> changeEvents = new LinkedList<>(); changeParams.setContentChanges(changeEvents); changeEvents.add(new TextDocumentContentChangeEvent()); changeEvents.get(0).setText("<rdf:RDF\n" + " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + " xmlns:schema=\"http://schema.org/\"\n" + " >\n" + "\n" + " <rdf:Description rdf:about=\"something\">\n" + " <schema:familyName xml:lang=\"ja\">familyName</schema:familyN>\n" + " </rdf:Description>\n" + "\n" + "</rdf:RDF>"); lsp.didChange(changeParams); verify(client, times(1)).publishDiagnostics(any()); }
Example #19
Source File: XMLModelPlugin.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public void start(InitializeParams params, XMLExtensionsRegistry registry) { // register xml-model content model provider ContentModelManager modelManager = registry.getComponent(ContentModelManager.class); ContentModelProvider modelProvider = new CMXMLModelContentModelProvider(modelManager); modelManager.registerModelProvider(modelProvider); }
Example #20
Source File: N4jscCompiler.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Starts the compiler in a blocking fashion */ public N4jscExitState start() throws Exception { InitializeParams params = new InitializeParams(); File baseDir = options.getDir(); if (baseDir == null) { throw new N4jscException(N4jscExitCode.ARGUMENT_DIRS_INVALID, "No base directory"); } params.setRootUri(baseDir.toURI().toString()); languageServer.initialize(params).get(); warnIfNoProjectsFound(); verbosePrintAllProjects(); switch (options.getGoal()) { case clean: performClean(); break; case compile: performCompile(); break; default: break; } languageServer.shutdown(); languageServer.exit(); writeTestCatalog(); return determineExitState(); }
Example #21
Source File: GroovyLanguageServer.java From groovy-language-server with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<InitializeResult> initialize(InitializeParams params) { String rootUriString = params.getRootUri(); if (rootUriString != null) { URI uri = URI.create(params.getRootUri()); Path workspaceRoot = Paths.get(uri); groovyServices.setWorkspaceRoot(workspaceRoot); } CompletionOptions completionOptions = new CompletionOptions(false, Arrays.asList(".")); ServerCapabilities serverCapabilities = new ServerCapabilities(); serverCapabilities.setCompletionProvider(completionOptions); serverCapabilities.setTextDocumentSync(TextDocumentSyncKind.Full); serverCapabilities.setDocumentSymbolProvider(true); serverCapabilities.setWorkspaceSymbolProvider(true); serverCapabilities.setDocumentSymbolProvider(true); serverCapabilities.setReferencesProvider(true); serverCapabilities.setDefinitionProvider(true); serverCapabilities.setTypeDefinitionProvider(true); serverCapabilities.setHoverProvider(true); serverCapabilities.setRenameProvider(true); SignatureHelpOptions signatureHelpOptions = new SignatureHelpOptions(); signatureHelpOptions.setTriggerCharacters(Arrays.asList("(", ",")); serverCapabilities.setSignatureHelpProvider(signatureHelpOptions); InitializeResult initializeResult = new InitializeResult(serverCapabilities); return CompletableFuture.completedFuture(initializeResult); }
Example #22
Source File: XLanguageServerImpl.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Compute the base dir. */ protected URI getBaseDir(InitializeParams params) { String rootUri = params.getRootUri(); if (rootUri != null) { return uriExtensions.toUri(rootUri); } return deprecatedToBaseDir(params); }
Example #23
Source File: LSPBindings.java From netbeans with Apache License 2.0 | 5 votes |
private static InitializeResult initServer(Process p, LanguageServer server, FileObject root) throws InterruptedException, ExecutionException { InitializeParams initParams = new InitializeParams(); initParams.setRootUri(Utils.toURI(root)); initParams.setRootPath(FileUtil.toFile(root).getAbsolutePath()); //some servers still expect root path initParams.setProcessId(0); TextDocumentClientCapabilities tdcc = new TextDocumentClientCapabilities(); DocumentSymbolCapabilities dsc = new DocumentSymbolCapabilities(); dsc.setHierarchicalDocumentSymbolSupport(true); dsc.setSymbolKind(new SymbolKindCapabilities(Arrays.asList(SymbolKind.values()))); tdcc.setDocumentSymbol(dsc); WorkspaceClientCapabilities wcc = new WorkspaceClientCapabilities(); wcc.setWorkspaceEdit(new WorkspaceEditCapabilities()); wcc.getWorkspaceEdit().setDocumentChanges(true); wcc.getWorkspaceEdit().setResourceOperations(Arrays.asList(ResourceOperationKind.Create, ResourceOperationKind.Delete, ResourceOperationKind.Rename)); initParams.setCapabilities(new ClientCapabilities(wcc, tdcc, null)); CompletableFuture<InitializeResult> initResult = server.initialize(initParams); while (true) { try { return initResult.get(100, TimeUnit.MILLISECONDS); } catch (TimeoutException ex) { if (p != null && !p.isAlive()) { InitializeResult emptyResult = new InitializeResult(); emptyResult.setCapabilities(new ServerCapabilities()); return emptyResult; } } } }
Example #24
Source File: BaseInitHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public InitializeResult initialize(InitializeParams param) { logInfo("Initializing Java Language Server " + JavaLanguageServerPlugin.getVersion()); InitializeResult result = new InitializeResult(); handleInitializationOptions(param); registerCapabilities(result); // At the end of the InitHandler, trigger a job to import the workspace. This is used to ensure ServiceStatus notification // is not sent before the initialize response. See the bug https://github.com/redhat-developer/vscode-java/issues/1056 triggerInitialization(preferenceManager.getPreferences().getRootPaths()); return result; }
Example #25
Source File: InitHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public Map<?, ?> handleInitializationOptions(InitializeParams param) { Map<?, ?> initializationOptions = super.handleInitializationOptions(param); try { Collection<String> bundleList = getInitializationOption(initializationOptions, BUNDLES_KEY, Collection.class); BundleUtils.loadBundles(bundleList); } catch (CoreException e) { // The additional plug-ins should not affect the main language server loading. JavaLanguageServerPlugin.logException("Failed to load extension bundles ", e); } return initializationOptions; }
Example #26
Source File: ChangeConverter2.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected ChangeConverter2(IResourceServiceProvider.Registry registry, WorkspaceEdit edit, ILanguageServerAccess access, UriExtensions uriExtensions) { this.registry = registry; this.uriExtensions = uriExtensions; this.edit = edit; this.access = access; Boolean documentChanges = null; if (access != null) { InitializeParams initializeParams = access.getInitializeParams(); if (initializeParams != null) { ClientCapabilities clientCapabilities = initializeParams.getCapabilities(); if (clientCapabilities != null) { WorkspaceClientCapabilities workspaceClientCapabilities = clientCapabilities.getWorkspace(); if (workspaceClientCapabilities != null) { WorkspaceEditCapabilities workspaceEditCapabilities = workspaceClientCapabilities .getWorkspaceEdit(); if (workspaceEditCapabilities != null) { documentChanges = workspaceEditCapabilities.getDocumentChanges(); } } } } } this.useDocumentChanges = documentChanges == Boolean.TRUE; if (this.useDocumentChanges) { this.edit.setDocumentChanges(new ArrayList<>()); } else { this.edit.setChanges(new LinkedHashMap<>()); } }
Example #27
Source File: LanguageServerImpl.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public CompletableFuture<InitializeResult> initialize(InitializeParams params) { if (initializeParams != null) { throw new IllegalStateException("This language server has already been initialized."); } URI baseDir = getBaseDir(params); if (languagesRegistry.getExtensionToFactoryMap().isEmpty()) { throw new IllegalStateException( "No Xtext languages have been registered. Please make sure you have added the languages\'s setup class in \'/META-INF/services/org.eclipse.xtext.ISetup\'"); } initializeParams = params; InitializeResult result = new InitializeResult(); result.setCapabilities(createServerCapabilities(params)); access.addBuildListener(this); return requestManager.runWrite(() -> { if (workspaceManager.isSupportsWorkspaceFolders()) { List<WorkspaceFolder> workspaceFolders = params.getWorkspaceFolders(); if (workspaceFolders == null) workspaceFolders = Collections.emptyList(); workspaceManager.initialize(workspaceFolders, this::publishDiagnostics, CancelIndicator.NullImpl); } else { workspaceManager.initialize(baseDir, this::publishDiagnostics, CancelIndicator.NullImpl); } return result; }, (cancelIndicator, it) -> it).thenApply(it -> initializeResult = it); }
Example #28
Source File: LanguageServerImpl.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Deprecated private URI deprecatedToBaseDir(InitializeParams params) { String rootPath = params.getRootPath(); if (rootPath != null) { return uriExtensions.toUri(uriExtensions.toUriString(URI.createFileURI(rootPath))); } return null; }
Example #29
Source File: LanguageServerImpl.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * Compute the base dir. */ protected URI getBaseDir(InitializeParams params) { String rootUri = params.getRootUri(); if (rootUri != null) { return uriExtensions.toUri(rootUri); } return deprecatedToBaseDir(params); }
Example #30
Source File: InitializeParamsTypeAdapter.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
public void write(final JsonWriter out, final InitializeParams value) throws IOException { if (value == null) { out.nullValue(); return; } out.beginObject(); out.name("processId"); writeProcessId(out, value.getProcessId()); out.name("rootPath"); writeRootPath(out, value.getRootPath()); out.name("rootUri"); writeRootUri(out, value.getRootUri()); out.name("initializationOptions"); writeInitializationOptions(out, value.getInitializationOptions()); out.name("capabilities"); writeCapabilities(out, value.getCapabilities()); out.name("clientName"); writeClientName(out, value.getClientName()); out.name("clientInfo"); writeClientInfo(out, value.getClientInfo()); out.name("trace"); writeTrace(out, value.getTrace()); out.name("workspaceFolders"); writeWorkspaceFolders(out, value.getWorkspaceFolders()); out.endObject(); }