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 classMessage and syntaxNode for a secondary location. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks 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.voidreportIssue(JavaCheck javaCheck, Tree tree, String message) Report an issue.voidreportIssue(JavaCheck javaCheck, Tree tree, String message, List<JavaFileScannerContext.Location> secondaryLocations, Integer cost) Report an issue.voidreportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message) Report an issue.voidreportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> secondaryLocations, Integer cost) Report an issue.voidreportIssueWithFlow(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 InputFileScannerContext
addIssue, addIssue, addIssueOnFile, getInputFileModifier and TypeMethodDescriptionvoidReport an issue on a specific line.voidReport an issue on a specific line.voidaddIssueOnFile(JavaCheck check, String message) Report an issue at file level.org.sonar.api.batch.fs.InputFileInputFile under analysis.Methods inherited from interface ModuleScannerContext
addIssueOnProject, getCacheContext, getConfiguration, getFullyQualifiedModuleKey, getJavaVersion, getModuleKey, getProject, getRootProjectWorkingDirectory, getWorkingDirectory, inAndroidContext, sonarProductModifier and TypeMethodDescriptionvoidaddIssueOnProject(JavaCheck check, String message) Report an issue at the project level.org.sonar.api.config.ConfigurationJava version defined for the analysis usingsonar.java.versionparameter.org.sonar.api.batch.fs.InputComponentInputComponentrepresenting the project being analyzedDeprecated.booleanTo be used to know if the current file is in an android context or not.org.sonar.api.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.Locationto 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.Locationto 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.Locationto 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
-
ModuleScannerContext.getRootProjectWorkingDirectory()instead