org.sonar.plugins.java.api.tree.ExpressionStatementTree Java Examples

The following examples show how to use org.sonar.plugins.java.api.tree.ExpressionStatementTree. 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: UnusedPrivateFieldCheck.java    From vjtools with Apache License 2.0 6 votes vote down vote up
@Override
public void visitNode(Tree tree) {
	if (!hasSemantic()) {
		return;
	}
	switch (tree.kind()) {
	case METHOD:
		checkIfNativeMethod((MethodTree) tree);
		break;
	case CLASS:
		classes.add((ClassTree) tree);
		break;
	case IMPORT:// VJ
		checkIfLombokClass((ImportTree) tree);
		break;
	case EXPRESSION_STATEMENT:
		collectAssignment(((ExpressionStatementTree) tree).expression());
		break;
	case IDENTIFIER:
		collectUnknownIdentifier((IdentifierTree) tree);
		break;
	default:
		throw new IllegalStateException("Unexpected subscribed tree.");
	}
}
 
Example #2
Source File: UnusedPrivateFieldCheck.java    From vjtools with Apache License 2.0 6 votes vote down vote up
@Override
public void visitNode(Tree tree) {
	if (!hasSemantic()) {
		return;
	}
	switch (tree.kind()) {
	case METHOD:
		checkIfNativeMethod((MethodTree) tree);
		break;
	case CLASS:
		classes.add((ClassTree) tree);
		break;
	case IMPORT:// VJ
		checkIfLombokClass((ImportTree) tree);
		break;
	case EXPRESSION_STATEMENT:
		collectAssignment(((ExpressionStatementTree) tree).expression());
		break;
	case IDENTIFIER:
		collectUnknownIdentifier((IdentifierTree) tree);
		break;
	default:
		throw new IllegalStateException("Unexpected subscribed tree.");
	}
}
 
Example #3
Source File: SlingQueryImplicitStrategyCheck.java    From AEM-Rules-for-SonarQube with Apache License 2.0 5 votes vote down vote up
@Override
public void visitExpressionStatement(ExpressionStatementTree tree) {
    currentSlingQueryVariableName = tree.firstToken().text();
    if (isThisANewSlingQuery()) {
        slingQueries.putIfAbsent(currentSlingQueryVariableName, SlingQueryStates.NOT_USED);
    }
    super.visitExpressionStatement(tree);
    // This part of code will be executed directly after expression
    reportIssueIfStrategyNotUsed(tree, currentSlingQueryVariableName);
}
 
Example #4
Source File: MethodMatcherTest.java    From AEM-Rules-for-SonarQube with Apache License 2.0 4 votes vote down vote up
private void givenMethodInvocationTree(String codeToParse) {
    CompilationUnitTree compilationUnitTree = parse(codeToParse);
    ClassTree classTree = (ClassTree) compilationUnitTree.types().get(CLASS_INDEX);
    StatementTree statementTree = ((MethodTree) classTree.members().get(CLASS_METHOD_INDEX)).block().body().get(METHOD_INVOCATION_INDEX);
    this.methodInvocationTree = (MethodInvocationTree) ((ExpressionStatementTree) statementTree).expression();
}