diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-02-21 17:10:55 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-02-21 17:11:07 +0100 |
commit | ce227110b0670bd0df0485fdced7b8758e5b1f67 (patch) | |
tree | 0bf47b293f33e62b3b1f709f5ae94b159f7c233b /sonar-plugin-api/src | |
parent | 482e0dd02074d088cfabbdbcc35234edca1906c6 (diff) | |
download | sonarqube-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.java | 3 | ||||
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java | 6 |
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(); |