Search in sources :

Example 1 with Parser

use of net.sourceforge.pmd.lang.Parser in project Gargoyle by callakrsos.

the class PMDUtil method getSupportedLanguageVersions.

/**
	 * 지원가능한 PMD Language를 리턴.
	 *
	 * @작성자 : KYJ
	 * @작성일 : 2016. 10. 4.
	 * @return
	 */
public static LanguageVersion[] getSupportedLanguageVersions() {
    List<LanguageVersion> languageVersions = new ArrayList<>();
    for (LanguageVersion languageVersion : LanguageRegistry.findAllVersions()) {
        LanguageVersionHandler languageVersionHandler = languageVersion.getLanguageVersionHandler();
        if (languageVersionHandler != null) {
            Parser parser = languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions());
            if (parser != null && parser.canParse()) {
                languageVersions.add(languageVersion);
                LOGGER.debug("support parser: {}", parser.toString());
            } else {
                LOGGER.debug("not support parser: {}", parser.toString());
            }
        } else {
            LOGGER.debug("not support parser (handler is null): {}", languageVersion.toString());
        }
    }
    return languageVersions.toArray(new LanguageVersion[languageVersions.size()]);
}
Also used : ArrayList(java.util.ArrayList) LanguageVersion(net.sourceforge.pmd.lang.LanguageVersion) LanguageVersionHandler(net.sourceforge.pmd.lang.LanguageVersionHandler) Parser(net.sourceforge.pmd.lang.Parser)

Example 2 with Parser

use of net.sourceforge.pmd.lang.Parser in project Gargoyle by callakrsos.

the class DesignerFx method getCompilationUnit.

static Node getCompilationUnit(LanguageVersionHandler languageVersionHandler, String code) {
    Parser parser = languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions());
    Node node = parser.parse(null, new StringReader(code));
    languageVersionHandler.getSymbolFacade().start(node);
    languageVersionHandler.getTypeResolutionFacade(DesignerFx.class.getClassLoader()).start(node);
    return node;
}
Also used : ScopedNode(net.sourceforge.pmd.lang.symboltable.ScopedNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) Node(net.sourceforge.pmd.lang.ast.Node) SwingNode(javafx.embed.swing.SwingNode) StringReader(java.io.StringReader) Parser(net.sourceforge.pmd.lang.Parser)

Aggregations

Parser (net.sourceforge.pmd.lang.Parser)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 SwingNode (javafx.embed.swing.SwingNode)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreeNode (javax.swing.tree.TreeNode)1 LanguageVersion (net.sourceforge.pmd.lang.LanguageVersion)1 LanguageVersionHandler (net.sourceforge.pmd.lang.LanguageVersionHandler)1 Node (net.sourceforge.pmd.lang.ast.Node)1 ScopedNode (net.sourceforge.pmd.lang.symboltable.ScopedNode)1