diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-18 18:10:12 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-06-19 10:19:37 +0200 |
commit | b65c25e4565ce0e7fe4deb15e9d8d2fd8544b731 (patch) | |
tree | 614027ba077c744e2f6ec17db673bd7f107b9b40 /sonar-batch | |
parent | 603b12e076df7851bcae261bb56ba8ed12422241 (diff) | |
download | sonarqube-b65c25e4565ce0e7fe4deb15e9d8d2fd8544b731.tar.gz sonarqube-b65c25e4565ce0e7fe4deb15e9d8d2fd8544b731.zip |
SONAR-5389 Sort analyzers according to metrics used/produced
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java | 15 | ||||
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan2/AnalyzersExecutor.java | 10 |
2 files changed, 13 insertions, 12 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java index b5979b998ea..fca38c4a4ce 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java @@ -19,18 +19,19 @@ */ package org.sonar.batch.bootstrap; -import org.sonar.api.batch.analyzer.Analyzer; -import org.sonar.api.batch.analyzer.AnalyzerContext; - import com.google.common.collect.Lists; import org.apache.commons.lang.ClassUtils; import org.sonar.api.batch.CheckProject; import org.sonar.api.batch.Sensor; +import org.sonar.api.batch.analyzer.Analyzer; +import org.sonar.api.batch.analyzer.AnalyzerContext; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.platform.ComponentContainer; import org.sonar.api.resources.Project; import org.sonar.batch.scan.SensorWrapper; +import javax.annotation.Nullable; + import java.util.Collection; import java.util.List; @@ -48,7 +49,7 @@ public class BatchExtensionDictionnary extends org.sonar.api.batch.BatchExtensio this.context = context; } - public <T> Collection<T> select(Class<T> type, Project project, boolean sort, ExtensionMatcher matcher) { + public <T> Collection<T> select(Class<T> type, @Nullable Project project, boolean sort, @Nullable ExtensionMatcher matcher) { List<T> result = getFilteredExtensions(type, project, matcher); if (sort) { return sort(result); @@ -56,9 +57,9 @@ public class BatchExtensionDictionnary extends org.sonar.api.batch.BatchExtensio return result; } - private <T> List<T> getFilteredExtensions(Class<T> type, Project project, ExtensionMatcher matcher) { + private <T> List<T> getFilteredExtensions(Class<T> type, @Nullable Project project, @Nullable ExtensionMatcher matcher) { List<T> result = Lists.newArrayList(); - for (Object extension : getExtensions()) { + for (Object extension : getExtensions(type)) { if (type == Sensor.class && extension instanceof Analyzer) { extension = new SensorWrapper((Analyzer) extension, context, fs); } @@ -69,7 +70,7 @@ public class BatchExtensionDictionnary extends org.sonar.api.batch.BatchExtensio return result; } - private boolean shouldKeep(Class type, Object extension, Project project, ExtensionMatcher matcher) { + private boolean shouldKeep(Class type, Object extension, @Nullable Project project, @Nullable ExtensionMatcher matcher) { boolean keep = (ClassUtils.isAssignable(extension.getClass(), type) || (type == Sensor.class && ClassUtils.isAssignable(extension.getClass(), Analyzer.class))) && (matcher == null || matcher.accept(extension)); 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 ce2d9e3effb..f90cb5ad4a4 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 @@ -25,7 +25,7 @@ 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.bootstrap.BatchExtensionDictionnary; import java.util.Collection; @@ -33,14 +33,14 @@ public class AnalyzersExecutor implements BatchComponent { private static final Logger LOG = LoggerFactory.getLogger(AnalyzersExecutor.class); - private ComponentContainer container; + private BatchExtensionDictionnary selector; - public AnalyzersExecutor(ComponentContainer container) { - this.container = container; + public AnalyzersExecutor(BatchExtensionDictionnary selector) { + this.selector = selector; } public void execute(AnalyzerContext context) { - Collection<Analyzer> analyzers = container.getComponentsByType(Analyzer.class); + Collection<Analyzer> analyzers = selector.select(Analyzer.class, null, true, null); for (Analyzer analyzer : analyzers) { |