Search in sources :

Example 11 with StandaloneSonarLintEngineImpl

use of org.sonarsource.sonarlint.core.StandaloneSonarLintEngineImpl 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)11 StandaloneGlobalConfiguration (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneGlobalConfiguration)8 IOException (java.io.IOException)6 Path (java.nio.file.Path)6 File (java.io.File)5 BeforeClass (org.junit.BeforeClass)5 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)5 URL (java.net.URL)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Test (org.junit.Test)4 TemporaryFolder (org.junit.rules.TemporaryFolder)4 StandaloneAnalysisConfiguration (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration)4 StandaloneSonarLintEngine (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneSonarLintEngine)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 StandardCharsets (java.nio.charset.StandardCharsets)3 Collections (java.util.Collections)3 List (java.util.List)3 FileUtils (org.apache.commons.io.FileUtils)3