Package com.sun.tools.javac.util

Examples of com.sun.tools.javac.util.Name


            if (owner == null ||
                (owner.kind & (VAR | MTH)) != 0
                || (owner.kind == TYP && owner.type.tag == TYPEVAR)
                ) return name;
            char sep = owner.kind == TYP ? '$' : '.';
            Name prefix = owner.flatName();
            if (prefix == null || prefix == prefix.table.empty)
                return name;
            else return prefix.append(sep, name);
        }
View Full Code Here


    /**
     * Get package name.
     */
    public String qualifiedName() {
        Name fullname = sym.getQualifiedName();
        // Some bogus tests depend on the interned "" being returned.
        // See 6457276.
        return fullname.isEmpty() ? "" : fullname.toString();
    }
View Full Code Here

        ListBuffer<ClassDocImpl> importedClasses = new ListBuffer<ClassDocImpl>();

        Env<AttrContext> compenv = env.enter.getEnv(tsym);
        if (compenv == null) return new ClassDocImpl[0];

        Name asterisk = tsym.name.table.asterisk;
        for (JCTree t : compenv.toplevel.defs) {
            if (t.getTag() == JCTree.IMPORT) {
                JCTree imp = ((JCImport) t).qualid;
                if ((TreeInfo.name(imp) != asterisk) &&
                        (imp.type.tsym.kind & Kinds.TYP) != 0) {
View Full Code Here

        }
        java.util.List<? extends Element> enclosedElements = e.getEnclosedElements();
        boolean getInstanceFound = false;
        boolean instanceFound = false;
        Element instanceElement = null;
        Name getInstanceMethName;
        Name instanceVarName;
        boolean lazy = false;//default
        if (ann.getQualifiedName().toString().equals(Singleton.class.getCanonicalName())) {
            final Singleton singleton = e.getAnnotation(Singleton.class);
            lazy = singleton.lazy();
            getInstanceMethName = elementUtils.getName(singleton.getInstance());
            instanceVarName = elementUtils.getName(singleton.instance());
        } else {
            getInstanceMethName = elementUtils.getName(getInstance.class.getSimpleName());
            instanceVarName = elementUtils.getName(getInstance.class.getSimpleName());
        }
        for (final Element element : enclosedElements) {
            if (element.getAnnotation(instance.class) != null) {
                if (instanceFound == true) {
                    msgr.printMessage(Kind.ERROR, "Found multiple methods annotated with @instance while at most one must be annotated", e);
                }
                instanceFound = true;
                instanceElement = element;
                instanceVarName = elementUtils.getName(element.getSimpleName());
            }

            if (element.getAnnotation(getInstance.class) != null) {
                if (getInstanceFound == true) {
                    msgr.printMessage(Kind.ERROR, "Found multiple methods annotated with @getInstance while at most one must be annotated", e);
                }
                getInstanceFound = true;
            }
        }

        if (instanceFound) {
            VariableTree tree = (VariableTree) trees.getTree(instanceElement);
            ExpressionTree initializer = tree.getInitializer();
            if (initializer == null) {
                lazy = true;
            } else {
                lazy = false; //default
            }
        }


        final Name singletonClassName = elementUtils.getName(e.getSimpleName());

        JCCompilationUnit singletonCU = (JCCompilationUnit) trees.getPath(e).getCompilationUnit();
        JCMethodDecl defCon = null;
        JCExpression defConInit = null;
        for (JCTree def : singletonCU.defs) {
View Full Code Here

        return trees.isAccessible(n.scope, s, itd);
    }

    protected void reflect(Symbol s, final CompilationUnitTree cut, Node n, com.sun.tools.javac.util.List<JCExpression> args, JCBlock encBlock) {
        final java.util.List<? extends Symbol> params;
        final Name accesseeVarName;

        if (s instanceof MethodSymbol) {
            if (s.isConstructor()) {
                accesseeVarName = getConstructorVar(s.owner.name, ((MethodSymbol) s).params);
            } else {
View Full Code Here

        JCExpression[] types = getTypes(params);
        final com.sun.tools.javac.util.List<JCExpression> args;

        final JCExpression javaReflectMethField;
        final Name getterName;
        if (symbol instanceof MethodSymbol) {

            if (symbol.isConstructor()) {
                getterName = elementUtils.getName("getDeclaredConstructor");
                javaReflectMethField = getIdAfterImporting("java.lang.reflect.Constructor");
View Full Code Here

     * @param args
     * @param n
     * @return the method invocation of invoke
     */
    JCMethodInvocation getReflectedAccess(Symbol s, final CompilationUnitTree cut, JCExpression accessor, com.sun.tools.javac.util.List<JCExpression> args, Node n) {
        final Name getterName;
        final JCIdent fieldMethInitId;
        if (s instanceof MethodSymbol) {
            if (s.isConstructor()) {
                getterName = elementUtils.getName("newInstance");
                fieldMethInitId = tm.Ident(getConstructorVar(s.owner.name, ((MethodSymbol) s).params));
View Full Code Here

     * @param n
     * @param staticField
     * @return method invocation that sets the field accessed in fa
     */
    JCMethodInvocation getReflectedFieldSetter(JCFieldAccess fa, final JCExpression value, final CompilationUnitTree cut, boolean primitiveField, Node n, final boolean staticField) {
        final Name field = getFieldVar(fa.name);
        Symbol s = rs.getSymbol(value, cut, n);
        s = rs.getTypeSymbol(s);

        final String typeName;
        if (primitiveField) {
View Full Code Here

    List<Name> getNames(List<? extends Symbol> params) {
        List<Name> names = new ArrayList<Name>();
        for (Symbol symbol : params) {
            final Symbol ts = rs.getTypeSymbol(symbol);
            final Name n;
            if (ts instanceof ArrayType) {
                String toString = ((ArrayType) ts).getComponentType().toString();
                n = elementUtils.getName(toString + ts.getSimpleName());
            } else {
                n = ts.getSimpleName();
View Full Code Here

            if (owner == null) return name;
            if (((owner.kind != ERR)) &&
                ((owner.kind & (VAR | MTH)) != 0
                 || (owner.kind == TYP && owner.type.tag == TYPEVAR)
                 )) return name;
            Name prefix = owner.getQualifiedName();
            if (prefix == null || prefix == prefix.table.empty)
                return name;
            else return prefix.append('.', name);
        }
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.util.Name

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.