use of org.sonar.plugins.java.api.tree.ListTree in project sonar-java by SonarSource.
the class TryStatementTreeImpl method filterVariableTreeResources.
private static ListTree filterVariableTreeResources(ResourceListTreeImpl resources) {
ImmutableList.Builder<Tree> filteredResources = ImmutableList.builder();
ImmutableList.Builder<SyntaxToken> filteredSeparators = ImmutableList.builder();
Iterator<SyntaxToken> separators = resources.separators().iterator();
for (Tree resource : resources) {
SyntaxToken separator = null;
if (separators.hasNext()) {
separator = separators.next();
}
if (resource.is(Kind.VARIABLE)) {
filteredResources.add(resource);
if (separator != null) {
filteredSeparators.add(separator);
}
}
}
return new ResourceListTreeImpl(filteredResources.build(), filteredSeparators.build());
}
Aggregations