java.lang.Object
edu.hm.hafner.analysis.IssueParser
edu.hm.hafner.analysis.LookaheadParser
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractMavenLogParser,AcuCobolParser,AnsibleLintParser,Armcc5CompilerParser,ArmccCompilerParser,BluePearlParser,BuckminsterParser,CadenceIncisiveParser,CargoClippyParser,ClangParser,ClangTidyParser,CMakeParser,CodeAnalysisParser,CodeCheckerParser,CodeGeneratorParser,CoolfluxChessccParser,CppLintParser,CrossCoreEmbeddedStudioParser,DiabCParser,DrMemoryParser,EclipseMavenParser,EclipseParser,ErlcParser,ErrorProneParser,FlawfinderParser,FlexSdkParser,FoodcriticParser,Gcc4CompilerParser,Gcc4LinkerParser,GccParser,GhsMultiParser,GnatParser,GnuFortranParser,GoLintParser,GoVetParser,GradleErrorProneParser,IarCstatParser,IarParser,IntelParser,InvalidsParser,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
Parses a report file line by line for issues using a pre-defined regular expression. If the regular expression
matches then the abstract method
createIssue(Matcher, LookaheadStream, IssueBuilder) will be called. Sub
classes need to provide an implementation that transforms the Matcher instance 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringPattern identifying an ant task debug output prefix.Fields inherited from class edu.hm.hafner.analysis.IssueParser
ADDITIONAL_PROPERTIES, CATEGORY, COLUMN_END, COLUMN_START, DESCRIPTION, FILE_NAME, FINGERPRINT, ID, LINE_END, LINE_RANGE_END, LINE_RANGE_START, LINE_RANGES, LINE_START, MESSAGE, MODULE_NAME, ORIGIN, PACKAGE_NAME, SEVERITY, TYPE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLookaheadParser(String pattern) Creates a new instance ofLookaheadParser. -
Method Summary
Modifier and TypeMethodDescriptioncreateIssue(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.parse(ReaderFactory readerFactory) Parses the specified file for issues.protected ReportpostProcess(Report report) Post processes the issues.protected voidpreprocessLine(String line) Preprocesses the specified line.Methods inherited from class edu.hm.hafner.analysis.IssueParser
accepts, equalsIgnoreCase, isXmlFile, parseFile
-
Field Details
-
ANT_TASK
Pattern identifying an ant task debug output prefix.- See Also:
-
-
Constructor Details
-
LookaheadParser
Creates a new instance ofLookaheadParser.- Parameters:
pattern- pattern of compiler warnings.
-
-
Method Details
-
parse
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
-
preprocessLine
Preprocesses the specified line. This method is called before the line is checked for a match. Subclasses may override this empty default implementation.- Parameters:
line- the line to preprocess
-
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
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.
-
postProcess
Post processes the issues. This default implementation does nothing.- Parameters:
report- the issues after the parsing process- Returns:
- the post processed issues
-