aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-06-10 09:45:15 +0200
committerJulien HENRY <henryju@yahoo.fr>2016-07-07 09:56:20 +0200
commit2d20c0f3f27356ad1f9aa430f3e5925c50756cfc (patch)
tree916658329d7245f97f3f390c1dee5c8659bde03b /sonar-scanner-engine
parenta4e0563f753bf04f6560f7014a974d2d4f248d84 (diff)
downloadsonarqube-2d20c0f3f27356ad1f9aa430f3e5925c50756cfc.tar.gz
sonarqube-2d20c0f3f27356ad1f9aa430f3e5925c50756cfc.zip
SONAR-7751, SONAR-7756 SonarLint API
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java10
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/DeprecatedSensorContext.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java16
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java3
5 files changed, 24 insertions, 13 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java
index 7fcece413b0..f3d60147662 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java
@@ -23,7 +23,7 @@ import java.util.List;
import javax.annotation.Nullable;
import org.sonar.api.ExtensionProvider;
import org.sonar.api.Plugin;
-import org.sonar.api.SonarQubeVersion;
+import org.sonar.api.RuntimeApiVersion;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.core.platform.PluginInfo;
@@ -31,12 +31,12 @@ import org.sonar.core.platform.PluginRepository;
public class ExtensionInstaller {
- private final SonarQubeVersion sonarQubeVersion;
+ private final RuntimeApiVersion runtimeApiVersionVersion;
private final PluginRepository pluginRepository;
private final AnalysisMode analysisMode;
- public ExtensionInstaller(SonarQubeVersion sonarQubeVersion, PluginRepository pluginRepository, AnalysisMode analysisMode) {
- this.sonarQubeVersion = sonarQubeVersion;
+ public ExtensionInstaller(RuntimeApiVersion sonarQubeVersion, PluginRepository pluginRepository, AnalysisMode analysisMode) {
+ this.runtimeApiVersionVersion = sonarQubeVersion;
this.pluginRepository = pluginRepository;
this.analysisMode = analysisMode;
}
@@ -51,7 +51,7 @@ public class ExtensionInstaller {
// plugin extensions
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Plugin plugin = pluginRepository.getPluginInstance(pluginInfo.getKey());
- Plugin.Context context = new Plugin.Context(sonarQubeVersion.get());
+ Plugin.Context context = new Plugin.Context(runtimeApiVersionVersion.get(), runtimeApiVersionVersion.isSonarlintRuntime());
plugin.define(context);
for (Object extension : context.getExtensions()) {
doInstall(container, matcher, pluginInfo, extension);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
index 47a9422efd8..fcd089cee54 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
@@ -23,7 +23,7 @@ import java.util.List;
import java.util.Map;
import org.sonar.api.Plugin;
-import org.sonar.api.internal.SonarQubeVersionFactory;
+import org.sonar.api.internal.RuntimeApiVersionFactory;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.UriReader;
import org.sonar.api.utils.log.Logger;
@@ -76,7 +76,7 @@ public class GlobalContainer extends ComponentContainer {
BatchPluginPredicate.class,
ExtensionInstaller.class,
- SonarQubeVersionFactory.create(System2.INSTANCE),
+ RuntimeApiVersionFactory.create(System2.INSTANCE, false),
CachesManager.class,
GlobalSettings.class,
new BatchWsClientProvider(),
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/DeprecatedSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/DeprecatedSensorContext.java
index 422cedf7205..876e3062d94 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/DeprecatedSensorContext.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/deprecated/DeprecatedSensorContext.java
@@ -21,7 +21,7 @@ package org.sonar.scanner.deprecated;
import java.io.Serializable;
import java.util.Collection;
-import org.sonar.api.SonarQubeVersion;
+import org.sonar.api.RuntimeApiVersion;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.fs.FileSystem;
@@ -51,7 +51,7 @@ public class DeprecatedSensorContext extends DefaultSensorContext implements Sen
private final CoverageExclusions coverageFilter;
public DeprecatedSensorContext(InputModule module, DefaultIndex index, Project project, Settings settings, FileSystem fs, ActiveRules activeRules,
- AnalysisMode analysisMode, CoverageExclusions coverageFilter, SensorStorage sensorStorage, SonarQubeVersion sqVersion) {
+ AnalysisMode analysisMode, CoverageExclusions coverageFilter, SensorStorage sensorStorage, RuntimeApiVersion sqVersion) {
super(module, settings, fs, activeRules, analysisMode, sensorStorage, sqVersion);
this.index = index;
this.project = project;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
index 801224b4450..55ac8d2161b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
@@ -20,7 +20,7 @@
package org.sonar.scanner.sensor;
import java.io.Serializable;
-import org.sonar.api.SonarQubeVersion;
+import org.sonar.api.RuntimeApiVersion;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputModule;
@@ -57,10 +57,10 @@ public class DefaultSensorContext implements SensorContext {
private final SensorStorage sensorStorage;
private final AnalysisMode analysisMode;
private final InputModule module;
- private final SonarQubeVersion sqVersion;
+ private final RuntimeApiVersion sqVersion;
public DefaultSensorContext(InputModule module, Settings settings, FileSystem fs, ActiveRules activeRules, AnalysisMode analysisMode, SensorStorage sensorStorage,
- SonarQubeVersion sqVersion) {
+ RuntimeApiVersion sqVersion) {
this.module = module;
this.settings = settings;
this.fs = fs;
@@ -96,6 +96,16 @@ public class DefaultSensorContext implements SensorContext {
}
@Override
+ public Version getRuntimeApiVersion() {
+ return sqVersion.get();
+ }
+
+ @Override
+ public boolean isSonarLintRuntime() {
+ return sqVersion.isSonarlintRuntime();
+ }
+
+ @Override
public <G extends Serializable> NewMeasure<G> newMeasure() {
return new DefaultMeasure<>(sensorStorage);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
index 0f28d6e42f8..caf7dd58f7a 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
@@ -67,7 +67,7 @@ public class DefaultSensorContextTest {
settings = new Settings();
sensorStorage = mock(SensorStorage.class);
analysisMode = mock(AnalysisMode.class);
- sqVersion = new SonarQubeVersion(Version.parse("5.5"));
+ sqVersion = new SonarQubeVersion(Version.parse("5.5"), false);
adaptor = new DefaultSensorContext(mock(InputModule.class), settings, fs, activeRules, analysisMode, sensorStorage, sqVersion);
}
@@ -77,6 +77,7 @@ public class DefaultSensorContextTest {
assertThat(adaptor.fileSystem()).isEqualTo(fs);
assertThat(adaptor.settings()).isEqualTo(settings);
assertThat(adaptor.getSonarQubeVersion()).isEqualTo(Version.parse("5.5"));
+ assertThat(adaptor.isSonarLintRuntime()).isFalse();
assertThat(adaptor.newIssue()).isNotNull();
assertThat(adaptor.newMeasure()).isNotNull();