Search in sources :

Example 1 with KotlinUSimpleReferenceExpression

use of org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression in project Signal-Android by WhisperSystems.

the class SignalLogDetector method visitMethodCall.

@Override
public void visitMethodCall(JavaContext context, @NotNull UCallExpression call, @NotNull PsiMethod method) {
    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isMemberInClass(method, "android.util.Log")) {
        LintFix fix = quickFixIssueLog(call);
        context.report(LOG_NOT_SIGNAL, call, context.getLocation(call), "Using 'android.util.Log' instead of a Signal Logger", fix);
    }
    if (evaluator.isMemberInClass(method, "org.signal.glide.Log")) {
        LintFix fix = quickFixIssueLog(call);
        context.report(LOG_NOT_SIGNAL, call, context.getLocation(call), "Using 'org.signal.glide.Log' instead of a Signal Logger", fix);
    }
    if (evaluator.isMemberInClass(method, "org.whispersystems.libsignal.logging.Log")) {
        LintFix fix = quickFixIssueLog(call);
        context.report(LOG_NOT_APP, call, context.getLocation(call), "Using Signal server logger instead of app level Logger", fix);
    }
    if (evaluator.isMemberInClass(method, "org.signal.core.util.logging.Log")) {
        List<UExpression> arguments = call.getValueArguments();
        UExpression tag = arguments.get(0);
        if (!(tag instanceof JavaUSimpleNameReferenceExpression || tag instanceof KotlinUSimpleReferenceExpression || tag instanceof KotlinUQualifiedReferenceExpression)) {
            context.report(INLINE_TAG, call, context.getLocation(call), "Not using a tag constant");
        }
    }
}
Also used : UExpression(org.jetbrains.uast.UExpression) KotlinUQualifiedReferenceExpression(org.jetbrains.uast.kotlin.KotlinUQualifiedReferenceExpression) LintFix(com.android.tools.lint.detector.api.LintFix) KotlinUSimpleReferenceExpression(org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression) JavaUSimpleNameReferenceExpression(org.jetbrains.uast.java.JavaUSimpleNameReferenceExpression) JavaEvaluator(com.android.tools.lint.client.api.JavaEvaluator)

Example 2 with KotlinUSimpleReferenceExpression

use of org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression in project Signal-Android by signalapp.

the class SignalLogDetector method visitMethodCall.

@Override
public void visitMethodCall(JavaContext context, @NotNull UCallExpression call, @NotNull PsiMethod method) {
    JavaEvaluator evaluator = context.getEvaluator();
    if (evaluator.isMemberInClass(method, "android.util.Log")) {
        LintFix fix = quickFixIssueLog(call);
        context.report(LOG_NOT_SIGNAL, call, context.getLocation(call), "Using 'android.util.Log' instead of a Signal Logger", fix);
    }
    if (evaluator.isMemberInClass(method, "org.signal.glide.Log")) {
        LintFix fix = quickFixIssueLog(call);
        context.report(LOG_NOT_SIGNAL, call, context.getLocation(call), "Using 'org.signal.glide.Log' instead of a Signal Logger", fix);
    }
    if (evaluator.isMemberInClass(method, "org.whispersystems.libsignal.logging.Log")) {
        LintFix fix = quickFixIssueLog(call);
        context.report(LOG_NOT_APP, call, context.getLocation(call), "Using Signal server logger instead of app level Logger", fix);
    }
    if (evaluator.isMemberInClass(method, "org.signal.core.util.logging.Log")) {
        List<UExpression> arguments = call.getValueArguments();
        UExpression tag = arguments.get(0);
        if (!(tag instanceof JavaUSimpleNameReferenceExpression || tag instanceof KotlinUSimpleReferenceExpression || tag instanceof KotlinUQualifiedReferenceExpression)) {
            context.report(INLINE_TAG, call, context.getLocation(call), "Not using a tag constant");
        }
    }
}
Also used : UExpression(org.jetbrains.uast.UExpression) KotlinUQualifiedReferenceExpression(org.jetbrains.uast.kotlin.KotlinUQualifiedReferenceExpression) LintFix(com.android.tools.lint.detector.api.LintFix) KotlinUSimpleReferenceExpression(org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression) JavaUSimpleNameReferenceExpression(org.jetbrains.uast.java.JavaUSimpleNameReferenceExpression) JavaEvaluator(com.android.tools.lint.client.api.JavaEvaluator)

Aggregations

JavaEvaluator (com.android.tools.lint.client.api.JavaEvaluator)2 LintFix (com.android.tools.lint.detector.api.LintFix)2 UExpression (org.jetbrains.uast.UExpression)2 JavaUSimpleNameReferenceExpression (org.jetbrains.uast.java.JavaUSimpleNameReferenceExpression)2 KotlinUQualifiedReferenceExpression (org.jetbrains.uast.kotlin.KotlinUQualifiedReferenceExpression)2 KotlinUSimpleReferenceExpression (org.jetbrains.uast.kotlin.KotlinUSimpleReferenceExpression)2