diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-01-09 15:27:53 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-01-09 15:27:53 +0100 |
commit | 24905998ba2e6b91efa4dcbb8f017078030fbbcd (patch) | |
tree | 09e91f358441ad4b4ac29be6b80ee76bba4ace79 /sonar-batch | |
parent | a8fea85fe5d509d2c895286edd31d6ca3cebbcfe (diff) | |
download | sonarqube-24905998ba2e6b91efa4dcbb8f017078030fbbcd.tar.gz sonarqube-24905998ba2e6b91efa4dcbb8f017078030fbbcd.zip |
SONAR-4783 Restore indexing methods to allow indexing of methods/paragraphs
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java index 4ca86170d38..3376c65013b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java @@ -19,6 +19,8 @@ */ package org.sonar.batch; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.sonar.api.batch.Event; import org.sonar.api.batch.SensorContext; import org.sonar.api.batch.SonarIndex; @@ -29,7 +31,9 @@ import org.sonar.api.measures.Metric; import org.sonar.api.resources.Project; import org.sonar.api.resources.ProjectLink; import org.sonar.api.resources.Resource; +import org.sonar.api.resources.ResourceUtils; import org.sonar.api.rules.Violation; +import org.sonar.api.utils.SonarException; import org.sonar.core.measure.MeasurementFilters; import java.util.Collection; @@ -39,6 +43,8 @@ import java.util.Set; public class DefaultSensorContext implements SensorContext { + private static final Logger LOG = LoggerFactory.getLogger(DefaultSensorContext.class); + private SonarIndex index; private Project project; private MeasurementFilters filters; @@ -54,11 +60,26 @@ public class DefaultSensorContext implements SensorContext { } public boolean index(Resource resource) { - return true; + // SONAR-5006 + if (ResourceUtils.isPersistable(resource)) { + logWarning(); + return true; + } + return index.index(resource); } public boolean index(Resource resource, Resource parentReference) { - return true; + // SONAR-5006 + if (ResourceUtils.isPersistable(resource)) { + logWarning(); + return true; + } + return index.index(resource, parentReference); + } + + private void logWarning() { + LOG.debug("Plugins are no more allowed to index physical resources like directories and files. This is now handled by the platform.", new SonarException( + "Plugin should not index physical resources")); } public boolean isExcluded(Resource reference) { |