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

Examples of org.python.pydev.editor.codecompletion.revisited.visitors.Definition


        if (modFound == null) {
            modFound = nature.getAstManager().getModule(moduleImported, nature, false);
        }
        if (modFound != null) {
            //ok, found it
            Definition definition = new Definition(1, 1, "", null, null, modFound);
            if (toRet != null) {
                toRet.add(definition);
            }
            return definition;
        }
View Full Code Here


                    if (module instanceof SourceModule) {
                        //this is just to get its scope...
                        SourceModule m = (SourceModule) module;
                        FindScopeVisitor scopeVisitor = m.getScopeVisitor(a.beginLine, a.beginColumn);
                        return new Definition(def.o1, def.o2, rep, a, scopeVisitor.scope, module);
                    } else {
                        //line, col
                        return new Definition(def.o1, def.o2, rep, a, new LocalScope(new FastStack<SimpleNode>(5)),
                                module);
                    }
                } else if (token instanceof ConcreteToken) {
                    //a contrete token represents a module
                    String modName = token.getParentPackage();
                    if (modName.length() > 0) {
                        modName += ".";
                    }
                    modName += token.getRepresentation();
                    IModule module = nature.getAstManager().getModule(modName, nature, true);
                    if (module == null) {
                        return null;
                    } else {
                        return new Definition(0 + 1, 0 + 1, "", null, null, module); // it is the module itself
                    }

                } else if (token instanceof CompiledToken) {
                    String parentPackage = token.getParentPackage();
                    FullRepIterable iterable = new FullRepIterable(parentPackage, true);
View Full Code Here

            try {
                defs = s.findDefinition(state, state.getLine() + 1, state.getCol() + 1, state.getNature());
                for (int i = 0; i < defs.length; i++) {
                    //go through all definitions found and make a merge of it...
                    Definition definition = defs[i];

                    if (state.getLine() == definition.line && state.getCol() == definition.col) {
                        //Check the module
                        if (definition.module != null && definition.module.equals(s)) {
                            //initial and final are the same
View Full Code Here

            String fPath = def.o1[0];
            if (fPath.equals("None")) {
                if (TRACE_COMPILED_MODULES) {
                    System.out.println("CompiledModule.findDefinition:" + token + " = None");
                }
                Definition[] definition = new Definition[] { new Definition(def.o2[0], def.o2[1], token, null, null,
                        this) };
                this.definitionsFoundCache.add(token, definition);
                return definition;
            }
            File f = new File(fPath);
            String foundModName = nature.resolveModule(f);
            String foundAs = def.o1[1];

            IModule mod;
            if (foundModName == null) {
                //this can happen in a case where we have a definition that's found from a compiled file which actually
                //maps to a file that's outside of the pythonpath known by Pydev.
                String n = FullRepIterable.getFirstPart(f.getName());
                mod = AbstractModule.createModule(n, f, nature, true);
            } else {
                mod = nature.getAstManager().getModule(foundModName, nature, true);
            }

            if (TRACE_COMPILED_MODULES) {
                System.out.println("CompiledModule.findDefinition: found at:" + mod.getName());
            }
            int foundLine = def.o2[0];
            if (foundLine == 0 && foundAs != null && foundAs.length() > 0 && mod != null
                    && state.canStillCheckFindSourceFromCompiled(mod, foundAs)) {
                //TODO: The nature (and so the grammar to be used) must be defined by the file we'll parse
                //(so, we need to know the system modules manager that actually created it to know the actual nature)
                IModule sourceMod = AbstractModule.createModuleFromDoc(mod.getName(), f,
                        new Document(FileUtils.getPyFileContents(f)), nature, true);
                if (sourceMod instanceof SourceModule) {
                    Definition[] definitions = (Definition[]) sourceMod.findDefinition(
                            state.getCopyWithActTok(foundAs), -1, -1, nature);
                    if (definitions.length > 0) {
                        this.definitionsFoundCache.add(token, definitions);
                        return definitions;
                    }
                }
            }
            if (mod == null) {
                mod = this;
            }
            int foundCol = def.o2[1];
            if (foundCol < 0) {
                foundCol = 0;
            }
            if (TRACE_COMPILED_MODULES) {
                System.out.println("CompiledModule.findDefinition: found compiled at:" + mod.getName());
            }
            Definition[] definitions = new Definition[] { new Definition(foundLine + 1, foundCol + 1, token, null,
                    null, mod) };
            this.definitionsFoundCache.add(token, definitions);
            return definitions;
        }
    }
View Full Code Here

        int len = definitions.length;
        for (int i = 0; i < len; i++) {
            IDefinition definition = definitions[i];
            boolean doAdd = true;
            if (definition instanceof Definition) {
                Definition d = (Definition) definition;
                doAdd = !findActualTokenFromImportFromDefinition(pythonNature, tok, selected, d, completionCache);
            }
            if (monitor != null && monitor.isCanceled()) {
                return;
            }
View Full Code Here

        FastStringBuffer temp = new FastStringBuffer();

        if (tokenAndQual != null && selected.size() > 0) {
            for (IDefinition d : selected) {
                Definition def = (Definition) d;

                SimpleNode astToPrint = null;
                if (def.ast != null) {
                    astToPrint = def.ast;
                    if ((astToPrint instanceof Name || astToPrint instanceof NameTok) && def.scope != null) {
View Full Code Here

                            //This was called only when isCall == false
                            //Ok, if it's not a call and we found a field, it's still possible that we may want to create
                            //a field if it wasn't found in the __init__
                            boolean foundInInit = false;
                            for (ItemPointer p : pointers) {
                                Definition definition = p.definition;
                                try {
                                    Object peek = definition.scope.getScopeStack().peek();
                                    if (peek instanceof FunctionDef) {
                                        FunctionDef functionDef = (FunctionDef) peek;
                                        String rep = NodeUtils.getRepresentationString(functionDef);
View Full Code Here

    public boolean checkCreationBasedOnFoundPointers(PyEdit edit, PySelection callPs, List<ICompletionProposal> ret,
            TddPossibleMatches possibleMatch, ItemPointer[] pointers, String methodToCreate, PySelection newSelection,
            IPythonNature nature) throws MisconfigurationException, Exception {
        CompletionCache completionCache = new CompletionCache();
        for (ItemPointer pointer : pointers) {
            Definition definition = pointer.definition;

            try {
                definition = rebaseToClassDefDefinition(nature, completionCache, definition, null);
            } catch (CompletionRecursionException e) {
                Log.log(e); //Just keep going.
View Full Code Here

    }

    private boolean checkInitCreation(PyEdit edit, PySelection callPs, ItemPointer[] pointers,
            List<ICompletionProposal> ret) {
        for (ItemPointer pointer : pointers) {
            Definition definition = pointer.definition;
            if (definition != null && definition.ast instanceof ClassDef) {
                ClassDef d = (ClassDef) definition.ast;
                ASTEntry initEntry = findInitInClass(d);

                if (initEntry == null) {
View Full Code Here

                    for (IDefinition iDefinition : selected) {

                        IModule module = iDefinition.getModule();
                        if (module.getFile() != null) {
                            Definition definition = (Definition) iDefinition;
                            File file = module.getFile();
                            if (definition.ast == null) {
                                //if we have no ast in the definition, it means the module itself was found (global scope)

                                //Add option to create class at the given module!
View Full Code Here

TOP

Related Classes of org.python.pydev.editor.codecompletion.revisited.visitors.Definition

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.