Package org.python.pydev.parser.jython.ast

Examples of org.python.pydev.parser.jython.ast.Name


    }

    private List<exprType> initCallArguments() {
        List<exprType> argsList = new ArrayList<exprType>();
        for (String parameter : callParameters) {
            argsList.add(new Name(parameter, Name.Load, false));
        }
        return argsList;
    }
View Full Code Here


        return argsList;
    }

    private exprType createCallAttribute() {
        if (this.offsetAdapter instanceof IClassDefAdapter) {
            return new Attribute(new Name("self", Name.Load, false), new NameTok(this.methodName, NameTok.Attrib),
                    Attribute.Load);
        } else {
            return new Name(this.methodName, Name.Load, false);
        }
    }
View Full Code Here

        for (SimpleAdapter adapter : before) {
            SimpleNode astNode = adapter.getASTNode();
            String id;
            if (astNode instanceof Name) {
                Name variable = (Name) astNode;
                id = variable.id;
            } else if (astNode instanceof NameTok) {
                NameTok variable = (NameTok) astNode;
                id = variable.id;
            } else {
View Full Code Here

    private void deduceReturns(List<SimpleAdapter> after, List<SimpleAdapter> selected) {
        for (SimpleAdapter adapter : after) {
            SimpleNode astNode = adapter.getASTNode();
            String id;
            if (astNode instanceof Name) {
                Name variable = (Name) astNode;
                id = variable.id;
            } else if (astNode instanceof NameTok) {
                NameTok variable = (NameTok) astNode;
                id = variable.id;
            } else {
View Full Code Here

     */
    private boolean isUsed(String var, List<SimpleAdapter> scopeVariables) {
        for (SimpleAdapter adapter : scopeVariables) {
            SimpleNode astNode = adapter.getASTNode();
            if (astNode instanceof Name) {
                Name scopeVar = (Name) astNode;
                if ((scopeVar.ctx == Name.Load || scopeVar.ctx == Name.AugLoad) && scopeVar.id.equals(var)) {
                    return true;
                }
            }
            //Note: NameTok are always only in store context.
View Full Code Here

        // must traverse all variables, because a
        // variable may be used in other context!
        for (SimpleAdapter adapter : scopeVariables) {
            SimpleNode astNode = adapter.getASTNode();
            if (astNode instanceof Name) {
                Name scopeVar = (Name) astNode;
                if (scopeVar.id.equals(var)) {
                    isStored = (scopeVar.ctx != Name.Load && scopeVar.ctx != Name.AugLoad);
                }
            } else if (astNode instanceof NameTok) {
                NameTok scopeVar = (NameTok) astNode;
View Full Code Here

            case JJTFILE_INPUT:
                ret = new Module(null);
                break;

            case JJTFALSE:
                ret = new Name("False", Name.Load, true);
                break;

            case JJTTRUE:
                ret = new Name("True", Name.Load, true);
                break;

            case JJTNONE:
                ret = new Name("None", Name.Load, true);
                break;

            case JJTNAME:
            case JJTDOTTED_NAME:
                //the actual name will be set during the parsing (token image) -- see Name construct
                ret = new Name(null, Name.Load, false);
                break;

            case JJTNUM://the actual number will be set during the parsing (token image) -- see Num construct
                ret = new Num(null, -1, null);
                break;
View Full Code Here

                Delete d = (Delete) stack.popNode();
                d.targets = exprs;
                return d;

            case JJTDOTTED_NAME:
                Name name = (Name) n;
                FastStringBuffer sb = tempBuffer.clear();
                for (int i = 0; i < arity; i++) {
                    if (i > 0) {
                        sb.insert(0, '.');
                    }
                    Name name0 = (Name) stack.popNode();
                    sb.insert(0, name0.id);
                    addSpecials(name0, name);
                    //we have to set that, because if we later add things to the previous Name, we will now want it to be added to
                    //the new name (comments will only appear later and may be added to the previous name -- so, we replace the previous
                    //name specials list).
View Full Code Here

        //addOwnArguments
        for (INodeAdapter adapter1 : attributes) {
            argsNames.add(nodeHelper.getPublicAttr(adapter1.getName()));
        }
        List<exprType> argsExprList = new ArrayList<exprType>();
        Name selfArg = new Name(NodeHelper.KEYWORD_SELF, Name.Param, false);
        argsExprList.add(selfArg);
        for (String parameter : argsNames) {
            argsExprList.add(new Name(parameter.trim(), Name.Param, false));
        }

        exprType[] argsExpr = argsExprList.toArray(new exprType[0]);
        argumentsType args = new argumentsType(argsExpr, varArg, kwArg, null, null, null, null, null, null, null);

        //constructorCalls
        List<stmtType> body = new ArrayList<stmtType>();
        for (IClassDefAdapter base : bases) {
            Expr init = extractConstructorInit(base);
            if (init != null) {
                body.add(init);
            }
        }

        //initAttributes
        for (INodeAdapter adapter : attributes) {
            exprType target = new Attribute(new Name(NodeHelper.KEYWORD_SELF, Name.Load, false), new NameTok(
                    adapter.getName(), NameTok.Attrib), Attribute.Store);
            Assign initParam1 = new Assign(new exprType[] { target }, new Name(nodeHelper.getPublicAttr(adapter
                    .getName()), Name.Load, false));
            Assign initParam = initParam1;
            body.add(initParam);
        }
View Full Code Here

    private Expr extractConstructorInit(IClassDefAdapter base) {
        FunctionDefAdapter init = base.getFirstInit();
        if (init != null) {
            if (!init.getArguments().hasOnlySelf()) {
                Attribute classInit = new Attribute(new Name(moduleAdapter.getBaseContextName(this.classAdapter,
                        base.getName()), Name.Load, false), new NameTok(NodeHelper.KEYWORD_INIT, NameTok.Attrib),
                        Attribute.Load);
                List<exprType> constructorParameters = init.getArguments().getSelfFilteredArgs();

                Name selfArg = new Name(NodeHelper.KEYWORD_SELF, Name.Load, false);
                constructorParameters.add(0, selfArg);

                exprType[] argExp = constructorParameters.toArray(new exprType[0]);
                Name varArg = null;
                Name kwArg = null;

                if (init.getArguments().hasVarArg()) {
                    varArg = new Name(ARGS, Name.Load, false);
                }

                if (init.getArguments().hasKwArg()) {
                    kwArg = new Name(KWARGS, Name.Load, false);
                }

                Call initCall = new Call(classInit, argExp, null, varArg, kwArg);
                return new Expr(initCall);
            }
View Full Code Here

TOP

Related Classes of org.python.pydev.parser.jython.ast.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.