Package edu.hm.hafner.analysis
Class LookaheadParser
- java.lang.Object
-
- edu.hm.hafner.analysis.IssueParser
-
- edu.hm.hafner.analysis.LookaheadParser
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AcuCobolParser,AnsibleLintParser,AntJavacParser,Armcc5CompilerParser,ArmccCompilerParser,BuckminsterParser,CadenceIncisiveParser,ClangParser,ClangTidyParser,CMakeParser,CodeAnalysisParser,CodeCheckerParser,CoolfluxChessccParser,CppLintParser,DiabCParser,DrMemoryParser,EclipseMavenParser,EclipseParser,ErlcParser,ErrorProneParser,FlawfinderParser,FlexSdkParser,FoodcriticParser,Gcc4CompilerParser,Gcc4LinkerParser,GccParser,GhsMultiParser,GnatParser,GnuFortranParser,GoLintParser,GoVetParser,GradleErrorProneParser,IarCstatParser,IarParser,IntelParser,InvalidsParser,JavacParser,JavaDocParser,MavenConsoleParser,MentorParser,MetrowerksCwCompilerParser,MetrowerksCwLinkerParser,MsBuildParser,NagFortranParser,OELintAdvParser,P4Parser,Pep8Parser,PerlCriticParser,PhpParser,PreFastParser,ProtoLintParser,PuppetLintParser,PyLintParser,QacSourceCodeAnalyserParser,RobocopyParser,RuboCopParser,SbtScalacParser,ScalacParser,SphinxBuildLinkCheckParser,SphinxBuildParser,SunCParser,TaskingVxCompilerParser,TiCcsParser,TnsdlParser,XlcCompilerParser,XlcLinkerParser,YuiCompressorParser
public abstract class LookaheadParser extends IssueParser
Parses a report file line by line for issues using a pre-defined regular expression. If the regular expression matches then the abstract methodcreateIssue(Matcher, LookaheadStream, IssueBuilder)will be called. Sub classes need to provide an implementation that transforms theMatcherinstance into a new issue. If required, sub classes may consume additional lines from the report file before control is handed back to the template method of this parser.- Author:
- Ullrich Hafner
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLookaheadParser(String pattern)Creates a new instance ofLookaheadParser.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Optional<Issue>createIssue(Matcher matcher, edu.hm.hafner.util.LookaheadStream lookahead, IssueBuilder builder)Creates a new issue for the specified pattern.protected booleanisLineInteresting(String line)Returns whether the specified line is interesting.Reportparse(ReaderFactory readerFactory)Parses the specified file for issues.protected ReportpostProcess(Report report)Post processes the issues.-
Methods inherited from class edu.hm.hafner.analysis.IssueParser
accepts, equalsIgnoreCase, isXmlFile, parseFile
-
-
-
-
Field Detail
-
ANT_TASK
protected static final String ANT_TASK
Pattern identifying an ant task debug output prefix.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LookaheadParser
protected LookaheadParser(String pattern)
Creates a new instance ofLookaheadParser.- Parameters:
pattern- pattern of compiler warnings.
-
-
Method Detail
-
parse
public Report parse(ReaderFactory readerFactory) throws ParsingException, ParsingCanceledException
Description copied from class:IssueParserParses the specified file for issues.- Specified by:
parsein classIssueParser- Parameters:
readerFactory- provides a reader to the reports- Returns:
- the issues
- Throws:
ParsingException- Signals that during parsing a non recoverable error has been occurredParsingCanceledException- Signals that the parsing has been aborted by the user
-
createIssue
protected abstract Optional<Issue> createIssue(Matcher matcher, edu.hm.hafner.util.LookaheadStream lookahead, IssueBuilder builder) throws ParsingException
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 returnOptional.empty()to ignore this warning.- Parameters:
matcher- the regular expression matcherlookahead- the lookahead stream to read additional linesbuilder- the issue builder to use- Returns:
- a new annotation for the specified pattern
- Throws:
ParsingException- Signals that during parsing a non recoverable error has been occurred
-
isLineInteresting
protected boolean isLineInteresting(String line)
Returns whether the specified line is interesting. Each interesting line will be matched by the defined regular expression. Here a parser can implement some fast checks (i.e. string or character comparisons) in order to see if a required condition is met. This default implementation does always returntrue.- Parameters:
line- the line to inspect- Returns:
trueif the line should be handed over to the regular expression scanner,falseif the line does not contain a warning.
-
-