public class DefaultJavaFileScannerContext extends Object implements JavaFileScannerContext
JavaFileScannerContext.Location| Constructor and Description |
|---|
DefaultJavaFileScannerContext(CompilationUnitTree tree,
File file,
SemanticModel semanticModel,
SonarComponents sonarComponents,
JavaVersion javaVersion,
boolean fileParsed) |
| Modifier and Type | Method and Description |
|---|---|
void |
addIssue(File file,
JavaCheck check,
int line,
String message)
Report an issue at a specific line of a given file.
|
void |
addIssue(int line,
JavaCheck javaCheck,
String message)
Report an issue on a specific line.
|
void |
addIssue(int line,
JavaCheck javaCheck,
String message,
Integer cost)
Report an issue on a specific line.
|
void |
addIssueOnFile(JavaCheck javaCheck,
String message)
Report an issue at file level.
|
protected static AnalyzerMessage |
createAnalyzerMessage(File file,
JavaCheck javaCheck,
Tree startTree,
Tree endTree,
String message,
Iterable<List<JavaFileScannerContext.Location>> flows,
Integer cost) |
boolean |
fileParsed()
Checks if file has been parsed correctly.
|
List<Tree> |
getComplexityNodes(Tree tree)
Computes the list of syntax nodes which are contributing to increase the complexity for the given methodTree.
|
File |
getFile()
File under analysis.
|
String |
getFileContent()
Content of the currently analyzed file.
|
String |
getFileKey()
FileKey of currently analyzed file.
|
List<String> |
getFileLines()
Lines of the currently analyzed file.
|
JavaVersion |
getJavaVersion()
Java version defined for the analysis using sonar.java.version parameter.
|
List<Tree> |
getMethodComplexityNodes(ClassTree enclosingClass,
MethodTree methodTree)
Computes the list of syntax nodes which are contributing to increase the complexity for the given methodTree.
|
Object |
getSemanticModel()
Get semantic analysis.
|
CompilationUnitTree |
getTree()
Parsed tree of the current file.
|
void |
reportIssue(JavaCheck javaCheck,
Tree tree,
String message)
Report an issue.
|
void |
reportIssue(JavaCheck javaCheck,
Tree syntaxNode,
String message,
List<JavaFileScannerContext.Location> secondary,
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> secondary,
Integer cost)
Report an issue.
|
void |
reportIssueWithFlow(JavaCheck javaCheck,
Tree syntaxNode,
String message,
Iterable<List<JavaFileScannerContext.Location>> flows,
Integer cost)
Report an issue.
|
public DefaultJavaFileScannerContext(CompilationUnitTree tree, File file, SemanticModel semanticModel, @Nullable SonarComponents sonarComponents, JavaVersion javaVersion, boolean fileParsed)
public CompilationUnitTree getTree()
JavaFileScannerContextgetTree in interface JavaFileScannerContextpublic void addIssueOnFile(JavaCheck javaCheck, String message)
JavaFileScannerContextaddIssueOnFile in interface JavaFileScannerContextjavaCheck - The check raising the issue.message - Message to display to the userpublic void addIssue(int line,
JavaCheck javaCheck,
String message)
JavaFileScannerContextaddIssue in interface JavaFileScannerContextline - line on which to report the issuejavaCheck - The check raising the issue.message - Message to display to the userJavaFileScannerContext#reportIssue(JavaCheck, Tree, String)} which should be prefered as reporting will be more precise.public void addIssue(int line,
JavaCheck javaCheck,
String message,
@Nullable
Integer cost)
JavaFileScannerContextaddIssue in interface JavaFileScannerContextline - line on which to report the issuejavaCheck - The check raising the issue.message - Message to display to the usercost - computed remediation cost if applicable, null if not.JavaFileScannerContext#reportIssue(JavaCheck, Tree, String, List, Integer)} which should be prefered as reporting will be more precise.@Nullable public Object getSemanticModel()
JavaFileScannerContextgetSemanticModel in interface JavaFileScannerContextpublic JavaVersion getJavaVersion()
JavaFileScannerContextgetJavaVersion in interface JavaFileScannerContextpublic boolean fileParsed()
JavaFileScannerContextfileParsed in interface JavaFileScannerContextpublic String getFileKey()
JavaFileScannerContextgetFileKey in interface JavaFileScannerContextpublic void addIssue(File file, JavaCheck check, int line, String message)
JavaFileScannerContextaddIssue in interface JavaFileScannerContextfile - File on which to reportcheck - The check raising the issue.line - line on which to report the issuemessage - Message to display to the userpublic void reportIssue(JavaCheck javaCheck, Tree tree, String message)
JavaFileScannerContextreportIssue in interface JavaFileScannerContextjavaCheck - check raising the issuetree - syntax node on which to raise the issue.message - Message to display to the user.public void reportIssue(JavaCheck javaCheck, Tree syntaxNode, String message, List<JavaFileScannerContext.Location> secondary, @Nullable Integer cost)
JavaFileScannerContextreportIssue in interface JavaFileScannerContextjavaCheck - check raising the issuesyntaxNode - syntax node on which to raise the issue.message - Message to display to the user.secondary - List of JavaFileScannerContext.Location to display secondary location for the issue.cost - computed remediation cost if applicable, null if not.public void reportIssueWithFlow(JavaCheck javaCheck, Tree syntaxNode, String message, Iterable<List<JavaFileScannerContext.Location>> flows, @Nullable Integer cost)
JavaFileScannerContextreportIssueWithFlow in interface JavaFileScannerContextjavaCheck - check raising the issuesyntaxNode - 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.public void reportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message)
JavaFileScannerContextreportIssue in interface JavaFileScannerContextjavaCheck - 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.public void reportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> secondary, @Nullable Integer cost)
JavaFileScannerContextreportIssue in interface JavaFileScannerContextjavaCheck - 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.secondary - List of JavaFileScannerContext.Location to display secondary location for the issue.cost - computed remediation cost if applicable, null if not.public List<String> getFileLines()
JavaFileScannerContextgetFileLines in interface JavaFileScannerContextpublic String getFileContent()
JavaFileScannerContextgetFileContent in interface JavaFileScannerContextprotected static AnalyzerMessage createAnalyzerMessage(File file, JavaCheck javaCheck, Tree startTree, @Nullable Tree endTree, String message, Iterable<List<JavaFileScannerContext.Location>> flows, @Nullable Integer cost)
public File getFile()
JavaFileScannerContextgetFile in interface JavaFileScannerContextpublic List<Tree> getComplexityNodes(Tree tree)
JavaFileScannerContextgetComplexityNodes in interface JavaFileScannerContexttree - the tree to compute the complexity.public List<Tree> getMethodComplexityNodes(ClassTree enclosingClass, MethodTree methodTree)
JavaFileScannerContextgetMethodComplexityNodes in interface JavaFileScannerContextenclosingClass - not used.methodTree - the methodTree to compute the complexity.Copyright © 2012–2017 SonarSource. All rights reserved.