Search in sources :

Example 1 with Builder

use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration.Builder in project sonarlint-core by SonarSource.

the class StandaloneSonarLintImpl method start.

private void start() {
    Builder builder = StandaloneGlobalConfiguration.builder();
    for (URL pluginPath : analyzers) {
        builder.addPlugin(pluginPath);
    }
    builder.setLogOutput(logOutput);
    builder.setSonarLintUserHome(Utils.getStandaloneHome());
    engine = new StandaloneSonarLintEngineImpl(builder.build());
}
Also used : Builder(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration.Builder) URL(java.net.URL) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl)

Example 2 with Builder

use of org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration.Builder in project sonarlint-core by SonarSource.

the class SonarLintLanguageServer method initialize.

@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
    String rootUri = params.getRootUri();
    // rootURI is null when no folder is open (like opening a single file in VSCode)
    if (rootUri != null) {
        try {
            workspaceRoot = new URI(rootUri);
        } catch (URISyntaxException e) {
            throw new IllegalStateException(e);
        }
    }
    Map<String, Object> options = (Map<String, Object>) params.getInitializationOptions();
    userSettings = new UserSettings(options);
    String productKey = (String) options.get("productKey");
    // deprecated, will be ignored when productKey present
    String telemetryStorage = (String) options.get("telemetryStorage");
    String productName = (String) options.get("productName");
    String productVersion = (String) options.get("productVersion");
    telemetry.init(getStoragePath(productKey, telemetryStorage), productName, productVersion);
    telemetry.optOut(userSettings.disableTelemetry);
    info("Starting SonarLint engine...");
    info("Using " + analyzers.size() + " analyzers");
    try {
        Map<String, String> extraProperties = new HashMap<>();
        extraProperties.put("sonar.typescript.internal.typescriptLocation", (String) options.get(TYPESCRIPT_LOCATION));
        Builder builder = StandaloneGlobalConfiguration.builder().setLogOutput(logOutput).setExtraProperties(extraProperties).addPlugins(analyzers.toArray(new URL[0]));
        this.engine = new StandaloneSonarLintEngineImpl(builder.build());
    } catch (Exception e) {
        error("Error starting SonarLint engine", e);
        throw new IllegalStateException(e);
    }
    info("SonarLint engine started");
    InitializeResult result = new InitializeResult();
    ServerCapabilities c = new ServerCapabilities();
    TextDocumentSyncOptions textDocumentSyncOptions = new TextDocumentSyncOptions();
    textDocumentSyncOptions.setOpenClose(true);
    textDocumentSyncOptions.setChange(TextDocumentSyncKind.Full);
    textDocumentSyncOptions.setSave(new SaveOptions(true));
    c.setTextDocumentSync(textDocumentSyncOptions);
    c.setCodeActionProvider(true);
    c.setExecuteCommandProvider(new ExecuteCommandOptions(asList(SONARLINT_OPEN_RULE_DESCRIPTION_COMMAND)));
    result.setCapabilities(c);
    return CompletableFuture.completedFuture(result);
}
Also used : TextDocumentSyncOptions(org.eclipse.lsp4j.TextDocumentSyncOptions) HashMap(java.util.HashMap) Builder(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration.Builder) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl) InitializeResult(org.eclipse.lsp4j.InitializeResult) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) SaveOptions(org.eclipse.lsp4j.SaveOptions) ExecuteCommandOptions(org.eclipse.lsp4j.ExecuteCommandOptions) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

URL (java.net.URL)2 StandaloneSonarLintEngineImpl (org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl)2 Builder (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration.Builder)2 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ExecuteCommandOptions (org.eclipse.lsp4j.ExecuteCommandOptions)1 InitializeResult (org.eclipse.lsp4j.InitializeResult)1 SaveOptions (org.eclipse.lsp4j.SaveOptions)1 ServerCapabilities (org.eclipse.lsp4j.ServerCapabilities)1 TextDocumentSyncOptions (org.eclipse.lsp4j.TextDocumentSyncOptions)1