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

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


            return;
        }
        List<ASTEntry> found = ScopeAnalysis.getLocalOccurrences(request.initialName, call);
        for (ASTEntry entry2 : found) {
            if (entry2.node instanceof NameTok) {
                NameTok name2 = (NameTok) entry2.node;
                if (name2.ctx == NameTok.KeywordName) {
                    ret.add(entry2);
                }
            }
        }
View Full Code Here


                "";

        Module node = (Module) parseLegalDocStr(s);
        ImportFrom f = (ImportFrom) node.body[0];
        assertEquals(f.level, 3);
        NameTok n = (NameTok) f.module;
        assertEquals(n.id, "");
        parseLegalDocStrWithoutTree(s);
    }
View Full Code Here

                        simpleNode);
                NameTokType funcName = ((FunctionDef) functionDefEntry.node).name;
                for (ASTEntry entry : attributeReferences) {
                    if (entry.node != funcName) {
                        if (entry.node instanceof NameTok) {
                            NameTok nameTok = (NameTok) entry.node;
                            if (nameTok.ctx == NameTok.ClassName) {
                                continue;
                            }
                        }
                        ret.add(entry);
View Full Code Here

    public PyAstFactory(AdapterPrefs adapterPrefs) {
        nodeHelper = new NodeHelper(adapterPrefs);
    }

    public FunctionDef createFunctionDef(String name) {
        FunctionDef functionDef = new FunctionDef(new NameTok(name, NameTok.FunctionName), null, null, null, null);
        return functionDef;
    }
View Full Code Here

        decoratorsType[] decs = null;
        keywordType[] keywords = null;
        exprType starargs = null;
        exprType kwargs = null;

        ClassDef def = new ClassDef(new NameTok(name, NameTok.ClassName), bases, body, decs, keywords, starargs, kwargs);
        return def;

    }
View Full Code Here

        Name name = new Name(s, Name.Load, false);
        return name;
    }

    public FunctionDef createSetterFunctionDef(String accessorName, String attributeName) {
        NameTok functionName = new NameTok(accessorName, NameTok.FunctionName);
        argumentsType args = createArguments(true, "value");
        stmtType[] body = createSetterBody(attributeName);

        return new FunctionDef(functionName, args, body, null, null);
    }
View Full Code Here

                null, null);
    }

    private stmtType[] createSetterBody(String attributeName) {
        Name self = new Name("self", Name.Load, true);
        NameTok name = new NameTok(nodeHelper.getPrivateAttr(attributeName), NameTok.Attrib);
        Attribute attribute = new Attribute(self, name, Attribute.Store);

        Name value = new Name("value", Name.Load, false);
        Assign assign = new Assign(new exprType[] { attribute }, value);
View Full Code Here

        List<String> splitted = StringUtils.split(attribute, '.');
        if (splitted.size() <= 1) {
            throw new RuntimeException("Cannot create attribute without dot access.");
        }
        if (splitted.size() == 2) {
            return new Attribute(new Name(splitted.get(0), Name.Load, false), new NameTok(splitted.get(1),
                    NameTok.Attrib), Attribute.Load);
        }
        //>2
        return new Attribute(createAttribute(FullRepIterable.getWithoutLastPart(attribute)), new NameTok(
                splitted.get(splitted.size() - 1), NameTok.Attrib), Attribute.Load);

    }
View Full Code Here

                exprType expr = args.defaults[i];
                if (expr != null) {
                    exprType name = params.get(i + diff);
                    if (name instanceof Name) {
                        removePositions.push(i + diff); //it's removed backwards, that's why it's a stack
                        keywords.add(new keywordType(new NameTok(((Name) name).id, NameTok.KeywordName), name, false));
                    } else {
                        Log.log("Expected: " + name + " to be a Name instance.");
                    }
                }
            }
            while (removePositions.size() > 0) {
                Integer pop = removePositions.pop();
                params.remove((int) pop);
            }
        }
        Call call;
        if (isClassMethod && params.size() > 0) {
            //We need to use the super() construct
            //Something as:
            //Expr[value=
            //    Call[func=
            //        Attribute[value=
            //            Call[func=Name[id=super, ctx=Load, reserved=false], args=[Name[id=Current, ctx=Load, reserved=false], Name[id=cls, ctx=Load, reserved=false]], keywords=[], starargs=null, kwargs=null],
            //        attr=NameTok[id=test, ctx=Attrib], ctx=Load],
            //    args=[], keywords=[], starargs=null, kwargs=null]
            //]

            exprType firstParam = params.remove(0);

            Call innerCall = createCall("super", currentClassName, NodeUtils.getRepresentationString(firstParam));
            Attribute attr = new Attribute(innerCall, new NameTok(NodeUtils.getRepresentationString(functionDef),
                    NameTok.Attrib), Attribute.Load);
            call = new Call(attr, params.toArray(new Name[params.size()]), keywords.toArray(new keywordType[keywords
                    .size()]), starargs, kwargs);

        } else {
View Full Code Here

TOP

Related Classes of org.python.pydev.parser.jython.ast.NameTok

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.