use of org.sonar.plugins.java.api.tree.VariableTree in project sonar-java by SonarSource.
the class GenericsTest method declaredTypesOfVariablesFromLastClass.
private static List<Type> declaredTypesOfVariablesFromLastClass(String... lines) {
CompilationUnitTree tree = treeOf(lines);
List<Tree> declaredClasses = tree.types();
Tree last = declaredClasses.get(declaredClasses.size() - 1);
if (!(last instanceof ClassTree)) {
return Collections.emptyList();
}
ClassTree testClass = (ClassTree) last;
List<Type> types = new ArrayList<>();
for (Tree member : testClass.members()) {
if (member instanceof VariableTree) {
types.add(((VariableTree) member).type().symbolType());
}
}
return types;
}
Aggregations