当前位置: 首页>>代码示例>>Java>>正文


Java ClassSymbol.complete方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ElementUtils.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ClassFinder.java

示例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();
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:42,代码来源:Enter.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:NoAbortForBadClassFile.java


注:本文中的com.sun.tools.javac.code.Symbol.ClassSymbol.complete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。