Search in sources :

Example 6 with StandaloneGlobalConfiguration

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

the class SonarLintEngineFactory method createEngine.

StandaloneSonarLintEngine createEngine() {
    /*
     * Some components in the container use the context classloader to find resources. For example, the ServiceLoader uses it by default
     * to find services declared by some libs.
     */
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    try {
        URL[] plugins = loadPlugins();
        StandaloneGlobalConfiguration globalConfiguration = StandaloneGlobalConfiguration.builder().setLogOutput(globalLogOutput).setSonarLintUserHome(getSonarLintHome()).setWorkDir(getWorkDir()).addPlugins(plugins).build();
        return new StandaloneSonarLintEngineImpl(globalConfiguration);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}
Also used : StandaloneGlobalConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) StandaloneSonarLintEngineImpl(org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl)

Aggregations

StandaloneSonarLintEngineImpl (org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl)6 StandaloneGlobalConfiguration (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration)6 Path (java.nio.file.Path)5 BeforeClass (org.junit.BeforeClass)5 File (java.io.File)4 IOException (java.io.IOException)4 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)4 StandardCharsets (java.nio.charset.StandardCharsets)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Assertions.tuple (org.assertj.core.api.Assertions.tuple)3 ClassRule (org.junit.ClassRule)3 Test (org.junit.Test)3 TemporaryFolder (org.junit.rules.TemporaryFolder)3 Issue (org.sonarsource.sonarlint.core.client.api.common.analysis.Issue)3 StandaloneAnalysisConfiguration (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration)3 StandaloneSonarLintEngine (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneSonarLintEngine)3