本文整理匯總了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()]);
}
示例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()]);
}
示例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;
}
示例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");
}
}
示例5: getLanguageVersionHandler
import net.sourceforge.pmd.lang.LanguageVersionHandler; //導入依賴的package包/類
private LanguageVersionHandler getLanguageVersionHandler() {
LanguageVersion languageVersion = getLanguageVersion();
return languageVersion.getLanguageVersionHandler();
}
示例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();
}