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

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


    }

    @Override
    public Object visitImportFrom(ImportFrom node) throws Exception {
        NameTok moduleName = (NameTok) node.module;

        visitAlias(moduleName.id, node.names);
        return null;
    }
View Full Code Here


    }

    private void visitAlias(String prefix, aliasType[] names) {
        if (names != null && names.length > 0) {
            for (aliasType alias : names) {
                NameTok name = (NameTok) alias.name;
                NameTok asName = (NameTok) alias.asname;

                String realName = name.id;
                String aliasName = name.id;
                if (asName != null) {
                    aliasName = asName.id;
View Full Code Here

                name = NodeUtils.getNameFromNameTok((NameTok) (attributeToken).attr);
            } else if (token instanceof Name) {
                Name nameToken = (Name) token;
                name = nameToken.id;
            } else {
                NameTok nameTokToken = (NameTok) token;
                name = NodeUtils.getNameFromNameTok(nameTokToken);
            }

            String image;
            if (name.startsWith("__")) {
View Full Code Here

            tempFileAt.delete();
        }
    }

    private ClassDef createClassDef(String name) {
        return new ClassDef(new NameTok(name, NameTok.FunctionName), null, null, null, null, null, null);
    }
View Full Code Here

        fail("The token requested (" + req + ") was not found.");
        return null;
    }

    private FunctionDef createFuncDef(String metName) {
        return new FunctionDef(new NameTok(metName, NameTok.FunctionName), null, null, null, null);
    }
View Full Code Here

                            null, null, null, null, null, null, null);
                    if (useAnyArgs) {
                        Name name = new Name("self", Name.Store, false);
                        name.addSpecial(new SpecialStr(",", -1, -1), true);
                        functionArguments.args = new exprType[] { name };
                        functionArguments.vararg = new NameTok("args", NameTok.VarArg);
                        functionArguments.kwarg = new NameTok("kwargs", NameTok.KwArg);
                    }
                    //                System.out.println(tok.getRepresentation()+tok.getArgs());
                    FunctionDef functionDef = new FunctionDef(
                            new NameTok(tok.getRepresentation(), NameTok.FunctionName), functionArguments, null, null,
                            null);
                    cache.add(new FunctionDefAdapter(this.getModule(), null, functionDef, adapterPrefs));
                }
            }
        }
View Full Code Here

    public Object visitImportFrom(ImportFrom node) throws Exception {
        Object ret = super.visitImportFrom(node);
        //the import from will generate the tokens that go into the module namespace, but still, it needs to
        //create tokens that will not be used in code-analysis, but will be used in matching tokens
        //regarding its module.
        NameTok tokModName = (NameTok) node.module;
        for (String m : new FullRepIterable(tokModName.id)) {
            if (m.indexOf(".") == -1) {
                aliasType[] names = new aliasType[1];
                NameTok importNameTok = new NameTok(m, NameTok.ImportModule);

                importNameTok.beginLine = tokModName.beginLine;
                importNameTok.beginColumn = tokModName.beginColumn;

                names[0] = new aliasType(importNameTok, null);
View Full Code Here

            if (ast instanceof ImportFrom) {
                ImportFrom f = (ImportFrom) ast;
                //f.names may be empty if it is a wild import
                for (aliasType t : f.names) {
                    NameTok importName = NodeUtils.getNameForAlias(t);
                    String importRep = NodeUtils.getFullRepresentationString(importName);

                    if (importRep.equals(nameToFind)) {
                        ast = importName;
                        representation = importRep;
                        break;
                    }

                }

            } else if (ast instanceof Import) {
                representation = NodeUtils.getFullRepresentationString(ast);
                Import f = (Import) ast;
                NameTok importName = NodeUtils.getNameForRep(f.names, representation);
                if (importName != null) {
                    ast = importName;
                }

            } else {
View Full Code Here

        assertNull(funcDef.body[1]);
        Assign assign = (Assign) funcDef.body[0];
        assertEquals(1, assign.targets.length);
        Attribute attribute = (Attribute) assign.targets[0];
        NameTok attr = (NameTok) attribute.attr;
        assertEquals("ATTRIBUTE", attr.id.toString());
    }
View Full Code Here

        for (int i = 0; i < 3; i++) {
            Assign assign = (Assign) funcDef.body[i];
            assertEquals(1, assign.targets.length);
            Attribute attribute = (Attribute) assign.targets[0];
            NameTok attr = (NameTok) attribute.attr;
            assertEquals("ATTRIBUTE" + i, attr.id.toString());
        }
        assertNull(funcDef.body[3]);
    }
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.