Interface JavaFileScannerContext

All Superinterfaces:
InputFileScannerContext, ModuleScannerContext
All Known Implementing Classes:
DefaultJavaFileScannerContext, JavaFileScannerContextForTests

@Beta public interface JavaFileScannerContext extends InputFileScannerContext
Context injected in check classes and used to report issues.
  • Method Details

    • getTree

      Parsed tree of the current file.
      Returns:
      CompilationUnitTree ready for scan by checks.
    • getSemanticModel

      @Nullable Object getSemanticModel()
      Get semantic analysis.
      Returns:
      SemanticModel if semantic analysis was successful, null otherwise.
    • fileParsed

      boolean fileParsed()
      Checks if file has been parsed correctly.
      Returns:
      true if parsing was successful
    • getComplexityNodes

      List<Tree> getComplexityNodes(Tree tree)
      Computes the list of syntax nodes which are contributing to increase the complexity for the given methodTree.
      Parameters:
      tree - the tree to compute the complexity.
      Returns:
      the list of syntax nodes incrementing the complexity.
    • reportIssue

      void reportIssue(JavaCheck javaCheck, Tree tree, String message)
      Report an issue.
      Parameters:
      javaCheck - check raising the issue
      tree - syntax node on which to raise the issue.
      message - Message to display to the user.
    • reportIssue

      void reportIssue(JavaCheck javaCheck, Tree tree, String message, List<JavaFileScannerContext.Location> secondaryLocations, @Nullable Integer cost)
      Report an issue.
      Parameters:
      javaCheck - check raising the issue
      tree - syntax node on which to raise the issue.
      message - Message to display to the user.
      secondaryLocations - List of JavaFileScannerContext.Location to display secondary location for the issue.
      cost - computed remediation cost if applicable, null if not.
    • reportIssueWithFlow

      void reportIssueWithFlow(JavaCheck javaCheck, Tree tree, String message, Iterable<List<JavaFileScannerContext.Location>> flows, @Nullable Integer cost)
      Report an issue.
      Parameters:
      javaCheck - check raising the issue
      tree - syntax node on which to raise the issue.
      message - Message to display to the user.
      flows - List of list of JavaFileScannerContext.Location to display flows for the issue.
      cost - computed remediation cost if applicable, null if not.
    • reportIssue

      void reportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message)
      Report an issue.
      Parameters:
      javaCheck - check raising the issue
      startTree - syntax node on which to start the highlighting of the issue.
      endTree - syntax node on which to end the highlighting of the issue.
      message - Message to display to the user.
    • reportIssue

      void reportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> secondaryLocations, @Nullable Integer cost)
      Report an issue.
      Parameters:
      javaCheck - check raising the issue
      startTree - syntax node on which to start the highlighting of the issue.
      endTree - syntax node on which to end the highlighting of the issue.
      message - Message to display to the user.
      secondaryLocations - List of JavaFileScannerContext.Location to display secondary location for the issue.
      cost - computed remediation cost if applicable, null if not.
    • getFileLines

      List<String> getFileLines()
      Lines of the currently analyzed file.
      Returns:
      list of file lines.
    • getFileContent

      String getFileContent()
      Content of the currently analyzed file.
      Returns:
      the file content as a String.
    • sourceMap

      default Optional<SourceMap> sourceMap()
      Return JSR 45 source map for current input file
      Returns:
      source map if available