當前位置: 首頁>>代碼示例>>Java>>正文


Java LanguageVersionHandler類代碼示例

本文整理匯總了Java中net.sourceforge.pmd.lang.LanguageVersionHandler的典型用法代碼示例。如果您正苦於以下問題:Java LanguageVersionHandler類的具體用法?Java LanguageVersionHandler怎麽用?Java LanguageVersionHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LanguageVersionHandler類屬於net.sourceforge.pmd.lang包,在下文中一共展示了LanguageVersionHandler類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSupportedLanguageVersions

import net.sourceforge.pmd.lang.LanguageVersionHandler; //導入依賴的package包/類
/**
 * 지원가능한 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()]);
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:27,代碼來源:PMDUtil.java

示例2: getSupportedLanguageVersions

import net.sourceforge.pmd.lang.LanguageVersionHandler; //導入依賴的package包/類
private 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: {}", languageVersion.getName());
//				} else {
//					LOGGER.debug("not support parser: {}", languageVersion.getName());
				}
//			} else {
//				LOGGER.debug("not support parser (handler is null): {}", languageVersion.getName());
			}
		}
		return languageVersions.toArray(new LanguageVersion[languageVersions.size()]);
	}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:20,代碼來源:DesignerFx.java

示例3: getCompilationUnit

import net.sourceforge.pmd.lang.LanguageVersionHandler; //導入依賴的package包/類
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;
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:8,代碼來源:DesignerFx.java

示例4: parse

import net.sourceforge.pmd.lang.LanguageVersionHandler; //導入依賴的package包/類
@Override
public LanguageVersion parse(String languageVersionString) {
    Matcher javaVersionMatcher = javaVersionPattern.matcher(languageVersionString);

    if (!javaVersionMatcher.matches()) {
        throw new IllegalArgumentException("Unsupported target Java version");
    }

    String majorVersion = javaVersionMatcher.group(1);
    String minorVersion = javaVersionMatcher.group(2);
    String languageHandlerClassName = String.format("net.sourceforge.pmd.lang.java.Java%s%sHandler", majorVersion, minorVersion);

    try {
        Class<? extends LanguageVersionHandler> languageHandlerClass = (Class<? extends LanguageVersionHandler>) Class.forName(languageHandlerClassName);

        LanguageVersionHandler languageHandler = languageHandlerClass.newInstance();

        Language javaLanguage = LanguageRegistry.getLanguage("Java");

        if (javaLanguage == null) {
            throw new IllegalStateException("Cannot find Java in PMD's language registry");
        }

        return new LanguageVersion(javaLanguage, languageVersionString, languageHandler);
    } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | IllegalArgumentException ex) {
        throw new IllegalArgumentException("Unsupported target Java version");
    }
}
 
開發者ID:giancosta86,項目名稱:EasyPmd,代碼行數:29,代碼來源:DefaultLanguageVersionParser.java

示例5: getLanguageVersionHandler

import net.sourceforge.pmd.lang.LanguageVersionHandler; //導入依賴的package包/類
private LanguageVersionHandler getLanguageVersionHandler() {
	LanguageVersion languageVersion = getLanguageVersion();
	return languageVersion.getLanguageVersionHandler();
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:5,代碼來源:DesignerFx.java

示例6: label

import net.sourceforge.pmd.lang.LanguageVersionHandler; //導入依賴的package包/類
public String label() {
	LanguageVersionHandler languageVersionHandler = getLanguageVersionHandler();
	StringWriter writer = new StringWriter();
	languageVersionHandler.getDumpFacade(writer, "", false).start(node);
	return writer.toString();
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:7,代碼來源:DesignerFx.java


注:本文中的net.sourceforge.pmd.lang.LanguageVersionHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。