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

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


        //ok, it is an import... (can only be a source token)
        SourceToken s = (SourceToken) generator;

        SimpleNode ast = s.getAst();
        if (ast instanceof ImportFrom) {
            ImportFrom i = (ImportFrom) ast;
            //if it is a wild import, it starts on the module name
            if (AbstractVisitor.isWildImport(i)) {
                return i.module.beginLine;
            } else {
                //no wild import, let's check the 'as name'
View Full Code Here


        //ok, it is an import... (can only be a source token)
        SourceToken s = (SourceToken) generator;

        SimpleNode ast = s.getAst();
        if (ast instanceof ImportFrom) {
            ImportFrom i = (ImportFrom) ast;
            //if it is a wild import, it starts on the module name
            if (AbstractVisitor.isWildImport(i)) {
                return i.module.beginColumn;
            } else {
                //no wild import, let's check the 'as name'
View Full Code Here

            SourceToken s = (SourceToken) generator;

            SimpleNode ast = s.getAst();

            if (ast instanceof ImportFrom) {
                ImportFrom i = (ImportFrom) ast;
                //ok, now, this depends on the name
                NameTok it = getNameForRepresentation(i, shortMessage, true);
                if (it != null) {
                    endCol = it.beginColumn + shortMessage.length();
                    return endCol;
View Full Code Here

            } else if (astNode instanceof Import) {
                Import importNode = (Import) astNode;
                isStored = checkNames(var, importNode.names);

            } else if (astNode instanceof ImportFrom) {
                ImportFrom importFrom = (ImportFrom) astNode;
                isStored = checkNames(var, importFrom.names);
            }

            if (isStored) {
                break;
View Full Code Here

                nT.beginLine = temporaryToken.getBeginLine();
            } else {
                Log.log("Expected to find 'from' token as the current temporary token (begin col/line can be wrong)!");
            }
        }
        return new ImportFrom((NameTokType) nT, aliastL.toArray(new aliasType[0]), 0);
    }
View Full Code Here

        if (tok.length() > 0) {
            IToken sourceToken = modTok.o3;
            if (sourceToken instanceof SourceToken) {
                SourceToken sourceToken2 = (SourceToken) sourceToken;
                if (sourceToken2.getAst() instanceof ImportFrom) {
                    ImportFrom importFrom = (ImportFrom) sourceToken2.getAst();
                    if (importFrom.names.length > 0 && importFrom.names[0].asname != null) {
                        String originalRep = sourceToken.getOriginalRep();
                        tokForSearchInOtherModule = FullRepIterable.getLastPart(originalRep);
                    }
                }
View Full Code Here

        IPythonNature nature = state.getNature();
        if (importedModule instanceof SourceToken) {
            SourceToken token = (SourceToken) importedModule;

            if (token.isImportFrom()) {
                ImportFrom importFrom = (ImportFrom) token.getAst();
                int level = importFrom.level;
                if (level > 0) {
                    //ok, it must be treated as a relative import
                    //ok, it is the import added on python 2.5 (from .. import xxx)
View Full Code Here

        if (v instanceof Expr) {
            Expr expr = (Expr) v;
            v = expr.value;
        }
        if (v instanceof ImportFrom) {
            ImportFrom f = (ImportFrom) v;
            FindLastLineVisitor findLastLineVisitor = new FindLastLineVisitor();
            try {
                f.accept(findLastLineVisitor);
                SimpleNode lastNode = findLastLineVisitor.getLastNode();
                ISpecialStr lastSpecialStr = findLastLineVisitor.getLastSpecialStr();
                if (lastSpecialStr != null && lastSpecialStr.toString().equals(")")) {
                    //it was an from xxx import (euheon, utehon)
                    return lastSpecialStr.getBeginLine();
                } else {
                    return lastNode.beginLine;
                }
            } catch (Exception e) {
                Log.log(e);
            }
        }
        if (v instanceof Import) {
            Import f = (Import) v;
            FindLastLineVisitor findLastLineVisitor = new FindLastLineVisitor();
            try {
                f.accept(findLastLineVisitor);
                SimpleNode lastNode = findLastLineVisitor.getLastNode();
                return lastNode.beginLine;
            } catch (Exception e) {
                Log.log(e);
            }
View Full Code Here

                target = (exprType) stack.popNode();
                ctx.setStore(target);
                return new Comprehension(target, iter, ifs);
            case JJTIMPORTFROM:
                aliasType[] aliases = makeAliases(arity - 1);
                return new ImportFrom(makeName(NameTok.ImportModule), aliases, 0); //relative import is always level 0 here (only actually added on version 25)

            default:
                Log.log("Error at TreeBuilder: default not treated:" + n.getId());
                return null;
        }
View Full Code Here

            retVal.deleteLast();
            return retVal.toString();

        } else if (astThis.node instanceof ImportFrom) {
            // from wxPython.wx import *
            ImportFrom importToken = (ImportFrom) astThis.node;
            StringBuffer modules = new StringBuffer();
            for (int i = 0; i < importToken.names.length; i++) {
                aliasType aliasType = importToken.names[i];

                //as ...
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.