lombok.ast.Return Java Examples
The following examples show how to use
lombok.ast.Return.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaVisitor.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean visitReturn(Return node) { List<VisitingDetector> list = mNodeTypeDetectors.get(Return.class); if (list != null) { for (VisitingDetector v : list) { v.getVisitor().visitReturn(node); } } return false; }
Example #2
Source File: SharedPrefsDetector.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean visitReturn(Return node) { if (node.astValue() == mTarget) { // If you just do "return editor.commit() don't warn mFound = true; } return super.visitReturn(node); }
Example #3
Source File: CleanupDetector.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean visitReturn(Return node) { Expression value = node.astValue(); if (value instanceof VariableReference) { ResolvedNode resolved = mContext.resolve(value); //noinspection SuspiciousMethodCalls if (resolved != null && mVariables.contains(resolved)) { mEscapes = true; } } return super.visitReturn(node); }
Example #4
Source File: ToastDetector.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean visitReturn(Return node) { if (node.astValue() == mTarget) { // If you just do "return Toast.makeText(...) don't warn mFound = true; } return super.visitReturn(node); }
Example #5
Source File: UnsafeAndroidDetector.java From SafelyAndroid with MIT License | 5 votes |
@Override public boolean visitReturn(Return node) { if(node.astValue() == this.mTarget) { this.mFound = true; } return super.visitReturn(node); }
Example #6
Source File: ToastDetector.java From MeituanLintDemo with Apache License 2.0 | 5 votes |
@Override public boolean visitReturn(Return node) { if (node.astValue() == mTarget) { // If you just do "return Toast.makeText(...) don't warn mFound = true; } return super.visitReturn(node); }
Example #7
Source File: SharedPrefsDetector.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public boolean visitMethodInvocation(MethodInvocation node) { if (node == mTarget) { mSeenTarget = true; } else if (mAllowCommitBeforeTarget || mSeenTarget || node.astOperand() == mTarget) { String name = node.astName().astValue(); boolean isCommit = "commit".equals(name); if (isCommit || "apply".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$ // TODO: Do more flow analysis to see whether we're really calling commit/apply // on the right type of object? mFound = true; ResolvedNode resolved = mContext.resolve(node); if (resolved instanceof JavaParser.ResolvedMethod) { ResolvedMethod method = (ResolvedMethod) resolved; JavaParser.ResolvedClass clz = method.getContainingClass(); if (clz.isSubclassOf("android.content.SharedPreferences.Editor", false) && mContext.getProject().getMinSdkVersion().getApiLevel() >= 9) { // See if the return value is read: can only replace commit with // apply if the return value is not considered Node parent = node.getParent(); boolean returnValueIgnored = false; if (parent instanceof MethodDeclaration || parent instanceof ConstructorDeclaration || parent instanceof ClassDeclaration || parent instanceof Block || parent instanceof ExpressionStatement) { returnValueIgnored = true; } else if (parent instanceof Statement) { if (parent instanceof If) { returnValueIgnored = ((If) parent).astCondition() != node; } else if (parent instanceof Return) { returnValueIgnored = false; } else if (parent instanceof VariableDeclaration) { returnValueIgnored = false; } else if (parent instanceof For) { returnValueIgnored = ((For) parent).astCondition() != node; } else if (parent instanceof While) { returnValueIgnored = ((While) parent).astCondition() != node; } else if (parent instanceof DoWhile) { returnValueIgnored = ((DoWhile) parent).astCondition() != node; } else if (parent instanceof Case) { returnValueIgnored = ((Case) parent).astCondition() != node; } else if (parent instanceof Assert) { returnValueIgnored = ((Assert) parent).astAssertion() != node; } else { returnValueIgnored = true; } } if (returnValueIgnored && isCommit) { 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); } } } } } return super.visitMethodInvocation(node); }