Package com.sun.tools.javac.util

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


     * @param scope
     * @return
     */
    public MethodSymbol getSymbol(final JCMethodInvocation mi, CompilationUnitTree cut, Node n) {
        Symbol invTarget = getInvokationTarget(mi, cut, n);
        Name mName = getName(mi);
        java.util.List<Type> args = getArgTypes(mi.args, cut, n);
        java.util.List<Type> typeParams = getArgTypes(mi.typeargs, cut, n);
        if (invTarget instanceof VarSymbol) {//this, super,
            invTarget = invTarget.type.tsym;
        } else if (invTarget instanceof MethodSymbol) {
View Full Code Here


            }
            Symbol acc = getAccessor((JCFieldAccess) exp, cut, n);
            return getSymbol(((JCFieldAccess) exp).name, acc, cut, n);
        } else if (exp instanceof JCNewClass) {
            final JCNewClass nc = (JCNewClass) exp;
            final Name name = getName(nc.clazz);
            TypeElement cl = (TypeElement) getSymbol(cut, n, null, name, null);
            java.util.List<Type> args = getArgTypes(nc.args, cut, n);
            java.util.List<Type> typeParams = getArgTypes(nc.typeargs, cut, n);
            Symbol s = contains(cl.getEnclosedElements(), typeParams, elementUtils.getName(init), args);
            return s;
View Full Code Here

    }

    Collection<? extends Element> listgetSameNameEls(Iterable<? extends Element> list, Name varName, java.util.List<? extends Type> args) {
        Collection<Element> els = new ArrayList<Element>();
        for (Element e : list) {
            final Name elName;
            if (e instanceof ClassSymbol) {
                ClassSymbol ct = (ClassSymbol) e;
                elName = ct.getQualifiedName();
            } else {
                elName = (Name) e.getSimpleName();
            }
            if (elName.equals(varName) || e.getSimpleName().equals(varName)) {
                if (args != null) {//isEmpty means empty-args method
                    if (!e.getKind().equals(ElementKind.METHOD) && !e.getKind().equals(ElementKind.CONSTRUCTOR)) {
                        continue;
                    }
                }
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");
                args = toList(types);
View Full Code Here

     * @param accessor assumed to be accessible. TODO: get rid of assumption!
     * @param args
     * @return
     */
    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

        return mi;
    }

    JCMethodInvocation getReflectedFieldSetter(JCFieldAccess fa, final JCExpression value, final CompilationUnitTree cut, Node n) {
        final Name field = getFieldVar(fa.name);
        Symbol s = rs.getSymbol(value, cut, n);
        s = rs.getTypeSymbol(s);
        String typeName = s.name.toString();
        typeName = StringUtils.capitalize(typeName);
        JCMethodInvocation set = getMethodInvoc(field + ".set" + typeName, fa.selected, value);
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

        return new FunctionTemplateInstance(instantiate(args), startupCode.reverse());
    }

    private AJCVariableDecl extractArgument(AJCExpressionTree arg, Symbol owningContext) {
        Name tempName = NameFactory.getName();
        VarSymbol newSym = new VarSymbol(Flags.FINAL, tempName, arg.getNodeType(), owningContext);

        // Create a new temporary variable to hold this expression.
        AJCVariableDecl newDecl = treeMaker.VarDef(newSym, arg);
        return newDecl;
View Full Code Here

        // Unused ones will have a score of zero - so no further ones can be of use.
        if (usages.isEmpty()) {
            return;
        }

        Name tempName = NameFactory.getName();
        VarSymbol newSym = new VarSymbol(Flags.FINAL, tempName, key.wrappedNode.getNodeType(), owningContext);

        // Create a new temporary variable to hold this expression.
        AJCVariableDecl newDecl = treeMaker.VarDef(newSym, (AJCExpressionTree) treeCopier.copy(key.wrappedNode));
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.