use of org.sonar.plugins.java.api.tree.SyntaxTrivia in project sonar-java by SonarSource.
the class SubscriptionVisitor method visit.
private void visit(Tree tree) {
boolean isSubscribed = isSubscribed(tree);
boolean shouldVisitSyntaxToken = (visitToken || visitTrivia) && tree.is(Tree.Kind.TOKEN);
if (shouldVisitSyntaxToken) {
SyntaxToken syntaxToken = (SyntaxToken) tree;
if (visitToken) {
visitToken(syntaxToken);
}
if (visitTrivia) {
for (SyntaxTrivia syntaxTrivia : syntaxToken.trivias()) {
visitTrivia(syntaxTrivia);
}
}
} else if (isSubscribed) {
visitNode(tree);
}
visitChildren(tree);
if (!shouldVisitSyntaxToken && isSubscribed) {
leaveNode(tree);
}
}
use of org.sonar.plugins.java.api.tree.SyntaxTrivia in project sonar-java by SonarSource.
the class JavaNodeBuilder method createTrivias.
private static List<SyntaxTrivia> createTrivias(List<Trivia> trivias) {
List<SyntaxTrivia> result = Lists.newArrayList();
for (Trivia trivia : trivias) {
Token trivialToken = trivia.getToken();
result.add(InternalSyntaxTrivia.create(trivialToken.getValue(), trivialToken.getLine(), trivialToken.getColumn()));
}
return result;
}
Aggregations