@Override public boolean visitMethodInvocation(MethodInvocation node) { Expression operand = node.astOperand(); if (node.astName().toString().equals("sleep") && operand.toString().equals("Thread") && !context.isSuppressedWithComment(node, ISSUE)) { context.report(ISSUE, node, context.getLocation(node), "Don't call sleep. Use MockTimer instead."); } return super.visitMethodInvocation(node); } };
@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); } };
@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); } };
@Override public boolean visitMethodInvocation(MethodInvocation node) { Expression operand = node.astOperand(); if (node.astName().toString().equals("wait") && !context.isSuppressedWithComment(node, ISSUE)) { context.report(ISSUE, context.getLocation(node), "Don't wait on object. Use Timer's wait instead."); } return super.visitMethodInvocation(node); } };
@Override public boolean visitMethodInvocation(MethodInvocation node) { ... String name = node.astName().astValue(); boolean isCommit = "commit".equals(name); if (isCommit || "apply".equals(name)) { ... if (returnValueIgnored) { String message = "Consider using apply() instead; commit writes " + "its data to persistent storage immediately, whereas " + "apply will handle it in the background"; mContext.report(ISSUE, node, mContext.getLocation(node), message, null); }
@Override public boolean visitMethodInvocation(MethodInvocation node) { if (node == mTarget) { mDone = true; } String name = node.astName().astValue(); if ((name.startsWith("check") || name.startsWith("enforce")) && name.endsWith("Permission")) { mChecksPermission = true; mDone = true; } return super.visitMethodInvocation(node); }
private static boolean isTransactionCommitMethodCall(@NonNull MethodInvocation call) { String methodName = call.astName().astValue(); return COMMIT.equals(methodName) || GET_INTENT.equals(methodName); }
@Override public boolean visitMethodInvocation(MethodInvocation node) { if (node == mTarget) { mSeenTarget = true; } else if ((mSeenTarget || node.astOperand() == mTarget) && "show".equals(node.astName().astValue())) { //$NON-NLS-1$ // TODO: Do more flow analysis to see whether we're really calling show // on the right type of object? mFound = true; } return true; }
@CopyMethod static String getDescription(MethodInvocation self) { return self.astName().astValue(); } }
@CopyMethod static String getDescription(MethodInvocation self) { return self.astName().astValue(); } }
@CopyMethod static String getDescription(MethodInvocation self) { return self.astName().astValue(); } }
private static boolean isTransactionCommitMethodCall(@NonNull JavaContext context, @NonNull MethodInvocation call) { String methodName = call.astName().astValue(); return (COMMIT.equals(methodName) || COMMIT_ALLOWING_LOSS.equals(methodName)) && isMethodOnFragmentClass(context, call, FRAGMENT_TRANSACTION_CLS, FRAGMENT_TRANSACTION_V4_CLS); }
private static boolean isShowFragmentMethodCall(@NonNull JavaContext context, @NonNull MethodInvocation call) { String methodName = call.astName().astValue(); return SHOW.equals(methodName) && isMethodOnFragmentClass(context, call, DIALOG_FRAGMENT, DIALOG_V4_FRAGMENT); }
@Override public boolean visitMethodInvocation(MethodInvocation node) { if (mVisitMethods) { String methodName = node.astName().astValue(); List<VisitingDetector> list = mMethodDetectors.get(methodName); if (list != null) { for (VisitingDetector v : list) { v.getJavaScanner().visitMethod(mContext, v.getVisitor(), node); } } } return super.visitMethodInvocation(node); }
@Override public void visitMessageSend(MessageSend node) { lombok.ast.MethodInvocation inv = new lombok.ast.MethodInvocation(); fillList(node.arguments, inv.rawArguments()); fillList(node.typeArguments, inv.rawMethodTypeArguments()); inv.astOperand(((lombok.ast.Expression) toTree(node.receiver))); inv.astName(toIdentifier(node.selector, node.nameSourcePosition)); setPosition(node, inv); set(node, inv); }
@Override public void visitMessageSend(MessageSend node) { lombok.ast.MethodInvocation inv = new lombok.ast.MethodInvocation(); fillList(node.arguments, inv.rawArguments()); fillList(node.typeArguments, inv.rawMethodTypeArguments()); inv.astOperand(((lombok.ast.Expression) toTree(node.receiver))); inv.astName(toIdentifier(node.selector, node.nameSourcePosition)); setPosition(node, inv); set(node, inv); }
@Override public void visitMessageSend(MessageSend node) { lombok.ast.MethodInvocation inv = new lombok.ast.MethodInvocation(); fillList(node.arguments, inv.rawArguments()); fillList(node.typeArguments, inv.rawMethodTypeArguments()); inv.astOperand(((lombok.ast.Expression) toTree(node.receiver))); inv.astName(toIdentifier(node.selector, node.nameSourcePosition)); setPosition(node, inv); set(node, inv); }
@Override public void visitMethod(@NonNull JavaContext context, @Nullable AstVisitor visitor, @NonNull MethodInvocation node) { String name = node.astName().astValue(); if (BEGIN_TRANSACTION.equals(name)) { checkTransactionCommits(context, node); } else { checkResourceRecycled(context, node, name); } }
@Override public boolean visitMethodInvocation(MethodInvocation node) { if (SET_SMALL_ICON.equals(node.astName().astValue())) { StrictListAccessor<Expression,MethodInvocation> arguments = node.astArguments(); if (arguments.size() == 1 && arguments.first() instanceof Select) { handleSelect((Select) arguments.first()); } } return super.visitMethodInvocation(node); } }
private static boolean isSharedPreferenceGetString(@NonNull JavaContext context, @NonNull MethodInvocation call) { if (!GET_STRING_METHOD.equals(call.astName().astValue())) { return false; } JavaParser.ResolvedNode resolved = context.resolve(call); if (resolved instanceof JavaParser.ResolvedMethod) { JavaParser.ResolvedMethod resolvedMethod = (JavaParser.ResolvedMethod) resolved; JavaParser.ResolvedClass containingClass = resolvedMethod.getContainingClass(); return containingClass.isSubclassOf(ANDROID_CONTENT_SHARED_PREFERENCES, false); } return false; // not certain }