Search in sources :

Example 1 with PsiArrayInitializerMemberValue

use of com.intellij.psi.PsiArrayInitializerMemberValue in project kotlin by JetBrains.

the class LintDriver method isSuppressed.

/**
     * Returns true if the annotation member value, assumed to be specified on a a SuppressWarnings
     * or SuppressLint annotation, specifies the given id (or "all").
     *
     * @param issue the issue to be checked
     * @param value     the member value to check
     * @return true if the issue or all issues should be suppressed for this modifier
     */
public static boolean isSuppressed(@NonNull Issue issue, @Nullable PsiAnnotationMemberValue value) {
    if (value instanceof PsiLiteral) {
        PsiLiteral literal = (PsiLiteral) value;
        Object literalValue = literal.getValue();
        if (literalValue instanceof String) {
            if (isSuppressed(issue, (String) literalValue)) {
                return true;
            }
        }
    } else if (value instanceof PsiArrayInitializerMemberValue) {
        PsiArrayInitializerMemberValue mv = (PsiArrayInitializerMemberValue) value;
        for (PsiAnnotationMemberValue mmv : mv.getInitializers()) {
            if (isSuppressed(issue, mmv)) {
                return true;
            }
        }
    } else if (value instanceof PsiArrayInitializerExpression) {
        PsiArrayInitializerExpression expression = (PsiArrayInitializerExpression) value;
        PsiExpression[] initializers = expression.getInitializers();
        for (PsiExpression e : initializers) {
            if (isSuppressed(issue, e)) {
                return true;
            }
        }
    }
    return false;
}
Also used : PsiArrayInitializerMemberValue(com.intellij.psi.PsiArrayInitializerMemberValue) PsiExpression(com.intellij.psi.PsiExpression) PsiLiteral(com.intellij.psi.PsiLiteral) PsiArrayInitializerExpression(com.intellij.psi.PsiArrayInitializerExpression) PsiAnnotationMemberValue(com.intellij.psi.PsiAnnotationMemberValue)

Aggregations

PsiAnnotationMemberValue (com.intellij.psi.PsiAnnotationMemberValue)1 PsiArrayInitializerExpression (com.intellij.psi.PsiArrayInitializerExpression)1 PsiArrayInitializerMemberValue (com.intellij.psi.PsiArrayInitializerMemberValue)1 PsiExpression (com.intellij.psi.PsiExpression)1 PsiLiteral (com.intellij.psi.PsiLiteral)1