Java Code Examples for org.sonar.plugins.java.api.tree.VariableTree#initializer()
The following examples show how to use
org.sonar.plugins.java.api.tree.VariableTree#initializer() .
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: FindRRDeclarationVisitor.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
@Override public void visitVariable(VariableTree tree) { if (isAMethodInvocation(tree) && variableIsEqualToReturnedVariableIn(tree)) { MethodInvocationTree methodInvocation = (MethodInvocationTree) tree.initializer(); if (isManuallyCreatedResourceResolver(methodInvocation)) { this.createdManually = true; } else { CheckIfRRCreatedManually rrCreatedManually = new CheckIfRRCreatedManually(); getMethodTree(methodInvocation).accept(rrCreatedManually); this.createdManually = rrCreatedManually.isCreatedManually(); } } super.visitVariable(tree); }
Example 2
Source File: FindRRDeclarationVisitor.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
private boolean isAMethodInvocation(VariableTree tree) { boolean returnVal = false; if (tree.initializer() != null) { returnVal = tree.initializer().is(Kind.METHOD_INVOCATION); } return returnVal; }
Example 3
Source File: ContentResourceShouldBeNullCheckedCheck.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 5 votes |
private boolean isGetContentResourceUsedOnPage(VariableTree tree) { return tree.initializer() instanceof MethodInvocationTree && !((MethodInvocationTree) tree.initializer()).symbol().isUnknown() && isPage(((MethodInvocationTree) tree.initializer()).symbol().owner().type() .fullyQualifiedName()) && GET_CONTENT_RESOURCE_METHOD.equals(((MethodInvocationTree) tree.initializer()).symbol().name()); }
Example 4
Source File: ContentResourceShouldBeNullCheckedCheck.java From AEM-Rules-for-SonarQube with Apache License 2.0 | 4 votes |
private boolean isResourceInitialized(VariableTree tree) { return tree.initializer() != null && tree.initializer().kind() != Kind.NULL_LITERAL; }