use of org.sonarsource.sonarlint.core.analysis.container.analysis.issue.ignore.scanner.IssueExclusionsLoader.DoubleRegexpMatcher in project sonarlint-core by SonarSource.
the class IssueExclusionsRegexpScannerTests method init.
@BeforeEach
void init() {
MockitoAnnotations.initMocks(this);
blockPatterns = Arrays.asList(new DoubleRegexpMatcher(Pattern.compile("// SONAR-OFF"), Pattern.compile("// SONAR-ON")), new DoubleRegexpMatcher(Pattern.compile("// FOO-OFF"), Pattern.compile("// FOO-ON")));
allFilePatterns = Collections.singletonList(Pattern.compile("@SONAR-IGNORE-ALL"));
javaFile = new SonarLintInputFile(new OnDiskTestClientInputFile(Paths.get("src/Foo.java"), "src/Foo.java", false, StandardCharsets.UTF_8), f -> mock(Metadata.class));
regexpScanner = new IssueExclusionsRegexpScanner(javaFile, allFilePatterns, blockPatterns);
}
use of org.sonarsource.sonarlint.core.analysis.container.analysis.issue.ignore.scanner.IssueExclusionsLoader.DoubleRegexpMatcher in project sonarlint-core by SonarSource.
the class IssueExclusionsRegexpScanner method checkDoubleRegexps.
private void checkDoubleRegexps(String line, int lineIndex) {
if (currentMatcher == null) {
for (DoubleRegexpMatcher matcher : blockMatchers) {
if (matcher.matchesFirstPattern(line)) {
startExclusion(lineIndex);
currentMatcher = matcher;
break;
}
}
} else {
if (currentMatcher.matchesSecondPattern(line)) {
endExclusion(lineIndex);
currentMatcher = null;
}
}
}
Aggregations