Package org.python.pydev.editor.codecompletion.revisited.modules

Examples of org.python.pydev.editor.codecompletion.revisited.modules.SourceToken


        SimpleNode simpleNode = iterator.next().node;
        List<IToken> toks = AbstractVisitor.makeImportToken(simpleNode, new ArrayList<IToken>(), MODULE_NAME, true);
        assertEquals(2, toks.size());

        SourceToken token = (SourceToken) toks.get(0);
        checkIt(simpleNode, token, "path", "os.path", "os.path");

        token = (SourceToken) toks.get(1);
        checkIt(simpleNode, token, "notDefined", "os.notDefined", "os.notDefined");
    }
View Full Code Here


        SimpleNode simpleNode = iterator.next().node;
        List<IToken> toks = AbstractVisitor.makeImportToken(simpleNode, new ArrayList<IToken>(), MODULE_NAME, true);
        assertEquals(2, toks.size());

        SourceToken token = (SourceToken) toks.get(0);
        checkIt(simpleNode, token, "tt", "os.path", "os.path");

        token = (SourceToken) toks.get(1);
        checkIt(simpleNode, token, "aa", "os.notDefined", "os.notDefined");
    }
View Full Code Here

        SimpleNode simpleNode = iterator.next().node;
        List<IToken> toks = AbstractVisitor.makeImportToken(simpleNode, new ArrayList<IToken>(), MODULE_NAME, true);
        assertEquals(1, toks.size());

        SourceToken token = (SourceToken) toks.get(0);
        checkIt(simpleNode, token, "os.path", "os.path", "os.path");
    }
View Full Code Here

        SimpleNode simpleNode = iterator.next().node;
        List<IToken> toks = AbstractVisitor.makeImportToken(simpleNode, new ArrayList<IToken>(), "some.dotted.name",
                true);
        assertEquals(1, toks.size());

        SourceToken token = (SourceToken) toks.get(0);
        checkIt(simpleNode, token, "os.path", "some.dotted.os.path", "os.path");
    }
View Full Code Here

        }

        public Collection<IToken> getCompletionsForTokenWithUndefinedType(ICompletionState state,
                ILocalScope localScope, Collection<IToken> interfaceForLocal) {
            ArrayList<IToken> ret = new ArrayList<IToken>();
            ret.add(new SourceToken(null, "bar", null, null, null, IToken.TYPE_ATTR));
            return ret;
        }
View Full Code Here

            try {
                if (!(tuple3.o1 instanceof SourceToken)) {
                    continue;
                }

                SourceToken tok = (SourceToken) tuple3.o1;
                SimpleNode ast = tok.getAst();
                int line = 0;
                int col = 0;
                if (!(ast instanceof Import)) {
                    continue;
                }
View Full Code Here

            if (!(token instanceof SourceToken)) { // we want only the source tokens for this module
                continue;
            }

            //if it is different, we have to make partial names
            SourceToken sourceToken = (SourceToken) tup.o1;
            SimpleNode ast = (sourceToken).getAst();

            String representation = null;

            if (ast instanceof ImportFrom) {
View Full Code Here

        List<IToken> builtinCompletions = nature.getAstManager().getBuiltinCompletions(completionState,
                new ArrayList<IToken>());

        if (moduleName != null && moduleName.endsWith("__init__")) {
            //__path__ should be added to modules that have __init__
            builtinCompletions.add(new SourceToken(new Name("__path__", Name.Load, false), "__path__", "", "",
                    moduleName));
        }

        for (IToken t : builtinCompletions) {
            Found found = makeFound(t);
View Full Code Here

    /**
     * used so that the token is added to the names to ignore...
     */
    protected void addToNamesToIgnore(SimpleNode node, boolean finishClassScope, boolean checkBuiltins) {
        SourceToken token = AbstractVisitor.makeToken(node, "");

        if (checkBuiltins) {
            if (checkCurrentScopeForAssignmentsToBuiltins()) {
                String rep = token.getRepresentation();
                if (builtinTokens.contains(rep)) {
                    // Overriding builtin...
                    onAddAssignmentToBuiltinMessage(token, rep);
                }
            }
        }

        ScopeItems currScopeItems = scope.getCurrScopeItems();

        Found found = new Found(token, token, scope.getCurrScopeId(), scope.getCurrScopeItems());
        com.aptana.shared_core.structure.Tuple<IToken, Found> tup = new com.aptana.shared_core.structure.Tuple<IToken, Found>(token, found);
        addToNamesToIgnore(token, currScopeItems, tup);

        //after adding it to the names to ignore, let's see if there is someone waiting for this declaration
        //in the 'probably not defined' stack.
        for (Iterator<Found> it = probablyNotDefined.iterator(); it.hasNext();) {
            Found n = it.next();

            GenAndTok single = n.getSingle();
            int foundScopeType = single.scopeFound.getScopeType();
            //ok, if we are in a scope method, we may not get things that were defined in a class scope.
            if (((foundScopeType & Scope.ACCEPTED_METHOD_AND_LAMBDA) != 0)
                    && scope.getCurrScopeItems().getScopeType() == Scope.SCOPE_TYPE_CLASS) {
                continue;
            }
            IToken tok = single.tok;
            String rep = tok.getRepresentation();
            if (rep.equals(token.getRepresentation())) {
                //found match in names to ignore...

                if (finishClassScope && foundScopeType == Scope.SCOPE_TYPE_CLASS
                        && scope.getCurrScopeId() < single.scopeFound.getScopeId()) {
                    it.remove();
View Full Code Here

    @Override
    public Object visitNameTok(NameTok nameTok) throws Exception {
        unhandled_node(nameTok);
        if (nameTok.ctx == NameTok.VarArg || nameTok.ctx == NameTok.KwArg) {

            SourceToken token = AbstractVisitor.makeToken(nameTok, moduleName);
            scope.addToken(token, token, (nameTok).id);
            if (checkCurrentScopeForAssignmentsToBuiltins()) {
                if (builtinTokens.contains(token.getRepresentation())) {
                    // Overriding builtin...
                    onAddAssignmentToBuiltinMessage(token, token.getRepresentation());
                }
            }
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.editor.codecompletion.revisited.modules.SourceToken

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.