Search in sources :

Example 1 with Names

use of com.sun.tools.javac.util.Names in project ceylon-compiler by ceylon.

the class AnnotationTypeDocImpl method elements.

/**
     * Returns the elements of this annotation type.
     * Returns an empty array if there are none.
     * Elements are always public, so no need to filter them.
     */
public AnnotationTypeElementDoc[] elements() {
    Names names = tsym.name.table.names;
    List<AnnotationTypeElementDoc> elements = List.nil();
    for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.MTH) {
            MethodSymbol s = (MethodSymbol) e.sym;
            elements = elements.prepend(env.getAnnotationTypeElementDoc(s));
        }
    }
    return elements.toArray(new AnnotationTypeElementDoc[elements.length()]);
}
Also used : Names(com.sun.tools.javac.util.Names) Scope(com.sun.tools.javac.code.Scope)

Example 2 with Names

use of com.sun.tools.javac.util.Names in project ceylon-compiler by ceylon.

the class ClassDocImpl method importedPackages.

/**
     * Get the list of packages declared as imported.
     * These are called "type-import-on-demand declarations" in the JLS.
     * This method is deprecated in the ClassDoc interface.
     *
     * @return an array of PackageDocImpl representing the imported packages.
     *
     * ###NOTE: the syntax supports importing all inner classes from a class as well.
     * @deprecated  Import declarations are implementation details that
     *          should not be exposed here.  In addition, this method's
     *          return type does not allow for all type-import-on-demand
     *          declarations to be returned.
     */
@Deprecated
public PackageDoc[] importedPackages() {
    // information is not available for binary classfiles
    if (tsym.sourcefile == null)
        return new PackageDoc[0];
    ListBuffer<PackageDocImpl> importedPackages = new ListBuffer<PackageDocImpl>();
    //### Add the implicit "import java.lang.*" to the result
    Names names = tsym.name.table.names;
    importedPackages.append(env.getPackageDoc(env.reader.enterPackage(names.java_lang)));
    Env<AttrContext> compenv = env.enter.getEnv(tsym);
    if (compenv == null)
        return new PackageDocImpl[0];
    for (JCTree t : compenv.toplevel.defs) {
        if (t.getTag() == JCTree.IMPORT) {
            JCTree imp = ((JCImport) t).qualid;
            if (TreeInfo.name(imp) == names.asterisk) {
                JCFieldAccess sel = (JCFieldAccess) imp;
                Symbol s = sel.selected.type.tsym;
                PackageDocImpl pdoc = env.getPackageDoc(s.packge());
                if (!importedPackages.contains(pdoc))
                    importedPackages.append(pdoc);
            }
        }
    }
    return importedPackages.toArray(new PackageDocImpl[importedPackages.length()]);
}
Also used : Names(com.sun.tools.javac.util.Names) JCImport(com.sun.tools.javac.tree.JCTree.JCImport) JCFieldAccess(com.sun.tools.javac.tree.JCTree.JCFieldAccess) Symbol(com.sun.tools.javac.code.Symbol) ListBuffer(com.sun.tools.javac.util.ListBuffer) JCTree(com.sun.tools.javac.tree.JCTree) AttrContext(com.sun.tools.javac.comp.AttrContext)

Example 3 with Names

use of com.sun.tools.javac.util.Names in project ceylon-compiler by ceylon.

the class ClassDocImpl method constructors.

/**
     * Return constructors in class.
     *
     * @param filter include only the included constructors if filter==true
     * @return an array of ConstructorDocImpl for representing the visible
     * constructors in this class.
     */
