aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2017-08-01 16:31:07 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-08-04 14:58:16 +0200
commitac7edbe5890ae7921593dda7520157dca652860d (patch)
treef08f51e73ae249e74c4e9a4a33ef6b004fe177f4 /sonar-plugin-api
parente6b28c1ba4e7627f4599590ddfcc21875843ce87 (diff)
downloadsonarqube-ac7edbe5890ae7921593dda7520157dca652860d.tar.gz
sonarqube-ac7edbe5890ae7921593dda7520157dca652860d.zip
SONAR-9574 Same file indexed in different modules
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java6
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java8
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/cpd/internal/DefaultCpdTokensTest.java3
5 files changed, 27 insertions, 6 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java
index 0d07003dce5..2f456b489fc 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultIndexedFile.java
@@ -70,6 +70,14 @@ public class DefaultIndexedFile extends DefaultInputComponent implements Indexed
return sensorStrategy.isGlobal() ? projectRelativePath : moduleRelativePath;
}
+ public String getModuleRelativePath() {
+ return moduleRelativePath;
+ }
+
+ public String getProjectRelativePath() {
+ return projectRelativePath;
+ }
+
@Override
public String absolutePath() {
return PathUtils.sanitize(path().toString());
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 3fe157a43e2..effb5663f31 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
@@ -125,6 +125,14 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile
return indexedFile.relativePath();
}
+ public String getModuleRelativePath() {
+ return indexedFile.getModuleRelativePath();
+ }
+
+ public String getProjectRelativePath() {
+ return indexedFile.getProjectRelativePath();
+ }
+
@Override
public String absolutePath() {
return indexedFile.absolutePath();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java
index 76e1a74ec29..30d039436b7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java
@@ -20,10 +20,8 @@
package org.sonar.api.scan.issue.filter;
import java.util.Date;
-
import javax.annotation.CheckForNull;
import javax.annotation.concurrent.ThreadSafe;
-
import org.sonar.api.rule.RuleKey;
/**
@@ -55,6 +53,10 @@ public interface FilterableIssue {
@CheckForNull
Double gap();
+ /**
+ * @deprecated since 6.6 useless
+ */
+ @Deprecated
Date creationDate();
String projectKey();
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 7d699d5bf39..5eb4b0a9d47 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
@@ -74,8 +74,6 @@ public class DefaultInputFileTest {
.setStatus(InputFile.Status.ADDED)
.setCharset(StandardCharsets.ISO_8859_1);
- assertThat(inputFile.relativePath()).isEqualTo(MODULE_RELATIVE_PATH);
- assertThat(new File(inputFile.relativePath())).isRelative();
assertThat(inputFile.absolutePath()).endsWith("Foo.php");
assertThat(inputFile.filename()).isEqualTo("Foo.php");
assertThat(inputFile.uri()).hasPath(baseDir.resolve(PROJECT_RELATIVE_PATH).toUri().getPath());
@@ -86,8 +84,14 @@ public class DefaultInputFileTest {
assertThat(inputFile.lines()).isEqualTo(42);
assertThat(inputFile.charset()).isEqualTo(StandardCharsets.ISO_8859_1);
+ assertThat(inputFile.getModuleRelativePath()).isEqualTo(MODULE_RELATIVE_PATH);
+ assertThat(inputFile.getProjectRelativePath()).isEqualTo(PROJECT_RELATIVE_PATH);
+
+ assertThat(inputFile.relativePath()).isEqualTo(MODULE_RELATIVE_PATH);
+ assertThat(new File(inputFile.relativePath())).isRelative();
sensorStrategy.setGlobal(true);
assertThat(inputFile.relativePath()).isEqualTo(PROJECT_RELATIVE_PATH);
+ assertThat(new File(inputFile.relativePath())).isRelative();
}
@Test
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/cpd/internal/DefaultCpdTokensTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/cpd/internal/DefaultCpdTokensTest.java
index 62a268f00f7..30126f0271d 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/cpd/internal/DefaultCpdTokensTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/cpd/internal/DefaultCpdTokensTest.java
@@ -23,7 +23,6 @@ import org.junit.Test;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import static org.assertj.core.api.Assertions.assertThat;
@@ -146,7 +145,7 @@ public class DefaultCpdTokensTest {
tokens.addToken(INPUT_FILE.newRange(1, 2, 1, 5), "foo");
fail("Expected exception");
} catch (Exception e) {
- assertThat(e).hasMessage("Tokens of file [moduleKey=foo, relative=src/Foo.java, basedir=foo] should be provided in order.\n" +
+ assertThat(e).hasMessage("Tokens of file src/Foo.java should be provided in order.\n" +
"Previous token: Range[from [line=1, lineOffset=6] to [line=1, lineOffset=10]]\n" +
"Last token: Range[from [line=1, lineOffset=2] to [line=1, lineOffset=5]]");
}