aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-12-01 16:57:56 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2014-12-01 16:57:56 +0100
commitab4232b3931437951dda555553fbd2ef1daada74 (patch)
tree06fd470fb5a3a2966979bca39b45dfbf942045d3 /sonar-batch
parent312e3bd4cda4abfe595fd07202dbcf5817ba1410 (diff)
parenta2d5e82501f3ed8d96239845842770515f5087e6 (diff)
downloadsonarqube-ab4232b3931437951dda555553fbd2ef1daada74.tar.gz
sonarqube-ab4232b3931437951dda555553fbd2ef1daada74.zip
Merge remote-tracking branch 'origin/branch-4.5'
Conflicts: sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java sonar-plugin-api/src/main/java/org/sonar/api/component/ResourcePerspectives.java sonar-plugin-api/src/main/java/org/sonar/api/web/CodeColorizerFormat.java
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java20
1 files changed, 16 insertions, 4 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 b8092ee54b4..eeecd48b8bd 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java
@@ -25,11 +25,14 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.batch.Event;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.SonarIndex;
+import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.Metric;
+import org.sonar.api.resources.Directory;
import org.sonar.api.resources.File;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.ProjectLink;
@@ -259,15 +262,24 @@ public class DefaultSensorContext implements SensorContext {
@Override
public Measure saveMeasure(InputFile inputFile, Metric metric, Double value) {
- return saveMeasure(fromInputFile(inputFile), metric, value);
+ return saveMeasure(getResource(inputFile), metric, value);
}
@Override
public Measure saveMeasure(InputFile inputFile, Measure measure) {
- return saveMeasure(fromInputFile(inputFile), measure);
+ return saveMeasure(getResource(inputFile), measure);
}
- private Resource fromInputFile(InputFile inputFile) {
- return File.create(inputFile.relativePath());
+ @Override
+ public Resource getResource(InputPath inputPath) {
+ Resource r;
+ if (inputPath instanceof InputDir) {
+ r = Directory.create(((InputDir) inputPath).relativePath());
+ } else if (inputPath instanceof InputFile) {
+ r = File.create(((InputFile) inputPath).relativePath());
+ } else {
+ throw new IllegalArgumentException("Unknow input path type: " + inputPath);
+ }
+ return getResource(r);
}
}