diff --git a/SUPPORTED-FORMATS.md b/SUPPORTED-FORMATS.md index 47cd17957..380234570 100644 --- a/SUPPORTED-FORMATS.md +++ b/SUPPORTED-FORMATS.md @@ -1,4 +1,4 @@ - + # Supported Report Formats The static analysis model supports the following report formats. diff --git a/src/main/java/edu/hm/hafner/analysis/LookaheadParser.java b/src/main/java/edu/hm/hafner/analysis/LookaheadParser.java index f57ea4875..de45cf064 100644 --- a/src/main/java/edu/hm/hafner/analysis/LookaheadParser.java +++ b/src/main/java/edu/hm/hafner/analysis/LookaheadParser.java @@ -28,6 +28,8 @@ public abstract class LookaheadParser extends IssueParser { private static final String CMAKE_PREFIX = "-- Build files have"; private static final Pattern CMAKE_PATH = Pattern.compile(CMAKE_PREFIX + " been written to: (?.*)"); + private static final int MAX_LINE_LENGTH = 4000; // see JENKINS-55805 + private final Pattern pattern; /** @@ -113,7 +115,7 @@ protected abstract Optional createIssue(Matcher matcher, LookaheadStream * line does not contain a warning. */ protected boolean isLineInteresting(final String line) { - return true; + return line.length() < MAX_LINE_LENGTH; // skip long lines, see JENKINS-55805 } /** diff --git a/src/main/java/edu/hm/hafner/analysis/RegexpLineParser.java b/src/main/java/edu/hm/hafner/analysis/RegexpLineParser.java deleted file mode 100644 index d3559162f..000000000 --- a/src/main/java/edu/hm/hafner/analysis/RegexpLineParser.java +++ /dev/null @@ -1,57 +0,0 @@ -package edu.hm.hafner.analysis; - -import java.util.Optional; -import java.util.regex.Matcher; - -import edu.hm.hafner.util.LookaheadStream; - -/** - * Parses a report file line by line for issues using a pre-defined regular expression. If the regular expression - * matches then the abstract method {@link #createIssue(Matcher, IssueBuilder)} will be called. Sub classes need to - * provide an implementation that transforms the {@link Matcher} instance into a new issue. This class basically - * simplifies the parent class {@link LookaheadParser} so that sub classes are not allowed to consume additional lines - * of the report anymore. - * - * @author Ullrich Hafner - */ -public abstract class RegexpLineParser extends LookaheadParser { - private static final long serialVersionUID = 434000822024807289L; - - private static final int MAX_LINE_LENGTH = 4000; // see JENKINS-55805 - - /** - * Creates a new instance of {@link RegexpLineParser}. - * - * @param pattern - * pattern of compiler warnings - */ - protected RegexpLineParser(final String pattern) { - super(pattern); - } - - @Override - protected boolean isLineInteresting(final String line) { - return line.length() < MAX_LINE_LENGTH; // skip long lines, see JENKINS-55805 - } - - @Override - protected final Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, - final IssueBuilder builder) throws ParsingException { - return createIssue(matcher, builder); - } - - /** - * Creates a new issue for the specified pattern. This method is called for each matching line in the specified - * file. If a match is a false positive, then return {@link Optional#empty()} to ignore this warning. - * - * @param matcher - * the regular expression matcher - * @param builder - * the issue builder to use - * - * @return a new annotation for the specified pattern - * @throws ParsingException - * Signals that during parsing a non recoverable error has been occurred - */ - protected abstract Optional createIssue(Matcher matcher, IssueBuilder builder); -} diff --git a/src/main/java/edu/hm/hafner/analysis/parser/AcuCobolParser.java b/src/main/java/edu/hm/hafner/analysis/parser/AcuCobolParser.java index 5047c51d6..8b14906d8 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/AcuCobolParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/AcuCobolParser.java @@ -5,7 +5,8 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; +import edu.hm.hafner.util.LookaheadStream; import static edu.hm.hafner.analysis.Categories.*; @@ -14,7 +15,7 @@ * * @author jerryshea */ -public class AcuCobolParser extends RegexpLineParser { +public class AcuCobolParser extends LookaheadParser { private static final long serialVersionUID = -894639209290549425L; private static final String ACU_COBOL_WARNING_PATTERN = "^\\s*(\\[.*\\])?\\s*?(.*), line ([0-9]*): Warning: (.*)$"; @@ -32,7 +33,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(2)) .setLineStart(matcher.group(3)) .setCategory(guessCategory(matcher.group(4))) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/AnsibleLintParser.java b/src/main/java/edu/hm/hafner/analysis/parser/AnsibleLintParser.java index ea1a5bfa4..e5d17a865 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/AnsibleLintParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/AnsibleLintParser.java @@ -5,17 +5,18 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Ansible Lint warnings. - * + * * The parser expects the Ansible Lint output to be in a "parseable output in the format of pep8". * Pass the argument {@code -p} to Ansible Lint to get a compatible output. * * @author Ce Qi */ -public class AnsibleLintParser extends RegexpLineParser { +public class AnsibleLintParser extends LookaheadParser { private static final long serialVersionUID = 8481090596321427484L; private static final String ANSIBLE_LINT_WARNING_PATTERN = "(.*)\\:([0-9]*)\\:\\s*\\[(.*)\\]\\s(.*)"; @@ -33,7 +34,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setCategory(matcher.group(3)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/AntJavacParser.java b/src/main/java/edu/hm/hafner/analysis/parser/AntJavacParser.java index b158d2e64..e8c31bab2 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/AntJavacParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/AntJavacParser.java @@ -7,8 +7,9 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; import static edu.hm.hafner.analysis.Categories.*; @@ -17,7 +18,7 @@ * * @author Ullrich Hafner */ -public class AntJavacParser extends RegexpLineParser { +public class AntJavacParser extends LookaheadParser { private static final long serialVersionUID = 1737791073711198075L; private static final String ANT_JAVAC_WARNING_PATTERN = ANT_TASK + "\\s*(.*java):(\\d*):\\s*" @@ -43,7 +44,8 @@ private boolean containsWarningPrefix(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { builder.setSeverity(mapSeverity(matcher.group(3))); if (StringUtils.isNotBlank(matcher.group(8))) { return builder.setFileName(matcher.group(8)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/Armcc5CompilerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/Armcc5CompilerParser.java index defeef157..79b30c705 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/Armcc5CompilerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/Armcc5CompilerParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for armcc5 compiler warnings. * * @author Dmytro Kutianskyi */ -public class Armcc5CompilerParser extends RegexpLineParser { +public class Armcc5CompilerParser extends LookaheadParser { private static final long serialVersionUID = -2677728927938443701L; private static final String ARMCC5_WARNING_PATTERN = "^(.+)\\((\\d+)\\): (warning|error): #(.+): (.+)$"; @@ -31,7 +32,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String type = matcher.group(3); Severity priority; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ArmccCompilerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ArmccCompilerParser.java index 1c7184baa..b57a71b0b 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ArmccCompilerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ArmccCompilerParser.java @@ -5,8 +5,9 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; import static edu.hm.hafner.util.IntegerParser.*; @@ -15,7 +16,7 @@ * * @author Emanuele Zattin */ -public class ArmccCompilerParser extends RegexpLineParser { +public class ArmccCompilerParser extends LookaheadParser { private static final long serialVersionUID = -2677728927938443703L; private static final String ARMCC_WARNING_PATTERN = "^\"(.+)\", line (\\d+): ([A-Z][a-z]+):\\D*(\\d+)\\D*?:\\s+(.+)$"; @@ -28,7 +29,8 @@ public ArmccCompilerParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String type = matcher.group(3); int errorCode = parseInt(matcher.group(4)); Severity priority; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/BuckminsterParser.java b/src/main/java/edu/hm/hafner/analysis/parser/BuckminsterParser.java index 3b7d52942..3092f8ca3 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/BuckminsterParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/BuckminsterParser.java @@ -5,8 +5,9 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; import static edu.hm.hafner.analysis.Categories.*; @@ -15,7 +16,7 @@ * * @author Johannes Utzig */ -public class BuckminsterParser extends RegexpLineParser { +public class BuckminsterParser extends LookaheadParser { private static final long serialVersionUID = -3723799140297979579L; private static final String BUCKMINSTER_WARNING_PATTERN = "^.*(Warning|Error): file (.*?)(, line )?(\\d*): (.*)$"; @@ -28,7 +29,8 @@ public BuckminsterParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { Severity priority = equalsIgnoreCase(matcher.group(1), "Error") ? Severity.WARNING_HIGH : Severity.WARNING_NORMAL; return builder.setFileName(matcher.group(2)).setLineStart(matcher.group(4)) .setCategory(guessCategory(matcher.group(5))).setMessage(matcher.group(5)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/CadenceIncisiveParser.java b/src/main/java/edu/hm/hafner/analysis/parser/CadenceIncisiveParser.java index f9f740ff3..dd227d15e 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/CadenceIncisiveParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/CadenceIncisiveParser.java @@ -12,8 +12,9 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; import static edu.hm.hafner.util.IntegerParser.*; @@ -22,7 +23,7 @@ * * @author Andrew 'Necromant' Andrianov */ -public class CadenceIncisiveParser extends RegexpLineParser { +public class CadenceIncisiveParser extends LookaheadParser { private static final long serialVersionUID = -3251791089328958452L; private static final String SLASH = "/"; @@ -41,7 +42,8 @@ public CadenceIncisiveParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String tool; String type; String category; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ClangParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ClangParser.java index 69d47bfba..35d68f943 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ClangParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ClangParser.java @@ -6,15 +6,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the Clang compiler warnings. * * @author Neil Davis */ -public class ClangParser extends RegexpLineParser { +public class ClangParser extends LookaheadParser { private static final long serialVersionUID = -3015592762345283182L; private static final String CLANG_WARNING_PATTERN = "^\\s*(?:\\d+%)?([^%]*?):(\\d+):(?:(\\d+):)?" + "(?:" @@ -29,7 +30,8 @@ public ClangParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String message = matcher.group(5); if (IGNORE_FORMAT.matcher(message).matches()) { return Optional.empty(); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ClangTidyParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ClangTidyParser.java index 81f7d9cba..b83deee10 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ClangTidyParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ClangTidyParser.java @@ -7,15 +7,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the clang-tidy static analysis warnings. * * @author Ryan Schaefer */ -public class ClangTidyParser extends RegexpLineParser { +public class ClangTidyParser extends LookaheadParser { private static final long serialVersionUID = -3015592762345283182L; private static final String CLANG_TIDY_WARNING_PATTERN = "([^\\s]+):(\\d+):(\\d+): (warning|error): (.*?) \\[([^\\s]*?)\\]$"; @@ -28,7 +29,8 @@ public ClangTidyParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { Severity priority; if (matcher.group(4).contains("error")) { priority = Severity.WARNING_HIGH; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/CodeAnalysisParser.java b/src/main/java/edu/hm/hafner/analysis/parser/CodeAnalysisParser.java index 57b865092..6e0b97d0c 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/CodeAnalysisParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/CodeAnalysisParser.java @@ -7,15 +7,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the CodeAnalysis compiler warnings. * * @author Rafal Jasica */ -public class CodeAnalysisParser extends RegexpLineParser { +public class CodeAnalysisParser extends LookaheadParser { private static final long serialVersionUID = -125874563249851L; private static final String WARNING_PATTERN = ANT_TASK + "((MSBUILD)|((.+)\\((\\d+)\\)))" @@ -31,7 +32,8 @@ public CodeAnalysisParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { if (StringUtils.isNotBlank(matcher.group(2))) { return builder.setFileName(matcher.group(11)) .setLineStart(0) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/CoolfluxChessccParser.java b/src/main/java/edu/hm/hafner/analysis/parser/CoolfluxChessccParser.java index bbecb0dc0..6deb5346e 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/CoolfluxChessccParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/CoolfluxChessccParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the Coolflux DSP Compiler warnings. * * @author Vangelis Livadiotis */ -public class CoolfluxChessccParser extends RegexpLineParser { +public class CoolfluxChessccParser extends LookaheadParser { private static final long serialVersionUID = 4742509996511002391L; private static final String CHESSCC_PATTERN = "^.*?Warning in \"([^\"]+)\", line (\\d+),.*?:\\s*(.*)$"; @@ -31,7 +32,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setMessage(matcher.group(3)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/CppLintParser.java b/src/main/java/edu/hm/hafner/analysis/parser/CppLintParser.java index efdc9793e..4393c096e 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/CppLintParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/CppLintParser.java @@ -5,16 +5,18 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import static edu.hm.hafner.util.IntegerParser.parseInt; +import edu.hm.hafner.util.LookaheadStream; + +import static edu.hm.hafner.util.IntegerParser.*; /** * A parser for C++ Lint compiler warnings. * * @author Ullrich Hafner */ -public class CppLintParser extends RegexpLineParser { +public class CppLintParser extends LookaheadParser { private static final long serialVersionUID = 1737791073711198075L; private static final String PATTERN = "^\\s*(.*)\\s*[(:](\\d+)\\)?:\\s*(.*)\\s*\\[(.*)\\] \\[(.*)\\]$"; @@ -29,7 +31,8 @@ public CppLintParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { Severity priority = mapPriority(matcher.group(5)); return builder.setFileName(matcher.group(1)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/DiabCParser.java b/src/main/java/edu/hm/hafner/analysis/parser/DiabCParser.java index 5768877ef..73c199c15 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/DiabCParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/DiabCParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the Diab C++ compiler warnings. * * @author Yuta Namiki */ -public class DiabCParser extends RegexpLineParser { +public class DiabCParser extends LookaheadParser { private static final long serialVersionUID = -1251248150596418456L; private static final String DIAB_CPP_WARNING_PATTERN = "^\\s*\"(.*)\"\\s*,\\s*line\\s*(\\d+)\\s*:\\s*" @@ -27,7 +28,8 @@ public DiabCParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setCategory(matcher.group(4)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ErlcParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ErlcParser.java index 062599526..15db4e030 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ErlcParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ErlcParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the erlc compiler warnings. * * @author Stefan Brausch */ -public class ErlcParser extends RegexpLineParser { +public class ErlcParser extends LookaheadParser { private static final long serialVersionUID = 8986478184830773892L; private static final String ERLC_WARNING_PATTERN = "^(.+\\.(?:erl|yrl|mib|bin|rel|asn1|idl)):(\\d*): ([wW]arning:" @@ -27,7 +28,8 @@ public ErlcParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { Severity priority; String category; String categoryMatch = matcher.group(3); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/FlawfinderParser.java b/src/main/java/edu/hm/hafner/analysis/parser/FlawfinderParser.java index 4db54eee9..7be982ad5 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/FlawfinderParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/FlawfinderParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the flawfinder warnings. * * @author Dom Postorivo */ -public class FlawfinderParser extends RegexpLineParser { +public class FlawfinderParser extends LookaheadParser { private static final long serialVersionUID = 8088991846076174837L; private static final String FLAWFINDER_WARNING_PATTERN = @@ -30,7 +31,8 @@ public FlawfinderParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String message = matcher.group("message"); String category = matcher.group("category"); int severity = Integer.parseInt(matcher.group("severity")); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/FlexSdkParser.java b/src/main/java/edu/hm/hafner/analysis/parser/FlexSdkParser.java index 749d01e31..453caffb7 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/FlexSdkParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/FlexSdkParser.java @@ -5,14 +5,15 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Flex SDK compiler warnings. * * @author Vivien Tintillier */ -public class FlexSdkParser extends RegexpLineParser { +public class FlexSdkParser extends LookaheadParser { private static final long serialVersionUID = -185055018399324311L; private static final String FLEX_SDK_WARNING_PATTERN = "^\\s*(?:\\[.*\\])?\\s*(.*\\.as|.*\\.mxml)\\((\\d*)\\)" @@ -31,7 +32,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setMessage(matcher.group(3)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/FoodcriticParser.java b/src/main/java/edu/hm/hafner/analysis/parser/FoodcriticParser.java index fb362c747..96f1f86e9 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/FoodcriticParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/FoodcriticParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Foodcritic warnings. * * @author Rich Schumacher */ -public class FoodcriticParser extends RegexpLineParser { +public class FoodcriticParser extends LookaheadParser { private static final long serialVersionUID = -5338881031392241140L; private static final String FOODCRITIC_WARNING_PATTERN = @@ -27,7 +28,8 @@ public FoodcriticParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group("file")) .setLineStart(matcher.group("line")) .setCategory(matcher.group("category")) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/Gcc4LinkerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/Gcc4LinkerParser.java index b45063bb3..c2a81e549 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/Gcc4LinkerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/Gcc4LinkerParser.java @@ -7,15 +7,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for gcc 4.x linker warnings. * * @author Frederic Chateau */ -public class Gcc4LinkerParser extends RegexpLineParser { +public class Gcc4LinkerParser extends LookaheadParser { private static final long serialVersionUID = -2792019431810134790L; /** A GCC error. */ @@ -32,7 +33,8 @@ public Gcc4LinkerParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { Severity priority; String message; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/GccParser.java b/src/main/java/edu/hm/hafner/analysis/parser/GccParser.java index 28ff10b6a..0fe20f706 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/GccParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/GccParser.java @@ -8,15 +8,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the gcc compiler warnings. * * @author Greg Roth */ -public class GccParser extends RegexpLineParser { +public class GccParser extends LookaheadParser { private static final long serialVersionUID = 2020182274225690532L; static final String GCC_ERROR = "GCC error"; @@ -33,7 +34,8 @@ public GccParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { if (StringUtils.isNotBlank(matcher.group(7))) { return builder.setFileName(matcher.group(8)) .setLineStart(0) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/GnatParser.java b/src/main/java/edu/hm/hafner/analysis/parser/GnatParser.java index de71745a7..daace60d9 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/GnatParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/GnatParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the Gnat compiler warnings. * * @author Bernhard Berger */ -public class GnatParser extends RegexpLineParser { +public class GnatParser extends LookaheadParser { private static final long serialVersionUID = -7139298560308123856L; private static final String GNAT_WARNING_PATTERN = "^(.+.(?:ads|adb)):(\\d+):(\\d+): ((?:error:)|(?:warning:)|" @@ -27,7 +28,8 @@ public GnatParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { Severity priority; String category; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/GoLintParser.java b/src/main/java/edu/hm/hafner/analysis/parser/GoLintParser.java index dd350ba64..31c614178 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/GoLintParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/GoLintParser.java @@ -3,17 +3,19 @@ import java.util.Optional; import java.util.regex.Matcher; -import static edu.hm.hafner.analysis.Categories.guessCategory; import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; +import edu.hm.hafner.util.LookaheadStream; + +import static edu.hm.hafner.analysis.Categories.*; /** * A parser for the golint tool in the Go toolchain. * * @author Ryan Cox */ -public class GoLintParser extends RegexpLineParser { +public class GoLintParser extends LookaheadParser { private static final long serialVersionUID = -5895416507693444713L; // conn.go:360:3: should replace c.writeSeq += 1 with c.writeSeq++ @@ -27,7 +29,8 @@ public GoLintParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String message = matcher.group(4); String category = guessCategory(message); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/GoVetParser.java b/src/main/java/edu/hm/hafner/analysis/parser/GoVetParser.java index bf796f172..8652f3c7f 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/GoVetParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/GoVetParser.java @@ -3,17 +3,19 @@ import java.util.Optional; import java.util.regex.Matcher; -import static edu.hm.hafner.analysis.Categories.guessCategory; import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; +import edu.hm.hafner.util.LookaheadStream; + +import static edu.hm.hafner.analysis.Categories.*; /** * A parser for the go vet tool in the Go toolchain. * * @author Ryan Cox */ -public class GoVetParser extends RegexpLineParser { +public class GoVetParser extends LookaheadParser { private static final long serialVersionUID = 1451787851164850844L; // ui_colored_test.go:59: missing argument for Fatalf("%#v"): format reads arg 2, have only 1 args @@ -27,7 +29,8 @@ public GoVetParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setCategory(guessCategory(matcher.group(3))) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/IarCstatParser.java b/src/main/java/edu/hm/hafner/analysis/parser/IarCstatParser.java index 14caff54e..ea2e5144f 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/IarCstatParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/IarCstatParser.java @@ -1,19 +1,20 @@ package edu.hm.hafner.analysis.parser; +import java.util.Optional; +import java.util.regex.Matcher; + import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; - -import java.util.Optional; -import java.util.regex.Matcher; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the IAR CSTAT warnings. * * @author Lorenz Aebi */ -public class IarCstatParser extends RegexpLineParser { +public class IarCstatParser extends LookaheadParser { private static final long serialVersionUID = 7695540852439013425L; private static final String IAR_WARNING_PATTERN = ANT_TASK @@ -32,7 +33,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setSeverity(mapSeverity(matcher.group(3))) .setMessage(normalizeWhitespaceInMessage(matcher.group(5))) .setFileName(matcher.group(1)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/IarParser.java b/src/main/java/edu/hm/hafner/analysis/parser/IarParser.java index c918bcfaa..4941c1776 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/IarParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/IarParser.java @@ -5,8 +5,9 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the IAR C/C++ compiler warnings. Note, that since release 4.1 this parser requires that IAR compilers @@ -16,7 +17,7 @@ * @author Ullrich Hafner * @author Jon Ware */ -public class IarParser extends RegexpLineParser { +public class IarParser extends LookaheadParser { private static final long serialVersionUID = 7695540852439013425L; static final String IAR_WARNING_PATTERN = ANT_TASK @@ -35,7 +36,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setSeverity(mapPriority(matcher)) .setMessage(normalizeWhitespaceInMessage(matcher.group(5))) .setFileName(matcher.group(1)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/IntelParser.java b/src/main/java/edu/hm/hafner/analysis/parser/IntelParser.java index b575bd053..695214e46 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/IntelParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/IntelParser.java @@ -7,15 +7,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for messages from the Intel C and Fortran compilers. * * @author Vangelis Livadiotis */ -public class IntelParser extends RegexpLineParser { +public class IntelParser extends LookaheadParser { private static final long serialVersionUID = 8409744276858003050L; private static final String INTEL_PATTERN = "^(\\d+>)?(.*)\\((\\d*)\\)?:(?:\\s*\\(col\\. (\\d+)\\))?.*(" + "(?:message|remark|warning|error)\\s*#*\\d*)\\s*:\\s*(.*)$"; @@ -33,7 +34,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String category = StringUtils.capitalize(matcher.group(5)); Severity priority; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/InvalidsParser.java b/src/main/java/edu/hm/hafner/analysis/parser/InvalidsParser.java index d0e5ae5df..91bb66275 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/InvalidsParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/InvalidsParser.java @@ -7,15 +7,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Oracle Invalids. * * @author Ullrich Hafner */ -public class InvalidsParser extends RegexpLineParser { +public class InvalidsParser extends LookaheadParser { private static final long serialVersionUID = 440910718005095427L; static final String WARNING_PREFIX = "Oracle "; private static final String INVALIDS_PATTERN = "^\\s*(\\w+),([a-zA-Z#_0-9/]*),([A-Z_ ]*),(.*),(\\d+),\\d+,([^:]*)" @@ -29,7 +30,8 @@ public InvalidsParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String type = WARNING_PREFIX + StringUtils.capitalize(StringUtils.lowerCase(matcher.group(4))); String category = matcher.group(6); Severity priority; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/JavaDocParser.java b/src/main/java/edu/hm/hafner/analysis/parser/JavaDocParser.java index 22c2c1b4d..79061a10f 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/JavaDocParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/JavaDocParser.java @@ -8,15 +8,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the ant JavaDoc compiler warnings. * * @author Ullrich Hafner */ -public class JavaDocParser extends RegexpLineParser { +public class JavaDocParser extends LookaheadParser { private static final long serialVersionUID = 7127568148333474921L; private static final String JAVA_DOC_WARNING_PATTERN = "(?:\\s*\\[(?:javadoc|WARNING|ERROR)\\]\\s*)?(?:(?:(?:Exit" + " code: \\d* - )?(.*):(\\d+))|(?:\\s*javadoc\\s*)):\\s*(warning|error)\\s*[-:]\\s*(.*)"; @@ -41,7 +42,8 @@ private boolean hasErrorPrefixAndErrorInMessage(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String type = matcher.group(3); String message = matcher.group(4); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/MetrowerksCwCompilerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/MetrowerksCwCompilerParser.java index 4c288c332..c8672dec9 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/MetrowerksCwCompilerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/MetrowerksCwCompilerParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Metrowerks Codewarrior 4.x compiler warnings. * * @author Sven Lübke */ -public class MetrowerksCwCompilerParser extends RegexpLineParser { +public class MetrowerksCwCompilerParser extends LookaheadParser { private static final long serialVersionUID = 4317595592384426180L; /** Pattern of MW CodeWarrior compiler warnings. */ @@ -28,7 +29,8 @@ public MetrowerksCwCompilerParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { Severity priority; String category; @@ -44,7 +46,7 @@ else if (equalsIgnoreCase(matcher.group(3), "information")) { priority = Severity.WARNING_NORMAL; category = "Warning"; } - + return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setCategory(category) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/MetrowerksCwLinkerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/MetrowerksCwLinkerParser.java index a7f9eeb83..e76b95403 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/MetrowerksCwLinkerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/MetrowerksCwLinkerParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Metrowerks Codewarrior 4.x linker warnings. * * @author Sven Lübke */ -public class MetrowerksCwLinkerParser extends RegexpLineParser { +public class MetrowerksCwLinkerParser extends LookaheadParser { private static final long serialVersionUID = 5993528761040876178L; /** Pattern of MW CodeWarrior linker warnings. */ @@ -27,7 +28,8 @@ public MetrowerksCwLinkerParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String message = matcher.group(2); String messageCategory = matcher.group(1); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/MsBuildParser.java b/src/main/java/edu/hm/hafner/analysis/parser/MsBuildParser.java index ae79bd789..9a4d35433 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/MsBuildParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/MsBuildParser.java @@ -8,15 +8,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the MSBuild/PcLint compiler warnings. * * @author Ullrich Hafner */ -public class MsBuildParser extends RegexpLineParser { +public class MsBuildParser extends LookaheadParser { private static final long serialVersionUID = -2141974437420906595L; private static final String MS_BUILD_WARNING_PATTERN @@ -34,7 +35,8 @@ public MsBuildParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { builder.setFileName(determineFileName(matcher)); if (StringUtils.isNotBlank(matcher.group(2))) { diff --git a/src/main/java/edu/hm/hafner/analysis/parser/P4Parser.java b/src/main/java/edu/hm/hafner/analysis/parser/P4Parser.java index 05a9b544b..a298dcbcf 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/P4Parser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/P4Parser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Perforce execution. * * @author Adrian Deccico */ -public class P4Parser extends RegexpLineParser { +public class P4Parser extends LookaheadParser { private static final long serialVersionUID = -8106854254745366432L; private static final String ALREADY_OPENED = "already opened for edit"; @@ -35,7 +36,8 @@ public P4Parser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String category = matcher.group(2).trim(); Severity p = mapPriority(category); return builder.setFileName(matcher.group(1).trim()).setLineStart(0).setCategory(category).setMessage( diff --git a/src/main/java/edu/hm/hafner/analysis/parser/Pep8Parser.java b/src/main/java/edu/hm/hafner/analysis/parser/Pep8Parser.java index 8017574d9..a8450697e 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/Pep8Parser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/Pep8Parser.java @@ -5,8 +5,9 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; import static edu.hm.hafner.analysis.Categories.*; @@ -16,7 +17,7 @@ * * @author Marvin Schütz */ -public class Pep8Parser extends RegexpLineParser { +public class Pep8Parser extends LookaheadParser { private static final long serialVersionUID = -8444940209330966997L; private static final String PEP8_WARNING_PATTERN = "(.*):(\\d+):(\\d+): (\\D\\d*) (.*)"; @@ -29,7 +30,8 @@ public Pep8Parser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String message = matcher.group(5); String category = guessCategoryIfEmpty(matcher.group(4), message); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/PerlCriticParser.java b/src/main/java/edu/hm/hafner/analysis/parser/PerlCriticParser.java index 1f3b827bc..a1d178049 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/PerlCriticParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/PerlCriticParser.java @@ -5,16 +5,18 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import static edu.hm.hafner.util.IntegerParser.parseInt; +import edu.hm.hafner.util.LookaheadStream; + +import static edu.hm.hafner.util.IntegerParser.*; /** * A parser for the Perl::Critic warnings. * * @author Mihail Menev, menev@hm.edu */ -public class PerlCriticParser extends RegexpLineParser { +public class PerlCriticParser extends LookaheadParser { private static final long serialVersionUID = -6481203155449490873L; private static final String PERLCRITIC_WARNING_PATTERN = "(?:(.*?):)?(.*)\\s+at\\s+line\\s+(\\d+),\\s+column\\s+" @@ -30,7 +32,8 @@ public PerlCriticParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String filename; if (matcher.group(1) == null) { filename = "-"; @@ -67,4 +70,4 @@ else if (priority < SEVERITY_NORMAL_LIMIT) { return Severity.WARNING_HIGH; } } -} \ No newline at end of file +} diff --git a/src/main/java/edu/hm/hafner/analysis/parser/PhpParser.java b/src/main/java/edu/hm/hafner/analysis/parser/PhpParser.java index 7710d20c7..04bf1a8fb 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/PhpParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/PhpParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for PHP runtime errors and warnings. * * @author Shimi Kiviti */ -public class PhpParser extends RegexpLineParser { +public class PhpParser extends LookaheadParser { private static final long serialVersionUID = -5154327854315791181L; private static final String PHP_WARNING_PATTERN = "^.*(PHP Warning|PHP Notice|PHP Fatal error|PHP Parse error)" @@ -32,7 +33,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String category = matcher.group(1); builder.setCategory(category).setSeverity(mapPriority(category)); @@ -56,4 +58,4 @@ private Severity mapPriority(final String category) { } return Severity.WARNING_NORMAL; } -} \ No newline at end of file +} diff --git a/src/main/java/edu/hm/hafner/analysis/parser/PreFastParser.java b/src/main/java/edu/hm/hafner/analysis/parser/PreFastParser.java index d96a85492..a4d94787a 100755 --- a/src/main/java/edu/hm/hafner/analysis/parser/PreFastParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/PreFastParser.java @@ -5,7 +5,8 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Microsoft PREfast (aka Code Analysis for C/C++) XML files. @@ -13,7 +14,7 @@ * @author Charles Chan * @see */ -public class PreFastParser extends RegexpLineParser { +public class PreFastParser extends LookaheadParser { private static final long serialVersionUID = 1409381677034028504L; /* @@ -66,11 +67,12 @@ public PreFastParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setCategory(matcher.group(3)) .setMessage(matcher.group(4)) .buildOptional(); } -} \ No newline at end of file +} diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ProtoLintParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ProtoLintParser.java index bcc672dba..821803cc1 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ProtoLintParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ProtoLintParser.java @@ -5,8 +5,9 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * Parser for ProtoLint. @@ -14,7 +15,7 @@ * @author David Hart * @see https://github.com/yoheimuta/protolint */ -public class ProtoLintParser extends RegexpLineParser { +public class ProtoLintParser extends LookaheadParser { private static final long serialVersionUID = -8347619672754062010L; private static final String PROTO_LINT_PATTERN = "^\\[(?[^:]+):(?\\d+):(?\\d+)\\] (?.+)$"; @@ -27,7 +28,8 @@ public ProtoLintParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group("file")) .setLineStart(matcher.group("line")) .setColumnStart(matcher.group("column")) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/PuppetLintParser.java b/src/main/java/edu/hm/hafner/analysis/parser/PuppetLintParser.java index 6429dacf4..276c232ea 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/PuppetLintParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/PuppetLintParser.java @@ -8,15 +8,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for puppet-lint checks warnings. * * @author Jan Vansteenkiste */ -public class PuppetLintParser extends RegexpLineParser { +public class PuppetLintParser extends LookaheadParser { private static final long serialVersionUID = 7492869677427430346L; private static final String SEPARATOR = "::"; @@ -33,7 +34,8 @@ public PuppetLintParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setCategory(matcher.group(3)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/PyLintParser.java b/src/main/java/edu/hm/hafner/analysis/parser/PyLintParser.java index 32022f1e2..13b0cf0d9 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/PyLintParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/PyLintParser.java @@ -7,15 +7,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the PyLint compiler warnings. * * @author Björn Pedersen */ -public class PyLintParser extends RegexpLineParser { +public class PyLintParser extends LookaheadParser { private static final long serialVersionUID = 4464053085862883240L; // the default pattern matches "--output-format=parseable" output. @@ -37,7 +38,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String category = matcher.group("category"); builder.setSeverity(mapPriority(category)); builder.setCategory(mapCategory(category)); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/QacSourceCodeAnalyserParser.java b/src/main/java/edu/hm/hafner/analysis/parser/QacSourceCodeAnalyserParser.java index ea0008eca..1eb04815d 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/QacSourceCodeAnalyserParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/QacSourceCodeAnalyserParser.java @@ -5,16 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; - +import edu.hm.hafner.util.LookaheadStream; /** * A parser for PRQA QA-C Sourcecode Analyser warnings. * * @author Sven Lübke */ -public class QacSourceCodeAnalyserParser extends RegexpLineParser { +public class QacSourceCodeAnalyserParser extends LookaheadParser { private static final long serialVersionUID = -8104046102312005968L; /** Pattern of QA-C Sourcecode Analyser warnings. */ @@ -28,7 +28,8 @@ public QacSourceCodeAnalyserParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { Severity priority; String category; if (equalsIgnoreCase(matcher.group(4), "err")) { diff --git a/src/main/java/edu/hm/hafner/analysis/parser/RobocopyParser.java b/src/main/java/edu/hm/hafner/analysis/parser/RobocopyParser.java index a21abe44b..c72bddc79 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/RobocopyParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/RobocopyParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for Robocopy. * * @author Adrian Deccico */ -public class RobocopyParser extends RegexpLineParser { +public class RobocopyParser extends LookaheadParser { private static final long serialVersionUID = -671744745118772873L; private static final String ROBOCOPY_WARNING_PATTERN = "^(.*)(EXTRA File|New File|same)\\s*(\\d*)\\s*(.*)$"; @@ -26,7 +27,8 @@ public RobocopyParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String file = matcher.group(4).split("\\s{11}", -1)[0]; return builder.setFileName(file) .setLineStart(0) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/RuboCopParser.java b/src/main/java/edu/hm/hafner/analysis/parser/RuboCopParser.java index d4fc2b4fa..5a1bbeb5f 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/RuboCopParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/RuboCopParser.java @@ -3,18 +3,20 @@ import java.util.Optional; import java.util.regex.Matcher; -import static edu.hm.hafner.analysis.Categories.guessCategoryIfEmpty; import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; + +import static edu.hm.hafner.analysis.Categories.*; /** * A parser for the ruboCop warnings. * * @author David van Laatum */ -public class RuboCopParser extends RegexpLineParser { +public class RuboCopParser extends LookaheadParser { private static final long serialVersionUID = 7199325311690082783L; private static final String RUBOCOP_WARNING_PATTERN = @@ -30,7 +32,8 @@ public RuboCopParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String message = matcher.group("message"); String category = guessCategoryIfEmpty(matcher.group("category"), message); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/SbtScalacParser.java b/src/main/java/edu/hm/hafner/analysis/parser/SbtScalacParser.java index 16f21512d..5c1240388 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/SbtScalacParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/SbtScalacParser.java @@ -5,18 +5,19 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the sbt scala compiler warnings. You should use -feature and -deprecation compiler opts. * * @author Hochak Hung */ -public class SbtScalacParser extends RegexpLineParser { +public class SbtScalacParser extends LookaheadParser { private static final long serialVersionUID = -4233964844965517977L; - private static final String SBT_WARNING_PATTERN = "^(\\[warn\\]|\\[error\\](?!\\s+Total\\stime:))\\s*(.*?):(\\d+)(?::\\d+)?:\\s*(.*)$"; + private static final String SBT_WARNING_PATTERN = "^(\\[warn\\]|\\[error\\](?!\\s+Total\\stime:))\\s*(.*?):(\\d+)(?::\\d+)?:\\s*(.*)$"; /** * Creates a new instance of {@link SbtScalacParser}. @@ -26,7 +27,8 @@ public SbtScalacParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(2)) .setLineStart(matcher.group(3)) .setMessage(matcher.group(4)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/ScalacParser.java b/src/main/java/edu/hm/hafner/analysis/parser/ScalacParser.java index 09717aa02..b7a3ad8e6 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/ScalacParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/ScalacParser.java @@ -5,16 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; - +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the scalac compiler warnings. You should use -feature and -deprecation compiler opts. * * @author Alexey Kislin */ -public class ScalacParser extends RegexpLineParser { +public class ScalacParser extends LookaheadParser { private static final long serialVersionUID = -4034552404001800574L; private static final String SCALAC_WARNING_PATTERN = "^(\\[WARNING\\]|\\[ERROR\\])\\s*(.*):(\\d+):\\s*([a-z]*)" @@ -28,7 +28,8 @@ public ScalacParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(2)) .setLineStart(matcher.group(3)) .setCategory(matcher.group(4)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/SphinxBuildParser.java b/src/main/java/edu/hm/hafner/analysis/parser/SphinxBuildParser.java index 94297d3cf..eaabf869e 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/SphinxBuildParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/SphinxBuildParser.java @@ -5,8 +5,9 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; import static edu.hm.hafner.analysis.Categories.*; @@ -15,7 +16,7 @@ * * @author Robert Williams */ -public class SphinxBuildParser extends RegexpLineParser { +public class SphinxBuildParser extends LookaheadParser { private static final long serialVersionUID = 1483050615340274588L; private static final String SPHINX_BUILD_WARNING_PATTERN = "^([a-zA-Z]:\\\\.*?|/.*?|[^\\/].*?):(?:.* of .*:)?(\\d+|None|): (ERROR|WARNING): (.*)"; @@ -28,7 +29,8 @@ public SphinxBuildParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String message = matcher.group(4); String category = guessCategoryIfEmpty(matcher.group(3), message); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/SunCParser.java b/src/main/java/edu/hm/hafner/analysis/parser/SunCParser.java index 29d03e615..aa1f375e8 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/SunCParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/SunCParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the SUN Studio C++ compiler warnings. * * @author Ullrich Hafner */ -public class SunCParser extends RegexpLineParser { +public class SunCParser extends LookaheadParser { private static final long serialVersionUID = -1251248150596418456L; private static final String SUN_CPP_WARNING_PATTERN = "^\\s*\"(.*)\"\\s*,\\s*line\\s*(\\d+)\\s*:\\s*" @@ -27,7 +28,8 @@ public SunCParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(1)) .setLineStart(matcher.group(2)) .setCategory(matcher.group(4)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/TaskingVxCompilerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/TaskingVxCompilerParser.java index 1164650f3..9bbcf9af6 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/TaskingVxCompilerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/TaskingVxCompilerParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for TASKING VX compiler warnings. * * @author Sven Lübke */ -public class TaskingVxCompilerParser extends RegexpLineParser { +public class TaskingVxCompilerParser extends LookaheadParser { private static final long serialVersionUID = -5225265084645449716L; /** Pattern of TASKING VX compiler warnings. */ @@ -28,7 +29,8 @@ public TaskingVxCompilerParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String type = matcher.group(1); Severity priority; String category; diff --git a/src/main/java/edu/hm/hafner/analysis/parser/TiCcsParser.java b/src/main/java/edu/hm/hafner/analysis/parser/TiCcsParser.java index 196c692dd..f5d141abc 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/TiCcsParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/TiCcsParser.java @@ -7,15 +7,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the Texas Instruments Code Composer Studio compiler warnings. * * @author Jan Linnenkohl */ -public class TiCcsParser extends RegexpLineParser { +public class TiCcsParser extends LookaheadParser { private static final long serialVersionUID = -8253481365175984661L; private static final String TI_CCS_WARNING_PATTERN = "^((\"(.*)\",\\s*)(line\\s*(\\d+)(\\s*\\(.*\\))?:)?\\s*)?" @@ -29,7 +30,8 @@ public TiCcsParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String lineNumber = matcher.group(5); if (StringUtils.isBlank(lineNumber)) { lineNumber = matcher.group(10); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/TnsdlParser.java b/src/main/java/edu/hm/hafner/analysis/parser/TnsdlParser.java index 48e9fa47b..9954f26de 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/TnsdlParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/TnsdlParser.java @@ -5,15 +5,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for the tnsdl translator warnings. * * @author Shaohua Wen */ -public class TnsdlParser extends RegexpLineParser { +public class TnsdlParser extends LookaheadParser { private static final long serialVersionUID = -7740789998865369930L; private static final String TNSDL_WARNING_PATTERN = "^tnsdl((.*)?):\\(.*\\) (.*) \\((.*)\\):(.*)$"; @@ -31,7 +32,8 @@ protected boolean isLineInteresting(final String line) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { return builder.setFileName(matcher.group(3)) .setLineStart(matcher.group(4)) .setMessage(matcher.group(5)) diff --git a/src/main/java/edu/hm/hafner/analysis/parser/XlcCompilerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/XlcCompilerParser.java index c3dcc676e..a9a0f78aa 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/XlcCompilerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/XlcCompilerParser.java @@ -6,15 +6,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for IBM xlC compiler warnings. * * @author Andrew Gvozdev */ -public class XlcCompilerParser extends RegexpLineParser { +public class XlcCompilerParser extends LookaheadParser { private static final long serialVersionUID = 5490211629355204910L; private static final String XLC_WARNING_PATTERN = ANT_TASK + ".*((?:[A-Z]+|[0-9]+-)[0-9]+)* ?\\([USEWI]\\)\\s*(" @@ -49,7 +50,8 @@ private Severity toPriority(final String severity) { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String line = matcher.group(0); Matcher lineMatcher = PATTERN_WITH_LINE.matcher(line); diff --git a/src/main/java/edu/hm/hafner/analysis/parser/XlcLinkerParser.java b/src/main/java/edu/hm/hafner/analysis/parser/XlcLinkerParser.java index 7e872b739..19fc154ec 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/XlcLinkerParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/XlcLinkerParser.java @@ -6,15 +6,16 @@ import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.IssueBuilder; +import edu.hm.hafner.analysis.LookaheadParser; import edu.hm.hafner.analysis.Severity; -import edu.hm.hafner.analysis.RegexpLineParser; +import edu.hm.hafner.util.LookaheadStream; /** * A parser for IBM xlC linker warnings. * * @author Andrew Gvozdev */ -public class XlcLinkerParser extends RegexpLineParser { +public class XlcLinkerParser extends LookaheadParser { private static final long serialVersionUID = 211259620936831096L; private static final String XLC_LINKER_WARNING_PATTERN = ANT_TASK + "ld: ([0-9]+-[0-9]+)*\\s*(.*)$"; @@ -37,7 +38,8 @@ public XlcLinkerParser() { } @Override - protected Optional createIssue(final Matcher matcher, final IssueBuilder builder) { + protected Optional createIssue(final Matcher matcher, final LookaheadStream lookahead, + final IssueBuilder builder) { String line = matcher.group(0); builder.setFileName("").setLineStart(0);