org.eclipse.lsp4j.InitializedParams Java Examples

The following examples show how to use org.eclipse.lsp4j.InitializedParams. 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: DefaultLanguageServerWrapper.java    From MSPaintIDE with MIT License 6 votes vote down vote up
@Override
public CompletableFuture<Void> start(File rootPath) {
    setStatus(STARTING);
    this.client = new LSPClient(this.startupLogic);

    this.rootPath = rootPath;

    try {
        var processedArgs = this.argumentPreprocessor.apply(this, new ArrayList<>(this.lspArgs));

        var streamConnectionProvider = new LSPProvider(
                () -> requestManager,
                processedArgs,
                serverPath.get());
        streamConnectionProvider.start();

        Launcher<LanguageServer> launcher =
                Launcher.createLauncher(client, LanguageServer.class, streamConnectionProvider.getInputStream(), streamConnectionProvider.getOutputStream());

        languageServer = launcher.getRemoteProxy();
        client.connect(languageServer);
        launcherFuture = launcher.startListening();

        return (startingFuture = languageServer.initialize(getInitParams()).thenApply(res -> {
            LOGGER.info("Started LSP");

            requestManager = new DefaultRequestManager(this, languageServer, client, res.getCapabilities());
            setStatus(STARTED);
            requestManager.initialized(new InitializedParams());
            setStatus(INITIALIZED);
            return res;
        }).thenRun(() -> LOGGER.info("Done starting LSP!")));

    } catch (Exception e) {
        LOGGER.error("Can't launch language server for project", e);
    }

    return CompletableFuture.runAsync(() -> {});
}
 
Example #2
Source File: InitHandlerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testRegisterDelayedCapability() throws Exception {
	ClientPreferences mockCapabilies = mock(ClientPreferences.class);
	when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
	when(mockCapabilies.isDocumentSymbolDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isWorkspaceSymbolDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isDocumentSymbolDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isCodeActionDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isDefinitionDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isHoverDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isReferencesDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isDocumentHighlightDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isFoldgingRangeDynamicRegistered()).thenReturn(Boolean.TRUE);
	when(mockCapabilies.isCompletionDynamicRegistered()).thenReturn(Boolean.TRUE);
	InitializeResult result = initialize(true);
	assertNull(result.getCapabilities().getDocumentSymbolProvider());
	server.initialized(new InitializedParams());
	verify(client, times(9)).registerCapability(any());
}
 
Example #3
Source File: N4jscCompiler.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void performCompile() {
	if (options.isClean()) {
		performClean();
		callback.resetCounters();
	}
	Stopwatch compilationTime = Stopwatch.createStarted();
	try (Measurement m = N4JSDataCollectors.dcBuild.getMeasurement()) {
		languageServer.initialized(new InitializedParams());
		languageServer.joinServerRequests();
	}
	printCompileResults(compilationTime.stop());
}
 
Example #4
Source File: ActionScriptLanguageServer.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
@Override
public void initialized(InitializedParams params)
{
    boolean canRegisterDidChangeWatchedFiles = false;
    try
    {
        canRegisterDidChangeWatchedFiles = actionScriptServices.getClientCapabilities().getWorkspace().getDidChangeWatchedFiles().getDynamicRegistration();
    }
    catch(NullPointerException e)
    {
        canRegisterDidChangeWatchedFiles = false;
    }
    if(canRegisterDidChangeWatchedFiles)
    {
        List<FileSystemWatcher> watchers = new ArrayList<>();
        //ideally, we'd only check .as, .mxml, asconfig.json, and directories
        //but there's no way to target directories without *
        watchers.add(new FileSystemWatcher("**/*"));

        String id = "as3mxml-language-server-" + Math.random();
        DidChangeWatchedFilesRegistrationOptions options = new DidChangeWatchedFilesRegistrationOptions(watchers);
        Registration registration = new Registration(id, "workspace/didChangeWatchedFiles", options);
        List<Registration> registrations = new ArrayList<>();
        registrations.add(registration);

        RegistrationParams registrationParams = new RegistrationParams(registrations);
        languageClient.registerCapability(registrationParams);
    }

    //we can't notify the client about problems until we receive this
    //initialized notification. this is the first time that we'll start
    //checking for errors.
    actionScriptServices.setInitialized();
}
 
Example #5
Source File: XMLLanguageServer.java    From lemminx with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialized(InitializedParams params) {
	capabilityManager.initializeCapabilities();
}
 
Example #6
Source File: XLanguageServerImpl.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void initialized(InitializedParams params) {
	lspBuilder.initialBuild();
	clientInitialized.complete(params);
}
 
Example #7
Source File: LanguageServerImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialized(InitializedParams params) {
	initialized.complete(params);
}
 
Example #8
Source File: LanguageServer.java    From lsp4j with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * The initialized notification is sent from the client to the server after
 * the client received the result of the initialize request but before the
 * client is sending any other request or notification to the server. The
 * server can use the initialized notification for example to dynamically
 * register capabilities.
 */
@JsonNotification
default void initialized(InitializedParams params) {
	initialized();
}