Package org.python.pydev.core

Examples of org.python.pydev.core.IToken


                }

                if (validTokensInAll.size() > 0) {
                    int len = tokens.size();
                    for (int i = 0; i < len; i++) {
                        IToken tok = tokens.get(i);
                        if (!validTokensInAll.contains(tok.getRepresentation())) {
                            tokens.remove(i);
                            //update the len and current pos to reflect the removal.
                            i--;
                            len--;
                        }
View Full Code Here


            }

            if (definition.ast instanceof ClassDef) {
                ClassDef d = (ClassDef) definition.ast;
                String fullName = NodeUtils.getRepresentationString(d) + "." + methodToCreate;
                IToken repInModule = nature.getAstManager().getRepInModule(definition.module, fullName, nature);
                if (repInModule != null) {
                    //System.out.println("Skipping creation of: " + fullName); //We found it, so, don't suggest it.
                    continue;
                }
View Full Code Here

        ICompletionProposal[] requestCompl = requestCompl(s, s.length(), -1, new String[] { "BB()",
                "assertEquals(first, second, msg)" });
        boolean found = false;
        for (ICompletionProposal p : requestCompl) {
            if (p.getDisplayString().equals("assertEquals(first, second, msg)")) {
                IToken element = ((PyLinkedModeCompletionProposal) p).getElement();
                assertEquals(element.getType(), IToken.TYPE_FUNCTION);
                found = true;
            }
        }
        assertTrue(found);
    }
View Full Code Here

    private void checkImportEntries(List<Tuple4<IToken, Integer, ASTEntry, Found>> ret, Set<IToken> f,
            List<Tuple3<Found, Integer, ASTEntry>> importEntries, int colDelta) {

        if (importEntries != null) {
            for (Tuple3<Found, Integer, ASTEntry> foundInFromModule : importEntries) {
                IToken generator = foundInFromModule.o1.getSingle().generator;

                Tuple4<IToken, Integer, ASTEntry, Found> tup3 = new Tuple4(generator,
                        colDelta > foundInFromModule.o2 ? colDelta : foundInFromModule.o2, foundInFromModule.o3,
                        foundInFromModule.o1);
View Full Code Here

        ArrayList<Tuple4<IToken, Integer, ASTEntry, Found>> complete = getCompleteTokenOccurrences();
        ArrayList<ASTEntry> ret = new ArrayList<ASTEntry>();

        for (Tuple4<IToken, Integer, ASTEntry, Found> tup : complete) {
            IToken token = tup.o1;
            if (!(token instanceof SourceToken)) { // we want only the source tokens for this module
                continue;
            }

            //if it is different, we have to make partial names
View Full Code Here

    @SuppressWarnings("unchecked")
    private void addImports(ArrayList<Tuple4<IToken, Integer, ASTEntry, Found>> ret,
            Map<String, List<Tuple3<Found, Integer, ASTEntry>>> map) {
        for (List<Tuple3<Found, Integer, ASTEntry>> fList : map.values()) {
            for (Tuple3<Found, Integer, ASTEntry> foundInFromModule : fList) {
                IToken generator = foundInFromModule.o1.getSingle().generator;

                Tuple4<IToken, Integer, ASTEntry, Found> tup3 = new Tuple4(generator, 0, foundInFromModule.o3,
                        foundInFromModule.o1);
                ret.add(tup3);
            }
View Full Code Here

            //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()) {
View Full Code Here

    public Object visitImportFrom(ImportFrom node) throws Exception {
        unhandled_node(node);
        try {

            if (AbstractVisitor.isWildImport(node)) {
                IToken wildImport = AbstractVisitor.makeWildImportToken(node, null, moduleName);

                ICompletionState state = CompletionStateFactory.getEmptyCompletionState(nature, this.completionCache);
                state.setBuiltinsGotten(true); //we don't want any builtins
                List<IToken> completionsForWildImport = new ArrayList<IToken>();
                if (nature.getAstManager().getCompletionsForWildImport(state, current, completionsForWildImport,
View Full Code Here

        ScopeItems m = scope.endScope(); //clear the last scope
        for (Iterator<Found> it = probablyNotDefined.iterator(); it.hasNext();) {
            Found n = it.next();

            final GenAndTok probablyNotDefinedFirst = n.getSingle();
            IToken tok = probablyNotDefinedFirst.tok;
            String rep = tok.getRepresentation();
            //we also get a last pass to the unused to see if they might have been defined later on the higher scope

            List<Found> foundItems = find(m, rep);
            boolean setUsed = false;
            for (Found found : foundItems) {
View Full Code Here

                        onAddToProbablyNotDefined(token, foundForProbablyNotDefined);
                    } else {
                        onAddUndefinedMessage(token, foundForProbablyNotDefined); //it is in the global scope, so, it is undefined.
                    }
                } else {
                    IToken tokenInNamesToIgnore = foundInNamesToIgnore.o1;
                    onFoundInNamesToIgnore(token, tokenInNamesToIgnore);
                }
            }
        } else if (checkIfIsValidImportToken) {
            //ok, it was found, but is it an attribute (and if so, are all the parts in the import defined?)
            //if it was an attribute (say xxx and initially it was xxx.foo, we will have to check if the token foo
            //really exists in xxx, if it was found as an import)
            try {
                if (foundAs.isImport() && !rep.equals(foundAsStr) && foundAs.importInfo != null
                        && foundAs.importInfo.wasResolved) {
                    //the foundAsStr equals the module resolved in the Found tok

                    IModule m = foundAs.importInfo.mod;
                    String tokToCheck;
                    if (foundAs.isWildImport()) {
                        tokToCheck = foundAsStr;

                    } else {
                        String tok = foundAs.importInfo.rep;
                        tokToCheck = rep.substring(foundAsStr.length() + 1);
                        if (tok.length() > 0) {
                            tokToCheck = tok + "." + tokToCheck;
                        }
                    }

                    for (String repToCheck : new FullRepIterable(tokToCheck)) {
                        int inGlobalTokens = m.isInGlobalTokens(repToCheck, nature, true, true, this.completionCache);

                        if (inGlobalTokens == IModule.NOT_FOUND) {
                            if (!isDefinitionUnknown(m, repToCheck)) {
                                //Check if there's some hasattr (if there is, we'll consider that the token which
                                //had the hasattr checked will actually have it).
                                Collection<IToken> interfaceForLocal = this.currentLocalScope.getInterfaceForLocal(
                                        foundAsStr, false, true);
                                boolean foundInHasAttr = false;
                                for (IToken iToken : interfaceForLocal) {
                                    if (iToken.getRepresentation().equals(repToCheck)) {
                                        foundInHasAttr = true;
                                        break;
                                    }
                                }

                                if (!foundInHasAttr) {
                                    IToken foundTok = findNameTok(token, repToCheck);
                                    onAddUndefinedVarInImportMessage(foundTok, foundAs);
                                }
                            }
                            break;//no need to keep checking once one is not defined
View Full Code Here

TOP

Related Classes of org.python.pydev.core.IToken

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.