Class IssuableSubscriptionVisitor
java.lang.Object
org.sonar.java.ast.visitors.SubscriptionVisitor
org.sonar.plugins.java.api.IssuableSubscriptionVisitor
- All Implemented Interfaces:
JavaCheck, JavaFileScanner
Subscription visitor providing an API to report issues.
-
Field Summary
Fields inherited from class SubscriptionVisitor
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidReport an issue on a specific line.voidaddIssueOnFile(String message) Report an issue at file level.voidleaveFile(JavaFileScannerContext context) Override this method only if you need to execute some instructions after the end of the analysis of a file.voidreportIssue(Tree tree, String message) Report an issue.voidreportIssue(Tree tree, String message, List<JavaFileScannerContext.Location> flow, Integer cost) Report an issue.voidreportIssue(Tree startTree, Tree endTree, String message) Report an issue.voidreportIssue(Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> flow, Integer cost) Report an issue.final voidscanFile(JavaFileScannerContext context) Deprecated.protected final voidDeprecated.UseleaveFile(JavaFileScannerContext)orsetContext(JavaFileScannerContext)instead.voidsetContext(JavaFileScannerContext context) Override this method only if you need to execute some instructions prior to start the analysis of a file.Methods inherited from class SubscriptionVisitor
leaveNode, nodesToVisit, visitNode, visitToken, visitTriviaModifier and TypeMethodDescriptionvoidvoidvoidvisitToken(SyntaxToken syntaxToken) voidvisitTrivia(SyntaxTrivia syntaxTrivia) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface JavaFileScanner
scanWithoutParsingModifier and TypeMethodDescriptiondefault booleanscanWithoutParsing(InputFileScannerContext inputFileScannerContext) Scan based on the raw file and cached data (ie: No tree is available at this stage).
-
Constructor Details
-
IssuableSubscriptionVisitor
public IssuableSubscriptionVisitor()
-
-
Method Details
-
setContext
Override this method only if you need to execute some instructions prior to start the analysis of a file. Don't forget to callsuper.setContext()`.- Overrides:
setContextin classSubscriptionVisitor- Parameters:
context- the analysis context.
-
scanTree
Deprecated.UseleaveFile(JavaFileScannerContext)orsetContext(JavaFileScannerContext)instead.This method is never called and should not be called. It is inherited from theSubscriptionVisitor. Implementations ofIssuableSubscriptionVisitorare not able to pilot the exploration of the AST.- Overrides:
scanTreein classSubscriptionVisitor
-
scanFile
@Deprecated(since="7.31", forRemoval=false) public final void scanFile(JavaFileScannerContext context) Deprecated.UseleaveFile(JavaFileScannerContext)orsetContext(JavaFileScannerContext)instead.This method is never called and should not be called. It is inherited from theSubscriptionVisitor. Implementations ofIssuableSubscriptionVisitorare not able to impact visit of a file.- Specified by:
scanFilein interfaceJavaFileScanner- Overrides:
scanFilein classSubscriptionVisitor- Parameters:
context- Context of analysis containing the parsed tree.
-
leaveFile
Override this method only if you need to execute some instructions after the end of the analysis of a file.- Overrides:
leaveFilein classSubscriptionVisitor- Parameters:
context- the analysis context.
-
addIssue
Report an issue on a specific line.- Parameters:
line- line on which to report the issuemessage- Message to display to the user
-
addIssueOnFile
Report an issue at file level.- Parameters:
message- Message to display to the user
-
reportIssue
-
reportIssue
public void reportIssue(Tree tree, String message, List<JavaFileScannerContext.Location> flow, @Nullable Integer cost) Report an issue.- Parameters:
tree- syntax node on which to raise the issue.message- Message to display to the user.flow- List ofJavaFileScannerContext.Locationto display secondary locations describing the flow leading to the issue. Empty list if the issue does not requires secondary location.cost- computed remediation cost if applicable, null if not.
-
reportIssue
-
reportIssue
public void reportIssue(Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> flow, @Nullable Integer cost) Report an issue.- Parameters:
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.flow- List ofJavaFileScannerContext.Locationto display secondary locations describing the flow leading to the issue. Empty list if the issue does not requires secondary location.cost- computed remediation cost if applicable, null if not.
-
leaveFile(JavaFileScannerContext)orsetContext(JavaFileScannerContext)instead.