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()
JavaFileScannerContext
getTree
in interface JavaFileScannerContext
public void addIssueOnFile(JavaCheck javaCheck, String message)
JavaFileScannerContext
addIssueOnFile
in interface JavaFileScannerContext
javaCheck
- The check raising the issue.message
- Message to display to the userpublic void addIssue(int line, JavaCheck javaCheck, String message)
JavaFileScannerContext
addIssue
in interface JavaFileScannerContext
line
- 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)
JavaFileScannerContext
addIssue
in interface JavaFileScannerContext
line
- 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()
JavaFileScannerContext
getSemanticModel
in interface JavaFileScannerContext
public JavaVersion getJavaVersion()
JavaFileScannerContext
getJavaVersion
in interface JavaFileScannerContext
public boolean fileParsed()
JavaFileScannerContext
fileParsed
in interface JavaFileScannerContext
public String getFileKey()
JavaFileScannerContext
getFileKey
in interface JavaFileScannerContext
public void addIssue(File file, JavaCheck check, int line, String message)
JavaFileScannerContext
addIssue
in interface JavaFileScannerContext
file
- 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)
JavaFileScannerContext
reportIssue
in interface JavaFileScannerContext
javaCheck
- 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)
JavaFileScannerContext
reportIssue
in interface JavaFileScannerContext
javaCheck
- 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)
JavaFileScannerContext
reportIssueWithFlow
in interface JavaFileScannerContext
javaCheck
- 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)
JavaFileScannerContext
reportIssue
in interface JavaFileScannerContext
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.public void reportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> secondary, @Nullable Integer cost)
JavaFileScannerContext
reportIssue
in interface JavaFileScannerContext
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.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()
JavaFileScannerContext
getFileLines
in interface JavaFileScannerContext
public String getFileContent()
JavaFileScannerContext
getFileContent
in interface JavaFileScannerContext
protected 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()
JavaFileScannerContext
getFile
in interface JavaFileScannerContext
public List<Tree> getComplexityNodes(Tree tree)
JavaFileScannerContext
getComplexityNodes
in interface JavaFileScannerContext
tree
- the tree to compute the complexity.public List<Tree> getMethodComplexityNodes(ClassTree enclosingClass, MethodTree methodTree)
JavaFileScannerContext
getMethodComplexityNodes
in interface JavaFileScannerContext
enclosingClass
- not used.methodTree
- the methodTree to compute the complexity.Copyright © 2012–2017 SonarSource. All rights reserved.