Search in sources :

Example 1 with ExpressionStatementTreeImpl

use of org.sonar.java.model.statement.ExpressionStatementTreeImpl in project sonar-java by SonarSource.

the class TreeFactory method newStatementExpressions.

public StatementExpressionListTreeImpl newStatementExpressions(ExpressionTree expression, Optional<List<Tuple<InternalSyntaxToken, ExpressionTree>>> rests) {
    ImmutableList.Builder<StatementTree> statements = ImmutableList.builder();
    statements.add(new ExpressionStatementTreeImpl(expression, null));
    ImmutableList.Builder<SyntaxToken> separators = ImmutableList.builder();
    if (rests.isPresent()) {
        for (Tuple<InternalSyntaxToken, ExpressionTree> rest : rests.get()) {
            separators.add(rest.first());
            statements.add(new ExpressionStatementTreeImpl(rest.second(), null));
        }
    }
    return new StatementExpressionListTreeImpl(statements.build(), separators.build());
}
Also used : StatementTree(org.sonar.plugins.java.api.tree.StatementTree) SyntaxToken(org.sonar.plugins.java.api.tree.SyntaxToken) InternalSyntaxToken(org.sonar.java.model.InternalSyntaxToken) ImmutableList(com.google.common.collect.ImmutableList) ExpressionTree(org.sonar.plugins.java.api.tree.ExpressionTree) InternalSyntaxToken(org.sonar.java.model.InternalSyntaxToken) ExpressionStatementTreeImpl(org.sonar.java.model.statement.ExpressionStatementTreeImpl)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 InternalSyntaxToken (org.sonar.java.model.InternalSyntaxToken)1 ExpressionStatementTreeImpl (org.sonar.java.model.statement.ExpressionStatementTreeImpl)1 ExpressionTree (org.sonar.plugins.java.api.tree.ExpressionTree)1 StatementTree (org.sonar.plugins.java.api.tree.StatementTree)1 SyntaxToken (org.sonar.plugins.java.api.tree.SyntaxToken)1