Search in sources :

Example 1 with ForwardingAstVisitor

use of lombok.ast.ForwardingAstVisitor in project android-priority-jobqueue by yigit.

the class NotifyOnObjectDetector method createJavaVisitor.

@Override
public AstVisitor createJavaVisitor(@NonNull final JavaContext context) {
    return new ForwardingAstVisitor() {

        @Override
        public boolean visitMethodInvocation(MethodInvocation node) {
            Expression operand = node.astOperand();
            String methodName = node.astName().toString();
            if (BAD_METHODS.contains(methodName) && !context.isSuppressedWithComment(node, ISSUE)) {
                context.report(ISSUE, context.getLocation(node), "Don't call " + methodName + " directly. Use" + " Timer instead.");
            }
            return super.visitMethodInvocation(node);
        }
    };
}
Also used : ForwardingAstVisitor(lombok.ast.ForwardingAstVisitor) Expression(lombok.ast.Expression) MethodInvocation(lombok.ast.MethodInvocation)

Example 2 with ForwardingAstVisitor

use of lombok.ast.ForwardingAstVisitor in project android-priority-jobqueue by yigit.

the class SystemTimeDetector method createJavaVisitor.

@Override
public AstVisitor createJavaVisitor(@NonNull final JavaContext context) {
    return new ForwardingAstVisitor() {

        @Override
        public boolean visitMethodInvocation(MethodInvocation node) {
            Expression operand = node.astOperand();
            String methodName = node.astName().toString();
            if (BAD_METHODS.contains(methodName) && operand.toString().equals("System") && !context.isSuppressedWithComment(node, ISSUE)) {
                context.report(ISSUE, context.getLocation(node), "Don't call " + methodName + " on system. Use" + " Timer instead.");
            }
            return super.visitMethodInvocation(node);
        }
    };
}
Also used : ForwardingAstVisitor(lombok.ast.ForwardingAstVisitor) Expression(lombok.ast.Expression) MethodInvocation(lombok.ast.MethodInvocation)

Aggregations

Expression (lombok.ast.Expression)2 ForwardingAstVisitor (lombok.ast.ForwardingAstVisitor)2 MethodInvocation (lombok.ast.MethodInvocation)2