summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-02-21 17:10:55 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-02-21 17:11:07 +0100
commitce227110b0670bd0df0485fdced7b8758e5b1f67 (patch)
tree0bf47b293f33e62b3b1f709f5ae94b159f7c233b /sonar-plugin-api/src
parent482e0dd02074d088cfabbdbcc35234edca1906c6 (diff)
downloadsonarqube-ce227110b0670bd0df0485fdced7b8758e5b1f67.tar.gz
sonarqube-ce227110b0670bd0df0485fdced7b8758e5b1f67.zip
SONAR-926 Fix org.sonar.api.resources.InputFile#getRelativePath()
Contrary to org.sonar.api.batch.fs.InputFile#relativePath(), it's the path relative to source dir
Diffstat (limited to 'sonar-plugin-api/src')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java3
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java6
2 files changed, 6 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
index 226a975765c..63e3c9ec01d 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
@@ -20,6 +20,7 @@
package org.sonar.api.batch.fs.internal;
import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang.StringUtils;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.utils.PathUtils;
@@ -239,7 +240,7 @@ public class DefaultInputFile implements InputFile, org.sonar.api.resources.Inpu
@Deprecated
@Override
public String getRelativePath() {
- return relativePath();
+ return pathRelativeToSourceDir;
}
@Override
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
index afbc74f2928..ff77bfe2565 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
@@ -43,10 +43,12 @@ public class DefaultInputFileTest {
.setLines(42)
.setLanguage("php")
.setStatus(InputFile.Status.ADDED)
- .setType(InputFile.Type.TEST);
+ .setType(InputFile.Type.TEST)
+ .setPathRelativeToSourceDir("Foo.php");
assertThat(inputFile.relativePath()).isEqualTo("src/Foo.php");
- assertThat(inputFile.getRelativePath()).isEqualTo("src/Foo.php");
+ // deprecated method is different -> path relative to source dir
+ assertThat(inputFile.getRelativePath()).isEqualTo("Foo.php");
assertThat(new File(inputFile.relativePath())).isRelative();
assertThat(inputFile.absolutePath()).endsWith("Foo.php");
assertThat(new File(inputFile.absolutePath())).isAbsolute();