public ConstructorDoc[] constructors(boolean filter) {
    Names names = tsym.name.table.names;
    List<ConstructorDocImpl> constructors = List.nil();
    for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
        if (e.sym != null && e.sym.kind == Kinds.MTH && e.sym.name == names.init) {
            MethodSymbol s = (MethodSymbol) e.sym;
            if (!filter || env.shouldDocument(s)) {
                constructors = constructors.prepend(env.getConstructorDoc(s));
            }
        }
    }
    //### Cache constructors here?
    return constructors.toArray(new ConstructorDocImpl[constructors.length()]);
}
Also used : Names(com.sun.tools.javac.util.Names) Scope(com.sun.tools.javac.code.Scope)

Example 4 with Names

use of com.sun.tools.javac.util.Names in project ceylon-compiler by ceylon.

the class SerializedForm method mapSerialFieldTagImplsToFieldDocImpls.

/*
     * Associate serialField tag fieldName with FieldDocImpl member.
     * Note: A serialField tag does not have to map an existing field
     *       of a class.
     */
private void mapSerialFieldTagImplsToFieldDocImpls(FieldDocImpl spfDoc, DocEnv env, ClassSymbol def) {
    Names names = def.name.table.names;
    SerialFieldTag[] sfTag = spfDoc.serialFieldTags();
    for (int i = 0; i < sfTag.length; i++) {
        Name fieldName = names.fromString(sfTag[i].fieldName());
        // Look for a FieldDocImpl that is documented by serialFieldTagImpl.
        for (Scope.Entry e = def.members().lookup(fieldName); e.scope != null; e = e.next()) {
            if (e.sym.kind == Kinds.VAR) {
                VarSymbol f = (VarSymbol) e.sym;
                FieldDocImpl fdi = env.getFieldDoc(f);
                ((SerialFieldTagImpl) (sfTag[i])).mapToFieldDocImpl(fdi);
                break;
            }
        }
    }
}
Also used : Names(com.sun.tools.javac.util.Names) Scope(com.sun.tools.javac.code.Scope) VarSymbol(com.sun.tools.javac.code.Symbol.VarSymbol) Name(com.sun.tools.javac.util.Name)

Example 5 with Names

use of com.sun.tools.javac.util.Names in project ceylon-compiler by ceylon.

the class TypeVariableImpl method owner.

/**
     * Return the class, interface, method, or constructor within
     * which this type variable is declared.
     */
public ProgramElementDoc owner() {
    Symbol osym = type.tsym.owner;
    if ((osym.kind & Kinds.TYP) != 0) {
        return env.getClassDoc((ClassSymbol) osym);
    }
    Names names = osym.name.table.names;
    if (osym.name == names.init) {
        return env.getConstructorDoc((MethodSymbol) osym);
    } else {
        return env.getMethodDoc((MethodSymbol) osym);
    }
}
Also used : Names(com.sun.tools.javac.util.Names) MethodSymbol(com.sun.tools.javac.code.Symbol.MethodSymbol) Symbol(com.sun.tools.javac.code.Symbol) ClassSymbol(com.sun.tools.javac.code.Symbol.ClassSymbol)

Aggregations

Names (com.sun.tools.javac.util.Names)10 Scope (com.sun.tools.javac.code.Scope)8 Symbol (com.sun.tools.javac.code.Symbol)2 AttrContext (com.sun.tools.javac.comp.AttrContext)2 ClassSymbol (com.sun.tools.javac.code.Symbol.ClassSymbol)1 MethodSymbol (com.sun.tools.javac.code.Symbol.MethodSymbol)1 VarSymbol (com.sun.tools.javac.code.Symbol.VarSymbol)1 JavacFileManager (com.sun.tools.javac.file.JavacFileManager)1 ClassReader (com.sun.tools.javac.jvm.ClassReader)1 JCTree (com.sun.tools.javac.tree.JCTree)1 JCFieldAccess (com.sun.tools.javac.tree.JCTree.JCFieldAccess)1 JCImport (com.sun.tools.javac.tree.JCTree.JCImport)1 Context (com.sun.tools.javac.util.Context)1 ListBuffer (com.sun.tools.javac.util.ListBuffer)1 Name (com.sun.tools.javac.util.Name)1