diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2018-11-13 15:38:22 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-01-16 09:42:59 +0100 |
commit | 4a659a05cf4ff177629e9cb78aa6a0721810ff61 (patch) | |
tree | 6f9a066e40db44cff8808f3d58285d2e7600fd8e /sonar-plugin-api/src/main/java/org/sonar/api/batch | |
parent | 8bbac3c6e0023978a59814cd1e77fd0efcb6c265 (diff) | |
download | sonarqube-4a659a05cf4ff177629e9cb78aa6a0721810ff61.tar.gz sonarqube-4a659a05cf4ff177629e9cb78aa6a0721810ff61.zip |
SONAR-11465 NoSonarFilter moved to project level
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/batch')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java | 17 |
1 files changed, 14 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 278d288d185..f7d640a4dbb 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 @@ -30,6 +30,8 @@ import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.function.Consumer; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -56,6 +58,7 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile private Metadata metadata; private boolean published; private boolean excludedForCoverage; + private final Set<Integer> noSonarLines = new HashSet<>(); public DefaultInputFile(DefaultIndexedFile indexedFile, Consumer<DefaultInputFile> metadataGenerator) { this(indexedFile, metadataGenerator, null); @@ -82,7 +85,7 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile public InputStream inputStream() throws IOException { return contents != null ? new ByteArrayInputStream(contents.getBytes(charset())) : new BOMInputStream(Files.newInputStream(path()), - ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE); + ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE); } @Override @@ -242,7 +245,7 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile checkMetadata(); Preconditions.checkState(metadata.originalLineEndOffsets() != null, "InputFile is not properly initialized."); Preconditions.checkState(metadata.originalLineEndOffsets().length == metadata.lines(), - "InputFile is not properly initialized. 'originalLineEndOffsets' property length should be equal to 'lines'"); + "InputFile is not properly initialized. 'originalLineEndOffsets' property length should be equal to 'lines'"); return metadata.originalLineEndOffsets(); } @@ -299,7 +302,7 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile int line = findLine(globalOffset); int startLineOffset = originalLineStartOffsets()[line - 1]; // In case the global offset is between \r and \n, move the pointer to a valid location - return new DefaultTextPointer(line, Math.min(globalOffset, originalLineEndOffsets()[line -1]) - startLineOffset); + return new DefaultTextPointer(line, Math.min(globalOffset, originalLineEndOffsets()[line - 1]) - startLineOffset); } public DefaultInputFile setStatus(Status status) { @@ -369,4 +372,12 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile return indexedFile.uri(); } + public void noSonarAt(Set<Integer> noSonarLines) { + this.noSonarLines.addAll(noSonarLines); + } + + public boolean hasNoSonarAt(int line) { + return this.noSonarLines.contains(line); + } + } |