use of org.sonar.plugins.java.api.tree.SyntaxToken in project sonar-java by SonarSource.
the class NestedIfStatementsCheck method visitForStatement.
@Override
public void visitForStatement(ForStatementTree tree) {
SyntaxToken forKeyword = tree.forKeyword();
checkNesting(forKeyword);
nestingLevel.push(forKeyword);
super.visitForStatement(tree);
nestingLevel.pop();
}
use of org.sonar.plugins.java.api.tree.SyntaxToken in project sonar-java by SonarSource.
the class NestedIfStatementsCheck method visitForEachStatement.
@Override
public void visitForEachStatement(ForEachStatement tree) {
SyntaxToken forKeyword = tree.forKeyword();
checkNesting(forKeyword);
nestingLevel.push(forKeyword);
super.visitForEachStatement(tree);
nestingLevel.pop();
}
use of org.sonar.plugins.java.api.tree.SyntaxToken in project sonar-java by SonarSource.
the class NestedIfStatementsCheck method visitIfStatement.
@Override
public void visitIfStatement(IfStatementTree tree) {
SyntaxToken ifKeyword = tree.ifKeyword();
checkNesting(ifKeyword);
nestingLevel.push(ifKeyword);
visit(tree);
nestingLevel.pop();
}
use of org.sonar.plugins.java.api.tree.SyntaxToken in project sonar-java by SonarSource.
the class ListTreeImplTest method emptySeparators.
@Test
public void emptySeparators() throws Exception {
Tree tree1 = new EmptyStatementTreeImpl(null);
List<Tree> trees = Lists.newArrayList(tree1);
List<SyntaxToken> separators = Lists.newArrayList();
ListTreeImpl<Tree> listTree = new MyList(trees, separators);
Iterable<Tree> result = listTree.children();
assertThat(Lists.newArrayList(result)).containsExactly(tree1);
}
use of org.sonar.plugins.java.api.tree.SyntaxToken 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());
}
Aggregations