use of net.sourceforge.pmd.lang.java.qname.QualifiedNameResolver in project pmd by pmd.
the class ParserTstUtil method getOrderedNodes.
public static <E> List<E> getOrderedNodes(Class<E> clazz, String javaCode) {
Collector<E> coll = new Collector<>(clazz, new ArrayList<E>());
LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler();
ASTCompilationUnit cu = (ASTCompilationUnit) languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions()).parse(null, new StringReader(javaCode));
JavaParserVisitor jpv = (JavaParserVisitor) Proxy.newProxyInstance(JavaParserVisitor.class.getClassLoader(), new Class[] { JavaParserVisitor.class }, coll);
jpv.visit(cu, null);
new QualifiedNameResolver().initializeWith(ParserTstUtil.class.getClassLoader(), cu);
new SymbolFacade().initializeWith(cu);
new DataFlowFacade().initializeWith(languageVersionHandler.getDataFlowHandler(), cu);
return (List<E>) coll.getCollection();
}
Aggregations