aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-01-17 17:45:09 +0100
committerDuarte Meneses <duarte.meneses@sonarsource.com>2017-01-27 16:26:30 +0100
commiteea589c564a924993e8edba9d8fa9691e756bce4 (patch)
treec112f6d41d7f4dfeb7ad8d14f895e1b879a68411 /sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor
parent211a993bd85b5d12ace1686b133677381da8c597 (diff)
downloadsonarqube-eea589c564a924993e8edba9d8fa9691e756bce4.tar.gz
sonarqube-eea589c564a924993e8edba9d8fa9691e756bce4.zip
Refactor resources API
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java13
2 files changed, 12 insertions, 7 deletions
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 ec7b8cfe5b6..8600ec3fdab 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
@@ -23,6 +23,7 @@ import java.io.Serializable;
import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.FileSystem;
+import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputModule;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.sensor.SensorContext;
@@ -156,4 +157,9 @@ public class DefaultSensorContext implements SensorContext {
public void addContextProperty(String key, String value) {
sensorStorage.storeProperty(key, value);
}
+
+ @Override
+ public void markForPublishing(InputFile inputFile) {
+
+ }
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
index 8beba97adae..051565781cd 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java
@@ -33,6 +33,7 @@ import java.util.stream.Stream;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.measure.Metric;
import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage;
@@ -54,7 +55,6 @@ import org.sonar.duplications.block.Block;
import org.sonar.duplications.internal.pmd.PmdBlockChunker;
import org.sonar.scanner.cpd.deprecated.DefaultCpdBlockIndexer;
import org.sonar.scanner.cpd.index.SonarCpdBlockIndex;
-import org.sonar.scanner.index.BatchComponentCache;
import org.sonar.scanner.issue.ModuleIssues;
import org.sonar.scanner.protocol.output.FileStructure;
import org.sonar.scanner.protocol.output.ScannerReport;
@@ -142,7 +142,6 @@ public class DefaultSensorStorage implements SensorStorage {
private final MetricFinder metricFinder;
private final ModuleIssues moduleIssues;
private final CoverageExclusions coverageExclusions;
- private final BatchComponentCache componentCache;
private final ReportPublisher reportPublisher;
private final MeasureCache measureCache;
private final SonarCpdBlockIndex index;
@@ -156,14 +155,13 @@ public class DefaultSensorStorage implements SensorStorage {
public DefaultSensorStorage(MetricFinder metricFinder, ModuleIssues moduleIssues,
Settings settings,
- CoverageExclusions coverageExclusions, BatchComponentCache componentCache, ReportPublisher reportPublisher,
+ CoverageExclusions coverageExclusions, ReportPublisher reportPublisher,
MeasureCache measureCache, SonarCpdBlockIndex index,
ContextPropertiesCache contextPropertiesCache, ScannerMetrics scannerMetrics) {
this.metricFinder = metricFinder;
this.moduleIssues = moduleIssues;
this.settings = settings;
this.coverageExclusions = coverageExclusions;
- this.componentCache = componentCache;
this.reportPublisher = reportPublisher;
this.measureCache = measureCache;
this.index = index;
@@ -352,8 +350,8 @@ public class DefaultSensorStorage implements SensorStorage {
@Override
public void store(DefaultHighlighting highlighting) {
ScannerReportWriter writer = reportPublisher.getWriter();
- InputFile inputFile = highlighting.inputFile();
- int componentRef = componentCache.get(inputFile).batchId();
+ DefaultInputFile inputFile = (DefaultInputFile) highlighting.inputFile();
+ int componentRef = inputFile.batchId();
if (writer.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, componentRef)) {
throw new UnsupportedOperationException("Trying to save highlighting twice for the same file is not supported: " + inputFile.absolutePath());
}
@@ -376,7 +374,8 @@ public class DefaultSensorStorage implements SensorStorage {
@Override
public void store(DefaultSymbolTable symbolTable) {
ScannerReportWriter writer = reportPublisher.getWriter();
- int componentRef = componentCache.get(symbolTable.inputFile()).batchId();
+ DefaultInputFile inputFile = (DefaultInputFile) symbolTable.inputFile();
+ int componentRef = inputFile.batchId();
if (writer.hasComponentData(FileStructure.Domain.SYMBOLS, componentRef)) {
throw new UnsupportedOperationException("Trying to save symbol table twice for the same file is not supported: " + symbolTable.inputFile().absolutePath());
}