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

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


                    "def func(arg, *, arg2=None):\n" +
                    "    arg2" +
                    "";

            Document doc = new Document(d);
            SourceModule module = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, true);
            Module ast = (Module) module.getAst();
            assertEquals(1, ast.body.length);
            ICompletionState emptyCompletionState = CompletionStateFactory.getEmptyCompletionState("arg2", nature,
                    new CompletionCache());
            Definition[] defs = (Definition[]) module.findDefinition(emptyCompletionState, 2, 7, nature);

            assertEquals(1, defs.length);
            assertEquals(1, defs[0].line);
            assertEquals(18, defs[0].col);
            assertSame(module, defs[0].module);
View Full Code Here


        assertEquals(originalRep, token.getOriginalRep());
    }

    private Iterator<ASTEntry> createModuleAndGetImports(String strDoc, Class classToGet) throws Exception {
        Document document = new Document(strDoc);
        SourceModule module = (SourceModule) AbstractModule.createModuleFromDoc(MODULE_NAME, null, document,
                CodeCompletionTestsBase.createStaticNature(), true);

        EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor();
        module.getAst().accept(visitor);
        Iterator<ASTEntry> iterator = visitor.getIterator(classToGet);
        return iterator;
    }
View Full Code Here

                col = import1.names[0].beginColumn - 1;
                PySelection ps = new PySelection(this.document, line, col);
                ScopeAnalyzerVisitorWithoutImports analyzerVisitorWithoutImports = new ScopeAnalyzerVisitorWithoutImports(
                        this.nature, this.moduleName, this.current, this.monitor, ps);

                SourceModule s = (SourceModule) this.current;
                s.getAst().accept(analyzerVisitorWithoutImports);
                analyzerVisitorWithoutImports.checkFinished();

                //now, let's get the token occurrences for the analyzer that worked without gathering the imports
                ArrayList<Tuple4<IToken, Integer, ASTEntry, Found>> completeTokenOccurrences = analyzerVisitorWithoutImports
                        .getCompleteTokenOccurrences();
View Full Code Here

        if (scope.getScopeStack().size() > 0) {
            simpleNode = (SimpleNode) scope.getScopeStack().peek();

        } else if (module instanceof SourceModule) {
            SourceModule m = (SourceModule) module;
            simpleNode = m.getAst();
        }

        if (simpleNode == null) {
            return new Tuple<SimpleNode, List<ASTEntry>>(null, new ArrayList<ASTEntry>());
        }
View Full Code Here

        assertContainsMsg("Unused parameter: show", msgs, 1);
        assertContainsMsg("Unused parameter: show", msgs, 2);
    }

    private IMessage[] analyzeDoc() {
        SourceModule mod;
        try {
            mod = (SourceModule) AbstractModule.createModuleFromDoc(null, null, doc, nature, true);
        } catch (MisconfigurationException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

                File f = info.getFile();
                String modName = info.getModuleName(tempBuf);
                ModulesKey modulesKey = new ModulesKey(modName, f);
                modules.add(modulesKey);

                SourceModule mod = (SourceModule) AbstractModule.createModule(modName, f, natureRefactoring, true);

                //also create the additional info so that it can be used for finds
                AbstractAdditionalTokensInfo additionalInfo = AdditionalProjectInterpreterInfo
                        .getAdditionalInfoForProject(natureRefactoring);
                additionalInfo.addAstInfo(mod.getAst(), modulesKey, false);
            }

            RefactorerFindReferences.FORCED_RETURN = iFiles;
        }
    }
View Full Code Here

                    new PyOpenAction().showInEditor(pyEdit, location, location);
                } else {
                    PyOpenAction pyOpenAction = new PyOpenAction();
                    IModule m = outlineEntry.model.module;
                    if (m instanceof SourceModule) {
                        SourceModule sourceModule = (SourceModule) m;
                        File file = sourceModule.getFile();
                        if (file != null) {
                            ItemPointer p = new ItemPointer(file, outlineEntry.node);
                            pyOpenAction.run(p);
                        }
                    }
View Full Code Here

        List<IToken> ret = visitor.getTokenOccurrences();
        return ret;
    }

    private ScopeAnalyzerVisitor doVisit(int line, int col) throws Exception {
        SourceModule mod = (SourceModule) AbstractModule.createModuleFromDoc(null, null, doc, nature, true);
        PySelection ps = new PySelection(doc, line, col);
        ScopeAnalyzerVisitor visitor = new ScopeAnalyzerVisitor(nature, "mod1", mod, new NullProgressMonitor(), ps);
        mod.getAst().accept(visitor);
        return visitor;
    }
View Full Code Here

TOP

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

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.