Search in sources :

Example 1 with FieldNode

use of org.jetbrains.org.objectweb.asm.tree.FieldNode in project kotlin by JetBrains.

the class LintDriver method isSuppressed.

// Unfortunately, ASMs nodes do not extend a common DOM node type with parent
// pointers, so we have to have multiple methods which pass in each type
// of node (class, method, field) to be checked.
/**
     * Returns whether the given issue is suppressed in the given method.
     *
     * @param issue the issue to be checked, or null to just check for "all"
     * @param classNode the class containing the issue
     * @param method the method containing the issue
     * @param instruction the instruction within the method, if any
     * @return true if there is a suppress annotation covering the specific
     *         issue on this method
     */
public boolean isSuppressed(@Nullable Issue issue, @NonNull ClassNode classNode, @NonNull MethodNode method, @Nullable AbstractInsnNode instruction) {
    if (method.invisibleAnnotations != null) {
        @SuppressWarnings("unchecked") List<AnnotationNode> annotations = method.invisibleAnnotations;
        return isSuppressed(issue, annotations);
    }
    // for members and <clinit> for static fields).
    if (instruction != null && method.name.charAt(0) == '<') {
        AbstractInsnNode next = LintUtils.getNextInstruction(instruction);
        if (next != null && next.getType() == AbstractInsnNode.FIELD_INSN) {
            FieldInsnNode fieldRef = (FieldInsnNode) next;
            FieldNode field = findField(classNode, fieldRef.owner, fieldRef.name);
            if (field != null && isSuppressed(issue, field)) {
                return true;
            }
        } else if (classNode.outerClass != null && classNode.outerMethod == null && isAnonymousClass(classNode)) {
            if (isSuppressed(issue, classNode)) {
                return true;
            }
        }
    }
    return false;
}
Also used : FieldNode(org.jetbrains.org.objectweb.asm.tree.FieldNode) AnnotationNode(org.jetbrains.org.objectweb.asm.tree.AnnotationNode) FieldInsnNode(org.jetbrains.org.objectweb.asm.tree.FieldInsnNode) AbstractInsnNode(org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode)

Aggregations

AbstractInsnNode (org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode)1 AnnotationNode (org.jetbrains.org.objectweb.asm.tree.AnnotationNode)1 FieldInsnNode (org.jetbrains.org.objectweb.asm.tree.FieldInsnNode)1 FieldNode (org.jetbrains.org.objectweb.asm.tree.FieldNode)1