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

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


                }
                return ret.toArray(new SimpleNode[0]);

            } else if (node instanceof ImportFrom) {
                ArrayList<SimpleNode> ret = new ArrayList<SimpleNode>();
                ImportFrom importToken = (ImportFrom) node;
                boolean found = false;
                for (int i = 0; i < importToken.names.length; i++) {
                    found = true;
                    aliasType aliasType = importToken.names[i];
View Full Code Here


            boolean allowForMultiple) {
        if (node instanceof Import) {
            return makeImportToken((Import) node, tokens, moduleName, allowForMultiple);
        }
        if (node instanceof ImportFrom) {
            ImportFrom i = (ImportFrom) node;
            if (isWildImport(i)) {
                makeWildImportToken(i, tokens, moduleName);
                return tokens;
            }
            return makeImportToken((ImportFrom) node, tokens, moduleName, allowForMultiple);
View Full Code Here

              Field generator = AbstractMessage.class.getDeclaredField("generator");
              generator.setAccessible(true);
              SourceToken token = (SourceToken)generator.get(message);
              SimpleNode ast = token.getAst();
              if (ast instanceof ImportFrom) {
                ImportFrom imprt = (ImportFrom)ast;
                //if it is a wild import, it starts on the module name
                if (!AbstractVisitor.isWildImport(imprt) &&
                    imprt.module instanceof NameTok)
                {
                  name = ((NameTok)imprt.module).id + '.' + name;
View Full Code Here

            SimpleNode ast = (sourceToken).getAst();

            String representation = null;

            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);
View Full Code Here

     */
    public void testNewRelativeImport() {
        setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5);
        String str = "from . import foo\n";
        Module mod = (Module) parseLegalDocStr(str);
        ImportFrom f = (ImportFrom) mod.body[0];
        assertEquals(1, f.level);
        assertEquals("", ((NameTok) f.module).id);
    }
View Full Code Here

    public void testNewRelativeImport2() {
        setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5);
        String str = "from ..bar import foo\n";
        Module mod = (Module) parseLegalDocStr(str);
        ImportFrom f = (ImportFrom) mod.body[0];
        assertEquals(2, f.level);
        assertEquals("bar", ((NameTok) f.module).id);
    }
View Full Code Here

    public void testNewRelativeImport3() {
        setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5);
        String str = "from ... import foo\n";
        Module mod = (Module) parseLegalDocStr(str);
        ImportFrom f = (ImportFrom) mod.body[0];
        assertEquals(3, f.level);
        assertEquals("", ((NameTok) f.module).id);
    }
View Full Code Here

    public void testNewRelativeImport4() {
        setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5);
        String str = "from ...bar import foo\n";
        Module mod = (Module) parseLegalDocStr(str);
        ImportFrom f = (ImportFrom) mod.body[0];
        assertEquals(3, f.level);
        assertEquals("bar", ((NameTok) f.module).id);
    }
View Full Code Here

                "from ... import a\n" +
                "..." +
                "";

        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

TOP

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

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.