本文整理汇总了Java中com.sun.tools.javac.code.Symbol.ClassSymbol.complete方法的典型用法代码示例。如果您正苦于以下问题:Java ClassSymbol.complete方法的具体用法?Java ClassSymbol.complete怎么用?Java ClassSymbol.complete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.code.Symbol.ClassSymbol
的用法示例。
在下文中一共展示了ClassSymbol.complete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeElementByBinaryName
import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入方法依赖的package包/类
public static TypeElement getTypeElementByBinaryName(JavacTask task, ModuleElement mod, String name) {
Context ctx = ((JavacTaskImpl) task).getContext();
Names names = Names.instance(ctx);
Symtab syms = Symtab.instance(ctx);
final Name wrappedName = names.fromString(name);
ClassSymbol clazz = syms.enterClass((ModuleSymbol) mod, wrappedName);
try {
clazz.complete();
if (clazz.kind == Kind.TYP &&
clazz.flatName() == wrappedName) {
return clazz;
}
} catch (CompletionFailure cf) {
}
return null;
}
示例2: loadClass
import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入方法依赖的package包/类
/** Load a toplevel class with given fully qualified name
* The class is entered into `classes' only if load was successful.
*/
public ClassSymbol loadClass(ModuleSymbol msym, Name flatname) throws CompletionFailure {
Assert.checkNonNull(msym);
Name packageName = Convert.packagePart(flatname);
PackageSymbol ps = syms.lookupPackage(msym, packageName);
Assert.checkNonNull(ps.modle, () -> "msym=" + msym + "; flatName=" + flatname);
boolean absent = syms.getClass(ps.modle, flatname) == null;
ClassSymbol c = syms.enterClass(ps.modle, flatname);
if (c.members_field == null) {
try {
c.complete();
} catch (CompletionFailure ex) {
if (absent) syms.removeClass(ps.modle, flatname);
throw ex;
}
}
return c;
}
示例3: complete
import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入方法依赖的package包/类
/** Main method: enter one class from a list of toplevel trees and
* place the rest on uncompleted for later processing.
* @param trees The list of trees to be processed.
* @param c The class symbol to be processed.
*/
public void complete(List<JCCompilationUnit> trees, ClassSymbol c) {
annotate.enterStart();
ListBuffer<ClassSymbol> prevUncompleted = uncompleted;
if (memberEnter.completionEnabled) uncompleted = new ListBuffer<ClassSymbol>();
try {
// enter all classes, and construct uncompleted list
classEnter(trees, null);
// complete all uncompleted classes in memberEnter
if (memberEnter.completionEnabled) {
while (uncompleted.nonEmpty()) {
ClassSymbol clazz = uncompleted.next();
if (c == null || c == clazz || prevUncompleted == null)
clazz.complete();
else
// defer
prevUncompleted.append(clazz);
}
// if there remain any unimported toplevels (these must have
// no classes at all), process their import statements as well.
for (JCCompilationUnit tree : trees) {
if (tree.starImportScope.elems == null) {
JavaFileObject prev = log.useSource(tree.sourcefile);
Env<AttrContext> topEnv = topLevelEnv(tree);
memberEnter.memberEnter(tree, topEnv);
log.useSource(prev);
}
}
}
} finally {
uncompleted = prevUncompleted;
annotate.enterDone();
}
}
示例4: complete
import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入方法依赖的package包/类
private List<String> complete(Path test, List<Path> order, Path missing, boolean badClassFile) {
Context context = new Context();
if (badClassFile) {
TestClassReader.preRegister(context);
}
JavacTool tool = JavacTool.create();
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, null, null, List.of("-classpath", test.toString(), "-XDblockClass=" + flatName(missing)), null, null, context);
Symtab syms = Symtab.instance(context);
Names names = Names.instance(context);
task.getElements().getTypeElement("java.lang.Object");
if (!badClassFile) {
//to ensure the same paths taken in ClassFinder.completeEnclosing in case the file is missing:
syms.enterClass(syms.unnamedModule, names.fromString(flatName(missing)));
}
List<String> result = new ArrayList<>();
for (Path toCheck : order) {
ClassSymbol sym = syms.enterClass(syms.unnamedModule, names.fromString(flatName(toCheck)));
try {
sym.complete();
} catch (CompletionFailure ignore) {
}
long flags = sym.flags_field;
flags &= ~(Flags.CLASS_SEEN | Flags.SOURCE_SEEN);
result.add("sym: " + sym.flatname + ", " + sym.owner.flatName() +
", " + sym.type + ", " + sym.members_field + ", " + flags);
}
return result;
}