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 Details

  • Constructor Details

    • SarifPluginJavaParserChanger

      protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType)
    • SarifPluginJavaParserChanger

      protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, RegionExtractor 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, RegionExtractor regionExtractor, RegionNodeMatcher regionNodeMatcher)
    • SarifPluginJavaParserChanger

      protected SarifPluginJavaParserChanger(RuleSarif sarif, Class<? extends com.github.javaparser.ast.Node> nodeType, RegionExtractor regionExtractor, RegionNodeMatcher regionNodeMatcher, CodemodReporterStrategy reporter)
  • Method Details

    • visit

      public List<CodemodChange> visit(CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu)
      Description copied from class: JavaParserChanger
      Called when a Java file, which has already been parsed into a compilation unit, is seen.
      Specified by:
      visit in class JavaParserChanger
    • shouldRun

      public boolean shouldRun()
      Description copied from interface: CodeChanger
      A 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 boolean 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 transformation
      cu - the parsed model of the file being transformed
      node - the node to act on
      result - the given SARIF result to act on
      Returns:
      true, if the change was made, false otherwise