Search in sources :

Example 26 with JavaEvaluator

use of com.android.tools.klint.client.api.JavaEvaluator in project kotlin by JetBrains.

the class PreferenceActivityDetector method checkClass.

@Override
public void checkClass(@NonNull JavaContext context, @NonNull UClass declaration) {
    if (!context.getProject().getReportIssues()) {
        return;
    }
    JavaEvaluator evaluator = context.getEvaluator();
    String className = declaration.getQualifiedName();
    if (InheritanceUtil.isInheritor(declaration, false, PREFERENCE_ACTIVITY) && mExportedActivities.containsKey(className)) {
        // valid fragments.
        if (context.getMainProject().getTargetSdk() >= 19 && overridesIsValidFragment(evaluator, declaration)) {
            return;
        }
        String message = String.format("`PreferenceActivity` subclass `%1$s` should not be exported", className);
        Location location = mExportedActivities.get(className).resolve();
        context.reportUast(ISSUE, declaration, location, message);
    }
}
Also used : JavaEvaluator(com.android.tools.klint.client.api.JavaEvaluator) Location(com.android.tools.klint.detector.api.Location)

Aggregations

JavaEvaluator (com.android.tools.klint.client.api.JavaEvaluator)26 PsiMethod (com.intellij.psi.PsiMethod)9 Location (com.android.tools.klint.detector.api.Location)7 UExpression (org.jetbrains.uast.UExpression)7 PsiClass (com.intellij.psi.PsiClass)3 PsiClassType (com.intellij.psi.PsiClassType)2 PsiElement (com.intellij.psi.PsiElement)2 PsiType (com.intellij.psi.PsiType)2 Nullable (com.android.annotations.Nullable)1 PsiAnnotation (com.intellij.psi.PsiAnnotation)1 PsiAnonymousClass (com.intellij.psi.PsiAnonymousClass)1 PsiField (com.intellij.psi.PsiField)1 UAnonymousClass (org.jetbrains.uast.UAnonymousClass)1 UElement (org.jetbrains.uast.UElement)1