Java Code Examples for org.sonar.plugins.java.api.tree.MethodInvocationTree#methodSelect()
The following examples show how to use
org.sonar.plugins.java.api.tree.MethodInvocationTree#methodSelect() .
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: HardCodedSleepCheck.java From sonar-webdriver-plugin with MIT License | 6 votes |
@Override public void visitMethodInvocation(MethodInvocationTree tree) { JavaFileScannerContext context = getContext(); if (!tree.methodSelect().is(Tree.Kind.IDENTIFIER)) { MemberSelectExpressionTree memberSelectExpressionTree = ((MemberSelectExpressionTree) tree.methodSelect()); String methodName = memberSelectExpressionTree.identifier().name(); String fullyQualifiedNameOfExpression = memberSelectExpressionTree.expression().symbolType() .fullyQualifiedName(); if (SLEEP_METHOD_NAME.equals(methodName) && fullyQualifiedNameOfExpression.equals(THREAD)) { context.reportIssue(this, tree, "Avoid using hard coded sleeps, use explicit wait instead"); } } }
Example 2
Source File: ImplicitWaitCheck.java From sonar-webdriver-plugin with MIT License | 6 votes |
@Override public void visitMethodInvocation(MethodInvocationTree tree) { JavaFileScannerContext context = getContext(); if (!tree.methodSelect().is(Tree.Kind.IDENTIFIER)) { MemberSelectExpressionTree memberSelectExpressionTree = ((MemberSelectExpressionTree) tree.methodSelect()); String methodName = memberSelectExpressionTree.identifier().name(); String fullyQualifiedNameOfExpression = memberSelectExpressionTree.expression().symbolType() .fullyQualifiedName(); if (IMPLICITLY_WAIT_METHOD_NAME.equals(methodName) && isPartOfWebDriverPackage(fullyQualifiedNameOfExpression)) { context.reportIssue(this, tree, "Avoid using implicit wait, use explicit wait instead"); } } }
Example 3
Source File: CommonUtil.java From sonar-webdriver-plugin with MIT License | 5 votes |
private static IdentifierTree getIdentifier(MethodInvocationTree methodInvocationTree) { // methodSelect can only be Tree.Kind.IDENTIFIER or Tree.Kind.MEMBER_SELECT if (methodInvocationTree.methodSelect().is(Tree.Kind.IDENTIFIER)) { return (IdentifierTree) methodInvocationTree.methodSelect(); } return ((MemberSelectExpressionTree) methodInvocationTree.methodSelect()).identifier(); }
Example 4
Source File: UnusedMethodParameterCheck.java From vjtools with Apache License 2.0 | 5 votes |
@Override public void visitMethodInvocation(MethodInvocationTree tree) { ExpressionTree methodSelect = tree.methodSelect(); if (!methodSelect.is(Tree.Kind.IDENTIFIER)) { // not interested in simple method invocations, we are targeting usage of method parameters scan(methodSelect); } scan(tree.typeArguments()); scan(tree.arguments()); }
Example 5
Source File: UnusedMethodParameterCheck.java From vjtools with Apache License 2.0 | 5 votes |
@Override public void visitMethodInvocation(MethodInvocationTree tree) { ExpressionTree methodSelect = tree.methodSelect(); if (!methodSelect.is(Tree.Kind.IDENTIFIER)) { // not interested in simple method invocations, we are targeting usage of method parameters scan(methodSelect); } scan(tree.typeArguments()); scan(tree.arguments()); }
Example 6
Source File: ContentResourceShouldBeNullCheckedCheck.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
private void chainedMethodsNullCheck(MethodInvocationTree tree) { if (tree.methodSelect() instanceof MemberSelectExpressionTree) { MemberSelectExpressionTree method = (MemberSelectExpressionTree) tree.methodSelect(); if (method.expression() instanceof MethodInvocationTree) { MethodInvocationTree invocation = (MethodInvocationTree) method.expression(); if (!invocation.symbol().isUnknown() && isPage(invocation.symbol().owner().type().fullyQualifiedName()) && isGetContentResourceUsedOnPage(invocation) && !returnOccurredInsideEqualNullCheck) { context.reportIssue(this, tree, RULE_MESSAGE); } } } }
Example 7
Source File: MethodMatcher.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
private static IdentifierTree getIdentifier(MethodInvocationTree methodInvocationTree) { // methodSelect can only be the Tree.Kind.IDENTIFIER or the Tree.Kind.MEMBER_SELECT if (methodInvocationTree.methodSelect().is(Tree.Kind.IDENTIFIER)) { return (IdentifierTree) methodInvocationTree.methodSelect(); } return ((MemberSelectExpressionTree) methodInvocationTree.methodSelect()).identifier(); }
Example 8
Source File: FindSessionDeclarationVisitor.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 4 votes |
private MethodTree getMethodTree(MethodInvocationTree methodInvocation) { IdentifierTree method = (IdentifierTree) methodInvocation.methodSelect(); return (MethodTree) getDeclaration(method); }
Example 9
Source File: FindRRDeclarationVisitor.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 4 votes |
private MethodTree getMethodTree(MethodInvocationTree methodInvocation) { IdentifierTree method = (IdentifierTree) methodInvocation.methodSelect(); return (MethodTree) getDeclaration(method); }