Search in sources :

Example 1 with ASTInput

use of net.sourceforge.pmd.lang.plsql.ast.ASTInput in project pmd by pmd.

the class AbstractPLSQLParserTst method getNodes.

public <E> Set<E> getNodes(LanguageVersion languageVersion, Class<E> clazz, String plsqlCode) {
    Collector<E> coll = new Collector<>(clazz);
    LanguageVersionHandler languageVersionHandler = languageVersion.getLanguageVersionHandler();
    ASTInput cu = (ASTInput) languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions()).parse(null, new StringReader(plsqlCode));
    PLSQLParserVisitor jpv = (PLSQLParserVisitor) Proxy.newProxyInstance(PLSQLParserVisitor.class.getClassLoader(), new Class[] { PLSQLParserVisitor.class }, coll);
    jpv.visit(cu, null);
    return (Set<E>) coll.getCollection();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) PLSQLParserVisitor(net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitor) StringReader(java.io.StringReader) ASTInput(net.sourceforge.pmd.lang.plsql.ast.ASTInput) LanguageVersionHandler(net.sourceforge.pmd.lang.LanguageVersionHandler)

Example 2 with ASTInput

use of net.sourceforge.pmd.lang.plsql.ast.ASTInput in project pmd by pmd.

the class AbstractPLSQLParserTst method buildDFA.

public ASTInput buildDFA(String plsqlCode) {
    LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(PLSQLLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler();
    ASTInput cu = (ASTInput) languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions()).parse(null, new StringReader(plsqlCode));
    PLSQLParserVisitor jpv = (PLSQLParserVisitor) Proxy.newProxyInstance(PLSQLParserVisitor.class.getClassLoader(), new Class[] { PLSQLParserVisitor.class }, new Collector<>(ASTInput.class));
    jpv.visit(cu, null);
    new SymbolFacade().initializeWith(cu);
    new DataFlowFacade().initializeWith(languageVersionHandler.getDataFlowHandler(), cu);
    return cu;
}
Also used : PLSQLParserVisitor(net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitor) SymbolFacade(net.sourceforge.pmd.lang.plsql.symboltable.SymbolFacade) StringReader(java.io.StringReader) DataFlowFacade(net.sourceforge.pmd.lang.plsql.dfa.DataFlowFacade) ASTInput(net.sourceforge.pmd.lang.plsql.ast.ASTInput) LanguageVersionHandler(net.sourceforge.pmd.lang.LanguageVersionHandler)

Example 3 with ASTInput

use of net.sourceforge.pmd.lang.plsql.ast.ASTInput in project pmd by pmd.

the class AbstractPLSQLParserTst method getOrderedNodes.

public <E> List<E> getOrderedNodes(Class<E> clazz, String plsqlCode) {
    Collector<E> coll = new Collector<>(clazz, new ArrayList<E>());
    LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(PLSQLLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler();
    ASTInput cu = (ASTInput) languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions()).parse(null, new StringReader(plsqlCode));
    PLSQLParserVisitor jpv = (PLSQLParserVisitor) Proxy.newProxyInstance(PLSQLParserVisitor.class.getClassLoader(), new Class[] { PLSQLParserVisitor.class }, coll);
    jpv.visit(cu, null);
    SymbolFacade sf = new SymbolFacade();
    sf.initializeWith(cu);
    DataFlowFacade dff = new DataFlowFacade();
    dff.initializeWith(languageVersionHandler.getDataFlowHandler(), cu);
    return (List<E>) coll.getCollection();
}
Also used : PLSQLParserVisitor(net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitor) SymbolFacade(net.sourceforge.pmd.lang.plsql.symboltable.SymbolFacade) StringReader(java.io.StringReader) DataFlowFacade(net.sourceforge.pmd.lang.plsql.dfa.DataFlowFacade) ASTInput(net.sourceforge.pmd.lang.plsql.ast.ASTInput) ArrayList(java.util.ArrayList) List(java.util.List) LanguageVersionHandler(net.sourceforge.pmd.lang.LanguageVersionHandler)

Aggregations

StringReader (java.io.StringReader)3 LanguageVersionHandler (net.sourceforge.pmd.lang.LanguageVersionHandler)3 ASTInput (net.sourceforge.pmd.lang.plsql.ast.ASTInput)3 PLSQLParserVisitor (net.sourceforge.pmd.lang.plsql.ast.PLSQLParserVisitor)3 DataFlowFacade (net.sourceforge.pmd.lang.plsql.dfa.DataFlowFacade)2 SymbolFacade (net.sourceforge.pmd.lang.plsql.symboltable.SymbolFacade)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1