Package org.sonar.plugins.java.api
Interface JavaFileScannerContext
- All Superinterfaces:
InputFileScannerContext
,ModuleScannerContext
- All Known Implementing Classes:
DefaultJavaFileScannerContext
,JavaFileScannerContextForTests
Context injected in check classes and used to report issues.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Message and syntaxNode for a secondary location. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if file has been parsed correctly.getComplexityNodes
(Tree tree) Computes the list of syntax nodes which are contributing to increase the complexity for the given methodTree.Content of the currently analyzed file.Lines of the currently analyzed file.Get semantic analysis.getTree()
Parsed tree of the current file.void
reportIssue
(JavaCheck javaCheck, Tree tree, String message) Report an issue.void
reportIssue
(JavaCheck javaCheck, Tree tree, String message, List<JavaFileScannerContext.Location> secondaryLocations, Integer cost) Report an issue.void
reportIssue
(JavaCheck javaCheck, Tree startTree, Tree endTree, String message) Report an issue.void
reportIssue
(JavaCheck javaCheck, Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> secondaryLocations, Integer cost) Report an issue.void
reportIssueWithFlow
(JavaCheck javaCheck, Tree tree, String message, Iterable<List<JavaFileScannerContext.Location>> flows, Integer cost) Report an issue.Return JSR 45 source map for current input fileMethods inherited from interface org.sonar.plugins.java.api.InputFileScannerContext
addIssue, addIssue, addIssueOnFile, getInputFile
Methods inherited from interface org.sonar.plugins.java.api.ModuleScannerContext
addIssueOnProject, getCacheContext, getJavaVersion, getModuleKey, getProject, getRootProjectWorkingDirectory, getWorkingDirectory, inAndroidContext, sonarProduct
-
Method Details
-
getTree
CompilationUnitTree getTree()Parsed tree of the current file.- Returns:
- CompilationUnitTree ready for scan by checks.
-
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
-
reportIssue
-
reportIssue
void reportIssue(JavaCheck javaCheck, Tree tree, String message, List<JavaFileScannerContext.Location> secondaryLocations, @Nullable Integer cost) Report an issue.- Parameters:
javaCheck
- check raising the issuetree
- syntax node on which to raise the issue.message
- Message to display to the user.secondaryLocations
- List ofJavaFileScannerContext.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 issuetree
- syntax node on which to raise the issue.message
- Message to display to the user.flows
- List of list ofJavaFileScannerContext.Location
to display flows for the issue.cost
- computed remediation cost if applicable, null if not.
-
reportIssue
Report an issue.- Parameters:
javaCheck
- check raising the issuestartTree
- 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 issuestartTree
- 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 ofJavaFileScannerContext.Location
to display secondary location for the issue.cost
- computed remediation cost if applicable, null if not.
-
getFileLines
-
getFileContent
String getFileContent()Content of the currently analyzed file.- Returns:
- the file content as a String.
-
sourceMap
-