use of lombok.ast.MethodDeclaration in project kotlin by JetBrains.
the class LintDriver method isSuppressed.
/**
* Returns whether the given issue is suppressed in the given parse tree node.
*
* @param context the context for the source being scanned
* @param issue the issue to be checked, or null to just check for "all"
* @param scope the AST node containing the issue
* @return true if there is a suppress annotation covering the specific
* issue in this class
*/
public boolean isSuppressed(@Nullable JavaContext context, @NonNull Issue issue, @Nullable Node scope) {
boolean checkComments = mClient.checkForSuppressComments() && context != null && context.containsCommentSuppress();
while (scope != null) {
Class<? extends Node> type = scope.getClass();
// so no need to do instanceof stuff here.
if (type == VariableDefinition.class) {
// Variable
VariableDefinition declaration = (VariableDefinition) scope;
if (isSuppressed(issue, declaration.astModifiers())) {
return true;
}
} else if (type == MethodDeclaration.class) {
// Method
// Look for annotations on the method
MethodDeclaration declaration = (MethodDeclaration) scope;
if (isSuppressed(issue, declaration.astModifiers())) {
return true;
}
} else if (type == ConstructorDeclaration.class) {
// Constructor
// Look for annotations on the method
ConstructorDeclaration declaration = (ConstructorDeclaration) scope;
if (isSuppressed(issue, declaration.astModifiers())) {
return true;
}
} else if (TypeDeclaration.class.isAssignableFrom(type)) {
// Class, annotation, enum, interface
TypeDeclaration declaration = (TypeDeclaration) scope;
if (isSuppressed(issue, declaration.astModifiers())) {
return true;
}
} else if (type == AnnotationMethodDeclaration.class) {
// Look for annotations on the method
AnnotationMethodDeclaration declaration = (AnnotationMethodDeclaration) scope;
if (isSuppressed(issue, declaration.astModifiers())) {
return true;
}
}
if (checkComments && context.isSuppressedWithComment(scope, issue)) {
return true;
}
scope = scope.getParent();
}
return false;
}
Aggregations