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


Java ClassSymbol类代码示例

本文整理汇总了Java中com.sun.tools.javac.code.Symbol.ClassSymbol的典型用法代码示例。如果您正苦于以下问题:Java ClassSymbol类的具体用法?Java ClassSymbol怎么用?Java ClassSymbol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClassSymbol类属于com.sun.tools.javac.code.Symbol包,在下文中一共展示了ClassSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAllClasses

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
/**
 * Adds all inner classes of this class, and their inner classes recursively, to the list
 */
private void addAllClasses(Collection<TypeElement> list, TypeElement typeElement, boolean filtered) {
    ClassSymbol klass = (ClassSymbol)typeElement;
    try {
        // eliminate needless checking, do this first.
        if (list.contains(klass)) return;
        // ignore classes with invalid Java class names
        if (!JavadocTool.isValidClassName(klass.name.toString())) return;
        if (filtered && !isTypeElementSelected(klass)) return;
        list.add(klass);
        for (Symbol sym : klass.members().getSymbols(NON_RECURSIVE)) {
            if (sym != null && sym.kind == Kind.TYP) {
                ClassSymbol s = (ClassSymbol)sym;
                addAllClasses(list, s, filtered);
            }
        }
    } catch (CompletionFailure e) {
        if (e.getMessage() != null)
            messager.printWarning(e.getMessage());
        else
            messager.printWarningUsingKey("main.unexpected.exception", e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:ElementsTable.java

示例2: makeClassDoc

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
@Override
protected void makeClassDoc(ClassSymbol clazz, TreePath treePath) {
    if (clazz.type.hasTag(TypeTag.UNKNOWN)) {
        return;
    }
    ClassDocImpl result = classMap.get(clazz);
    if (result != null) {
        if (treePath != null) setTreePath(result, treePath);
        return;
    }
    if (isAnnotationType((JCClassDecl)treePath.getLeaf())) {	// flags of clazz may not yet be set
        result = new JavadocAnnotation(this, clazz, treePath);
    } else {
        result = new JavadocClass(this, clazz, treePath);
    }
    classMap.put(clazz, result);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JavadocEnv.java

示例3: 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

示例4: overridesMethod

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
/**
    * Returns true if this element represents a method which overrides a
    * method in one of its superclasses.
    */
   public boolean overridesMethod(ExecutableElement element) {
       MethodSymbol m = (MethodSymbol)element;
       if ((m.flags() & Flags.STATIC) == 0) {
           ClassSymbol owner = (ClassSymbol) m.owner;
           for (Type sup = jctypes.supertype(m.owner.type);
                   sup.hasTag(TypeTag.CLASS);
                   sup = jctypes.supertype(sup)) {
               for (Symbol sym : sup.tsym.members().getSymbolsByName(m.name)) {
                   if (m.overrides(sym, owner, jctypes, true)) 
                       return true;
               }
           }
       }
return false;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ElementsService.java

示例5: alreadyDefinedIn

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
public boolean alreadyDefinedIn(CharSequence name, TypeMirror returnType, List<TypeMirror> paramTypes, TypeElement enclClass) {
    ClassSymbol clazz = (ClassSymbol)enclClass;
    Scope scope = clazz.members();
    Name n = names.fromString(name.toString());
    ListBuffer<Type> buff = new ListBuffer<>();
    for (TypeMirror tm : paramTypes) {
        buff.append((Type)tm);
    }
    for (Symbol sym : scope.getSymbolsByName(n, Scope.LookupKind.NON_RECURSIVE)) {
        if(sym.type instanceof ExecutableType &&
                jctypes.containsTypeEquivalent(sym.type.asMethodType().getParameterTypes(), buff.toList()) &&
                jctypes.isSameType(sym.type.asMethodType().getReturnType(), (Type)returnType))
            return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ElementsService.java

示例6: javaDocFor

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
/**Get javadoc for given element.
 * @deprecated The new DocTree API should be used to traverse Javadoc comments.
 * Use {@link DocTrees#getDocCommentTree(javax.lang.model.element.Element)} instead.
 */
@Deprecated
public Doc javaDocFor(Element element) {
    if (element != null) {
        DocEnv env = DocEnv.instance(ctx);
        switch (element.getKind()) {
            case ANNOTATION_TYPE:
            case CLASS:
            case ENUM:
            case INTERFACE:
                return env.getClassDoc((ClassSymbol)element);
            case ENUM_CONSTANT:
            case FIELD:
                return env.getFieldDoc((VarSymbol)element);
            case METHOD:
                if (((MethodSymbol)element).enclClass().getKind() == ElementKind.ANNOTATION_TYPE)
                    return env.getAnnotationTypeElementDoc((MethodSymbol)element);
                return env.getMethodDoc((MethodSymbol)element);
            case CONSTRUCTOR:
                return env.getConstructorDoc((MethodSymbol)element);
            case PACKAGE:
                return env.getPackageDoc((PackageSymbol)element);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ElementUtilities.java

示例7: dumpSymFile

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
private void dumpSymFile(
        @NonNull final JavaFileManager jfm,
        @NonNull final JavacTaskImpl jti,
        @NullAllowed final ClassSymbol cs,
        @NonNull final Set<File> alreadyCreated,
        @NonNull final File classes,
        @NonNull final HashMap<ClassSymbol, JCClassDecl> syms2trees) throws IOException {
    if (cs == null) {
        //ClassDecl has no symbol because compilation was cancelled
        //by low memory before ENTER done.
        return;
    }        
    JavaFileObject file = jfm.getJavaFileForOutput(StandardLocation.CLASS_OUTPUT,
            cs.flatname.toString(), JavaFileObject.Kind.CLASS, cs.sourcefile);
    if (file instanceof FileObjects.FileBase && !alreadyCreated.contains(((FileObjects.FileBase)file).getFile())) {
        TreeLoader.dumpSymFile(jfm, jti, cs, classes, syms2trees);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:MultiPassCompileWorker.java

示例8: loadParamNames

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
@Override
public boolean loadParamNames(ClassSymbol clazz) {
    boolean contended = !attachTo(Thread.currentThread());
    try {
        assert DISABLE_CONFINEMENT_TEST || JavaSourceAccessor.getINSTANCE().isJavaCompilerLocked() || !contended;
        if (clazz != null) {
            JavadocHelper.TextStream page = JavadocHelper.getJavadoc(clazz, ALWAYS_ALLOW_JDOC_ARG_NAMES, null);
            if (page != null && (!page.isRemote() || !EventQueue.isDispatchThread())) {
                if (getParamNamesFromJavadocText(page, clazz)) {
                    return true;
                }
            }
            if (!DISABLE_ARTIFICAL_PARAMETER_NAMES) {
                fillArtificalParamNames(clazz);
                return true;
            }
        }

        return false;
    } finally {
        dettachFrom(Thread.currentThread());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:TreeLoader.java

示例9: fillArtificalParamNames

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
private void fillArtificalParamNames(final ClassSymbol clazz) {
    for (Symbol s : clazz.getEnclosedElements()) {
        if (s instanceof MethodSymbol) {
            MethodSymbol ms = (MethodSymbol) s;

            if (ms.getParameters().isEmpty()) {
                continue;
            }
            
            Set<String> usedNames = new HashSet<String>();
            
            for (VarSymbol vs : ms.getParameters()) {
                String name = JavaSourceAccessor.getINSTANCE().generateReadableParameterName(vs.asType().toString(), usedNames);

                vs.setName(clazz.name.table.fromString(name));
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TreeLoader.java

示例10: getAllValues

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
/**
 * Returns a map from element symbols to their values.
 * Includes all elements, whether explicit or defaulted.
 */
private Map<MethodSymbol, Attribute> getAllValues() {
    Map<MethodSymbol, Attribute> res =
        new LinkedHashMap<MethodSymbol, Attribute>();

    // First find the default values.
    ClassSymbol sym = (ClassSymbol) anno.type.tsym;
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol m = (MethodSymbol) e.sym;
            Attribute def = m.getDefaultValue();
            if (def != null)
                res.put(m, def);
        }
    }
    // Next find the explicit values, possibly overriding defaults.
    for (Pair<MethodSymbol, Attribute> p : anno.values)
        res.put(p.fst, p.snd);
    return res;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:AnnotationProxyMaker.java

示例11: 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

示例12: getClasses

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
/**
 * Return a list of all classes contained in this package, including
 * member classes of those classes, and their member classes, etc.
 */
private List<ClassDocImpl> getClasses(boolean filtered) {
    if (allClasses != null && !filtered) {
        return allClasses;
    }
    if (allClassesFiltered != null && filtered) {
        return allClassesFiltered;
    }
    ListBuffer<ClassDocImpl> classes = new ListBuffer<ClassDocImpl>();
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null) {
            ClassSymbol s = (ClassSymbol)e.sym;
            ClassDocImpl c = env.getClassDoc(s);
            if (c != null && !c.isSynthetic())
                c.addAllClasses(classes, filtered);
        }
    }
    if (filtered)
        return allClassesFiltered = classes.toList();
    else
        return allClasses = classes.toList();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:PackageDocImpl.java

示例13: overriddenType

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
/**
 * Return the type containing the method that this method overrides.
 * It may be a <code>TypeElement</code> or a <code>TypeParameterElement</code>.
 * @param method target
 * @return a type
 */
public TypeMirror overriddenType(ExecutableElement method) {
    if (utils.isStatic(method)) {
        return null;
    }
    MethodSymbol sym = (MethodSymbol)method;
    ClassSymbol origin = (ClassSymbol) sym.owner;
    for (com.sun.tools.javac.code.Type t = toolEnv.getTypes().supertype(origin.type);
            t.hasTag(com.sun.tools.javac.code.TypeTag.CLASS);
            t = toolEnv.getTypes().supertype(t)) {
        ClassSymbol c = (ClassSymbol) t.tsym;
        for (com.sun.tools.javac.code.Symbol sym2 : c.members().getSymbolsByName(sym.name)) {
            if (sym.overrides(sym2, origin, toolEnv.getTypes(), true)) {
                return t;
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:WorkArounds.java

示例14: computeDefaultSerializableFields

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
private void computeDefaultSerializableFields(DocEnv env,
                                              ClassSymbol def,
                                              ClassDocImpl cd) {
    for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.VAR) {
            VarSymbol f = (VarSymbol)e.sym;
            if ((f.flags() & Flags.STATIC) == 0 &&
                (f.flags() & Flags.TRANSIENT) == 0) {
                //### No modifier filtering applied here.
                FieldDocImpl fd = env.getFieldDoc(f);
                //### Add to beginning.
                //### Preserve order used by old 'javadoc'.
                fields.prepend(fd);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SerializedForm.java

示例15: visitType

import com.sun.tools.javac.code.Symbol.ClassSymbol; //导入依赖的package包/类
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Void visitType(TypeElement e, Void p) {
    if (isNonPrivate(e)) {
        PubApi prevApi = collectedApi;
        collectedApi = new PubApi();
        super.visitType(e, p);
        if (!isAnonymous(e)) {
            String name = ((ClassSymbol) e).flatname.toString();
            PubType t = new PubType(e.getModifiers(),
                                    name,
                                    //e.getQualifiedName().toString(),
                                    collectedApi);
            prevApi.types.put(t.fqName, t);
        }
        collectedApi = prevApi;
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:PubapiVisitor.java


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