Package io.codemodder
Class SarifPluginJavaParserChanger<T extends com.github.javaparser.ast.Node>
java.lang.Object
io.codemodder.javaparser.JavaParserChanger
io.codemodder.SarifPluginJavaParserChanger<T>
- All Implemented Interfaces:
CodeChanger
public abstract class SarifPluginJavaParserChanger<T extends com.github.javaparser.ast.Node>
extends JavaParserChanger
Provides base functionality for making JavaParser-based changes based on results found by a sarif
file.
-
Field Summary
FieldsFields inherited from class io.codemodder.javaparser.JavaParserChanger
reporter -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType) protectedSarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, CodemodReporterStrategy codemodReporterStrategy) protectedSarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, RegionNodeMatcher regionNodeMatcher) protectedSarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, RegionNodeMatcher regionNodeMatcher, CodemodReporterStrategy reporterStrategy) protectedSarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, SourceCodeRegionExtractor<com.contrastsecurity.sarif.Result> regionExtractor) protectedSarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, SourceCodeRegionExtractor<com.contrastsecurity.sarif.Result> regionExtractor, RegionNodeMatcher regionNodeMatcher) protectedSarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, SourceCodeRegionExtractor<com.contrastsecurity.sarif.Result> regionExtractor, RegionNodeMatcher regionNodeMatcher, CodemodReporterStrategy reporter) -
Method Summary
Modifier and TypeMethodDescriptionabstract ChangesResultonResultFound(CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, T node, com.contrastsecurity.sarif.Result result) Creates a visitor for the given context and locations.booleanA lifecycle event that is called before any files are processed.booleanA predicate which dictates if the file should be inspected by the codemod.visit(CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu) Called when a Java file, which has already been parsed into a compilation unit, is seen.Methods inherited from class io.codemodder.javaparser.JavaParserChanger
getDescription, getIncludesExcludesPattern, getIndividualChangeDescription, getReferences, getSummary
-
Field Details
-
sarif
-
-
Constructor Details
-
SarifPluginJavaParserChanger
-
SarifPluginJavaParserChanger
protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, SourceCodeRegionExtractor<com.contrastsecurity.sarif.Result> regionExtractor) -
SarifPluginJavaParserChanger
protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, CodemodReporterStrategy codemodReporterStrategy) -
SarifPluginJavaParserChanger
protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, RegionNodeMatcher regionNodeMatcher) -
SarifPluginJavaParserChanger
protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, RegionNodeMatcher regionNodeMatcher, CodemodReporterStrategy reporterStrategy) -
SarifPluginJavaParserChanger
protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, SourceCodeRegionExtractor<com.contrastsecurity.sarif.Result> regionExtractor, RegionNodeMatcher regionNodeMatcher) -
SarifPluginJavaParserChanger
protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, SourceCodeRegionExtractor<com.contrastsecurity.sarif.Result> regionExtractor, RegionNodeMatcher regionNodeMatcher, CodemodReporterStrategy reporter)
-
-
Method Details
-
supports
Description copied from interface:CodeChangerA predicate which dictates if the file should be inspected by the codemod. This cannot be overridden and should always pass before executing the codemod.- Specified by:
supportsin interfaceCodeChanger- Overrides:
supportsin classJavaParserChanger
-
visit
public CodemodFileScanningResult visit(CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu) Description copied from class:JavaParserChangerCalled when a Java file, which has already been parsed into a compilation unit, is seen.- Specified by:
visitin classJavaParserChanger
-
shouldRun
public boolean shouldRun()Description copied from interface:CodeChangerA lifecycle event that is called before any files are processed. This is a good place to short circuit if you don't have the necessary resources (e.g., SARIF). -
onResultFound
public abstract ChangesResult onResultFound(CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, T node, com.contrastsecurity.sarif.Result result) Creates a visitor for the given context and locations.- Parameters:
context- the context of this files transformationcu- the parsed model of the file being transformednode- the node to act onresult- the given SARIF result to act on- Returns:
ChangesResult, that contains result changes
-