本文整理了Java中com.sun.tools.javac.main.JavaCompiler.resolveIdent()
方法的一些代码示例,展示了JavaCompiler.resolveIdent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JavaCompiler.resolveIdent()
方法的具体详情如下:
包路径:com.sun.tools.javac.main.JavaCompiler
类名称:JavaCompiler
方法名:resolveIdent
[英]Resolve an identifier.
[中]解析标识符。
代码示例来源:origin: google/error-prone
public ClassSymbol resolveClass(CharSequence qualifiedClass)
throws CouldNotResolveImportException {
try {
Symbol symbol =
JavaCompiler.instance(context)
.resolveIdent(symtab().java_base, qualifiedClass.toString());
if (symbol.equals(symtab().errSymbol) || !(symbol instanceof ClassSymbol)) {
throw new CouldNotResolveImportException(qualifiedClass);
} else {
return (ClassSymbol) symbol;
}
} catch (NullPointerException e) {
throw new CouldNotResolveImportException(qualifiedClass);
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/** Resolve an identifier which may be the binary name of a class or
* the Java name of a class or package.
* @param name The name to resolve
*/
public Symbol resolveBinaryNameOrIdent(String name) {
try {
Name flatname = names.fromString(name.replace("/", "."));
return reader.loadClass(flatname);
} catch (CompletionFailure ignore) {
return resolveIdent(name);
}
}
代码示例来源:origin: konsoletyper/teavm-javac
/** Resolve an identifier which may be the binary name of a class or
* the Java name of a class or package.
* @param name The name to resolve
*/
public Symbol resolveBinaryNameOrIdent(String name) {
try {
Name flatname = names.fromString(name.replace("/", "."));
return reader.loadClass(flatname);
} catch (CompletionFailure ignore) {
return resolveIdent(name);
}
}
代码示例来源:origin: konsoletyper/teavm-javac
/**
* Returns a symbol given the type's or packages's canonical name,
* or null if the name isn't found.
*/
private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) {
Name name = names.fromString(nameStr);
// First check cache.
Symbol sym = (clazz == ClassSymbol.class)
? syms.classes.get(name)
: syms.packages.get(name);
try {
if (sym == null)
sym = javaCompiler.resolveIdent(nameStr);
sym.complete();
return (sym.kind != Kinds.ERR &&
sym.exists() &&
clazz.isInstance(sym) &&
name.equals(sym.getQualifiedName()))
? clazz.cast(sym)
: null;
} catch (CompletionFailure e) {
return null;
}
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Returns a symbol given the type's or packages's canonical name,
* or null if the name isn't found.
*/
private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) {
Name name = names.fromString(nameStr);
// First check cache.
Symbol sym = (clazz == ClassSymbol.class)
? syms.classes.get(name)
: syms.packages.get(name);
try {
if (sym == null)
sym = javaCompiler.resolveIdent(nameStr);
sym.complete();
return (sym.kind != Kinds.ERR &&
sym.exists() &&
clazz.isInstance(sym) &&
name.equals(sym.getQualifiedName()))
? clazz.cast(sym)
: null;
} catch (CompletionFailure e) {
return null;
}
}
代码示例来源:origin: com.google.errorprone/error_prone_core
public ClassSymbol resolveClass(CharSequence qualifiedClass)
throws CouldNotResolveImportException {
try {
Symbol symbol =
JavaCompiler.instance(context)
.resolveIdent(symtab().java_base, qualifiedClass.toString());
if (symbol.equals(symtab().errSymbol) || !(symbol instanceof ClassSymbol)) {
throw new CouldNotResolveImportException(qualifiedClass);
} else {
return (ClassSymbol) symbol;
}
} catch (NullPointerException e) {
throw new CouldNotResolveImportException(qualifiedClass);
}
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* Returns a symbol given the type's or packages's canonical name,
* or null if the name isn't found.
*/
private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) {
Name name = names.fromString(nameStr);
// First check cache.
Symbol sym = (clazz == ClassSymbol.class)
? syms.classes.get(name)
: syms.packages.get(name);
try {
if (sym == null)
sym = javaCompiler.resolveIdent(nameStr);
sym.complete();
return (sym.kind != Kinds.ERR &&
sym.exists() &&
clazz.isInstance(sym) &&
name.equals(sym.getQualifiedName()))
? clazz.cast(sym)
: null;
} catch (CompletionFailure e) {
return null;
}
}
代码示例来源:origin: sc.fiji/javac
/**
* Returns a symbol given the type's or packages's canonical name,
* or null if the name isn't found.
*/
private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) {
Name name = names.fromString(nameStr);
// First check cache.
Symbol sym = (clazz == ClassSymbol.class)
? syms.classes.get(name)
: syms.packages.get(name);
try {
if (sym == null)
sym = javaCompiler.resolveIdent(nameStr);
sym.complete();
return (sym.kind != Kinds.ERR &&
sym.exists() &&
clazz.isInstance(sym) &&
name.equals(sym.getQualifiedName()))
? clazz.cast(sym)
: null;
} catch (CompletionFailure e) {
return null;
}
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
continue;
TypeSymbol sym = (TypeSymbol)compiler.resolveIdent(className);
if (sym.kind != Kinds.TYP) {
if (className.indexOf('$') < 0) {
代码示例来源:origin: sc.fiji/javac
continue;
TypeSymbol sym = (TypeSymbol)compiler.resolveIdent(className);
if (sym.kind != Kinds.TYP) {
if (className.indexOf('$') < 0) {
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
continue;
TypeSymbol sym = (TypeSymbol)compiler.resolveIdent(className);
if (sym.kind != Kinds.TYP) {
if (className.indexOf('$') < 0) {
代码示例来源:origin: konsoletyper/teavm-javac
continue;
TypeSymbol sym = (TypeSymbol)compiler.resolveIdent(className);
if (sym.kind != Kinds.TYP) {
if (className.indexOf('$') < 0) {
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
boolean errors = false;
for (String nameStr : classnames) {
Symbol sym = resolveIdent(nameStr);
if (sym == null || (sym.kind == Kinds.PCK && !processPcks)) {
log.error("proc.cant.find.class", nameStr);
代码示例来源:origin: sc.fiji/javac
boolean errors = false;
for (String nameStr : classnames) {
Symbol sym = resolveIdent(nameStr);
if (sym == null || (sym.kind == Kinds.PCK && !processPcks)) {
log.error("proc.cant.find.class", nameStr);
内容来源于网络,如有侵权,请联系作者删除!