diff options
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/scan2')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerMeasureCache.java (renamed from sonar-batch/src/main/java/org/sonar/batch/scan2/MeasureCache.java) | 18 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java | 9 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java | 26 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java | 4 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan2/Phase2Executor.java | 3 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java | 6 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan2/ScanTaskObserver.java | 2 |
7 files changed, 39 insertions, 29 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/MeasureCache.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerMeasureCache.java index 96ab8adc9de..593324a1c73 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/MeasureCache.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzerMeasureCache.java @@ -21,7 +21,7 @@ package org.sonar.batch.scan2; import com.google.common.base.Preconditions; import org.sonar.api.BatchComponent; -import org.sonar.batch.api.analyzer.measure.AnalyzerMeasure; +import org.sonar.api.batch.analyzer.measure.internal.DefaultAnalyzerMeasure; import org.sonar.batch.index.Cache; import org.sonar.batch.index.Cache.Entry; import org.sonar.batch.index.Caches; @@ -29,36 +29,36 @@ import org.sonar.batch.index.Caches; /** * Cache of all measures. This cache is shared amongst all project modules. */ -public class MeasureCache implements BatchComponent { +public class AnalyzerMeasureCache implements BatchComponent { - private final Cache<AnalyzerMeasure<?>> cache; + private final Cache<DefaultAnalyzerMeasure> cache; - public MeasureCache(Caches caches) { + public AnalyzerMeasureCache(Caches caches) { cache = caches.createCache("measures"); } - public Iterable<Entry<AnalyzerMeasure<?>>> entries() { + public Iterable<Entry<DefaultAnalyzerMeasure>> entries() { return cache.entries(); } - public AnalyzerMeasure<?> byMetric(String resourceKey, String metricKey) { + public DefaultAnalyzerMeasure<?> byMetric(String resourceKey, String metricKey) { return cache.get(resourceKey, metricKey); } - public MeasureCache put(String resourceKey, AnalyzerMeasure<?> measure) { + public AnalyzerMeasureCache put(String resourceKey, DefaultAnalyzerMeasure<?> measure) { Preconditions.checkNotNull(resourceKey); Preconditions.checkNotNull(measure.metricKey()); cache.put(resourceKey, measure.metricKey(), measure); return this; } - public boolean contains(String resourceKey, AnalyzerMeasure<?> measure) { + public boolean contains(String resourceKey, DefaultAnalyzerMeasure<?> measure) { Preconditions.checkNotNull(resourceKey); Preconditions.checkNotNull(measure); return cache.containsKey(resourceKey, measure.metricKey()); } - public Iterable<AnalyzerMeasure<?>> all() { + public Iterable<DefaultAnalyzerMeasure> all() { return cache.values(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java index c0ae6dbbaab..ce2d9e3effb 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java @@ -22,10 +22,10 @@ package org.sonar.batch.scan2; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.BatchComponent; +import org.sonar.api.batch.analyzer.Analyzer; +import org.sonar.api.batch.analyzer.AnalyzerContext; +import org.sonar.api.batch.analyzer.internal.DefaultAnalyzerDescriptor; import org.sonar.api.platform.ComponentContainer; -import org.sonar.batch.api.analyzer.Analyzer; -import org.sonar.batch.api.analyzer.AnalyzerContext; -import org.sonar.batch.api.analyzer.AnalyzerDescriptor; import java.util.Collection; @@ -44,7 +44,8 @@ public class AnalyzersExecutor implements BatchComponent { for (Analyzer analyzer : analyzers) { - AnalyzerDescriptor descriptor = analyzer.describe(); + DefaultAnalyzerDescriptor descriptor = new DefaultAnalyzerDescriptor(); + analyzer.describe(descriptor); LOG.info("Execute analyzer: " + descriptor.name()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java index 253bf0cab41..5fc2961ef84 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultAnalyzerContext.java @@ -19,14 +19,17 @@ */ package org.sonar.batch.scan2; +import org.sonar.api.batch.analyzer.AnalyzerContext; +import org.sonar.api.batch.analyzer.issue.AnalyzerIssue; +import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure; +import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder; +import org.sonar.api.batch.analyzer.measure.internal.DefaultAnalyzerMeasure; +import org.sonar.api.batch.analyzer.measure.internal.DefaultAnalyzerMeasureBuilder; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.measures.Metric; import org.sonar.api.issue.internal.DefaultIssue; import org.sonar.api.rule.RuleKey; -import org.sonar.batch.api.analyzer.AnalyzerContext; -import org.sonar.batch.api.analyzer.issue.AnalyzerIssue; -import org.sonar.batch.api.analyzer.measure.AnalyzerMeasure; -import org.sonar.batch.api.measures.Metric; import org.sonar.batch.issue.ModuleIssues; import org.sonar.core.component.ComponentKeys; import org.sonar.core.issue.DefaultIssueBuilder; @@ -36,17 +39,22 @@ import java.util.Collection; public class DefaultAnalyzerContext implements AnalyzerContext { - private final MeasureCache measureCache; + private final AnalyzerMeasureCache measureCache; private ProjectDefinition def; private ModuleIssues moduleIssues; - public DefaultAnalyzerContext(ProjectDefinition def, MeasureCache measureCache, ModuleIssues moduleIssues) { + public DefaultAnalyzerContext(ProjectDefinition def, AnalyzerMeasureCache measureCache, ModuleIssues moduleIssues) { this.def = def; this.measureCache = measureCache; this.moduleIssues = moduleIssues; } @Override + public <G extends Serializable> AnalyzerMeasureBuilder<G> measureBuilder() { + return new DefaultAnalyzerMeasureBuilder<G>(); + } + + @Override public AnalyzerMeasure getMeasure(String metricKey) { return measureCache.byMetric(def.getKey(), metricKey); } @@ -67,11 +75,11 @@ public class DefaultAnalyzerContext implements AnalyzerContext { } @Override - public void addMeasure(org.sonar.batch.api.analyzer.measure.AnalyzerMeasure<?> measure) { + public void addMeasure(AnalyzerMeasure<?> measure) { if (measure.inputFile() != null) { - measureCache.put(ComponentKeys.createEffectiveKey(def.getKey(), measure.inputFile()), measure); + measureCache.put(ComponentKeys.createEffectiveKey(def.getKey(), measure.inputFile()), (DefaultAnalyzerMeasure) measure); } else { - measureCache.put(def.getKey(), measure); + measureCache.put(def.getKey(), (DefaultAnalyzerMeasure) measure); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java index 24435c0dc55..6982d3da3b2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java @@ -21,12 +21,12 @@ package org.sonar.batch.scan2; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.sonar.api.BatchComponent; +import org.sonar.api.batch.InstantiationStrategy; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.rule.CheckFactory; import org.sonar.api.platform.ComponentContainer; import org.sonar.api.scan.filesystem.FileExclusions; -import org.sonar.batch.api.BatchComponent; -import org.sonar.batch.api.InstantiationStrategy; import org.sonar.batch.bootstrap.BatchExtensionDictionnary; import org.sonar.batch.bootstrap.ExtensionInstaller; import org.sonar.batch.bootstrap.ExtensionMatcher; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/Phase2Executor.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/Phase2Executor.java index fcbec9bf4b4..0b6f2071df9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/Phase2Executor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/Phase2Executor.java @@ -19,11 +19,12 @@ */ package org.sonar.batch.scan2; +import org.sonar.api.batch.analyzer.AnalyzerContext; + import com.google.common.collect.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.batch.api.analyzer.AnalyzerContext; import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader; import org.sonar.batch.phases.SensorsExecutor; import org.sonar.batch.rule.QProfileVerifier; diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java index 6a3d9bfcfac..f5dd041678e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java @@ -20,7 +20,9 @@ package org.sonar.batch.scan2; import com.google.common.annotations.VisibleForTesting; +import org.sonar.api.BatchComponent; import org.sonar.api.CoreProperties; +import org.sonar.api.batch.InstantiationStrategy; import org.sonar.api.batch.bootstrap.ProjectBootstrapper; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.bootstrap.ProjectReactor; @@ -28,8 +30,6 @@ import org.sonar.api.config.Settings; import org.sonar.api.platform.ComponentContainer; import org.sonar.api.scan.filesystem.PathResolver; import org.sonar.api.utils.SonarException; -import org.sonar.batch.api.BatchComponent; -import org.sonar.batch.api.InstantiationStrategy; import org.sonar.batch.bootstrap.ExtensionInstaller; import org.sonar.batch.bootstrap.ExtensionMatcher; import org.sonar.batch.bootstrap.ExtensionUtils; @@ -105,7 +105,7 @@ public class ProjectScanContainer extends ComponentContainer { ResourceCache.class, ComponentDataCache.class, ComponentDataPersister.class, - MeasureCache.class, + AnalyzerMeasureCache.class, // file system InputFileCache.class, diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ScanTaskObserver.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ScanTaskObserver.java index 89f5c7694cc..636ed9f34ed 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ScanTaskObserver.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ScanTaskObserver.java @@ -19,7 +19,7 @@ */ package org.sonar.batch.scan2; -import org.sonar.batch.api.BatchExtension; +import org.sonar.api.BatchExtension; public interface ScanTaskObserver extends BatchExtension { |