Package org.python.pydev.core

Examples of org.python.pydev.core.IModule


    public void testPreferCompiledOnBootstrap() throws BadLocationException, IOException, Exception {
        if (TestDependent.PYTHON_NUMPY_PACKAGES != null) {
            String s = "" +
                    "from extendable.bootstrap_dll import umath\n" +
                    "umath.";
            IModule module = nature.getAstManager().getModule("extendable.bootstrap_dll.umath", nature, true);
            assertTrue("Expected CompiledModule. Found: " + module.getClass(), module instanceof CompiledModule);
            //NOTE: The test can fail if numpy is not available (umath.pyd depends on numpy)
            requestCompl(s, s.length(), -1, new String[] { "less" });
        }
    }
View Full Code Here


    public void testPreferCompiledOnBootstrap2() throws BadLocationException, IOException, Exception {
        if (TestDependent.PYTHON_NUMPY_PACKAGES != null) {
            String s = "" +
                    "from extendable.bootstrap_dll.umath import ";
            IModule module = nature.getAstManager().getModule("extendable.bootstrap_dll.umath", nature, true);
            assertTrue(module instanceof CompiledModule);
            //NOTE: The test can fail if numpy is not available (umath.pyd depends on numpy)
            requestCompl(s, s.length(), -1, new String[] { "less" });
        }
    }
View Full Code Here

        String d = "" +
                "from javax import swing\n" +
                "print swing.JFrame()";

        Document doc = new Document(d);
        IModule module = AbstractModule.createModuleFromDoc("", null, doc, nature, true);
        Definition[] defs = (Definition[]) module.findDefinition(
                CompletionStateFactory.getEmptyCompletionState("swing.JFrame", nature, new CompletionCache()), 2, 7,
                nature);

        assertEquals(1, defs.length);
        assertEquals("", defs[0].value);
View Full Code Here

    public void testFind2() throws Exception {
        String d = "" +
                "import java.lang.Class";

        Document doc = new Document(d);
        IModule module = AbstractModule.createModuleFromDoc("", null, doc, nature, true);
        Definition[] defs = (Definition[]) module.findDefinition(
                CompletionStateFactory.getEmptyCompletionState("java.lang.Class", nature, new CompletionCache()), 1,
                20, nature);

        assertEquals(1, defs.length);
        assertEquals("", defs[0].value);
View Full Code Here

    public void testMod1() {
        Tuple<SimpleNode, Throwable> obj = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(getDoc1()),
                IPythonNature.GRAMMAR_PYTHON_VERSION_2_4));
        SimpleNode n = obj.o1;
        IModule module = AbstractModule.createModule(n);

        IToken[] globalTokens = module.getGlobalTokens();
        assertEquals(8, globalTokens.length); //C c D d a __file__ __name__
        compareReps(globalTokens, "__file__ __name__ __dict__ C c D d a");

        IToken[] wildImportedModules = module.getWildImportedModules();
        assertEquals(1, wildImportedModules.length); //m4
        compareReps(wildImportedModules, "m4");

        IToken[] tokenImportedModules = module.getTokenImportedModules();
        assertEquals(5, tokenImportedModules.length); //a1, xx, yy, aa
        compareReps(tokenImportedModules, "a1 xx yy aa m3");

        assertEquals("docstring for module", module.getDocString());

    }
View Full Code Here

                "other = method\n" +
                "";
        Tuple<SimpleNode, Throwable> obj = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(doc),
                IPythonNature.GRAMMAR_PYTHON_VERSION_2_4));
        SimpleNode n = obj.o1;
        IModule module = AbstractModule.createModule(n);

        IToken[] globalTokens = module.getGlobalTokens();
        assertEquals(5, globalTokens.length);
        compareReps(globalTokens, "__file__ __name__ __dict__ method other");
        int found = 0;
        for (IToken t : globalTokens) {
            if (t.getRepresentation().equals("method") || t.getRepresentation().equals("other")) {
View Full Code Here

                "other = another = method\n" +
                "";
        Tuple<SimpleNode, Throwable> obj = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(doc),
                IPythonNature.GRAMMAR_PYTHON_VERSION_2_4));
        SimpleNode n = obj.o1;
        IModule module = AbstractModule.createModule(n);

        IToken[] globalTokens = module.getGlobalTokens();
        assertEquals(6, globalTokens.length);
        compareReps(globalTokens, "__file__ __name__ __dict__ method other another");
        int found = 0;
        for (IToken t : globalTokens) {
            if (t.getRepresentation().equals("method") || t.getRepresentation().equals("other")
View Full Code Here

                "        remove_chars = [',', '(', ')', ':']\n" +
                "        for c in remove_chars:\n"
                +
                "            printed = printed.replace(c, '')\n" +
                "";
        IModule mod = SourceModule.createModuleFromDoc(null, new Document(str), nature);
        ICompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();
        PyRefactoringFindDefinition.findActualDefinition(null, mod, "printed.replace", selected, 8, 32, nature,
                completionCache);
        assertEquals(0, selected.size());
View Full Code Here

                +
                "        mantissa, _exponent_str = exp_format.split('e')\n"
                +
                "        mantissa = mantissa.strip().rjust(exp_format_digits + 3)\n" +
                "";
        IModule mod = SourceModule.createModuleFromDoc(null, new Document(str), nature);
        ICompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();
        PyRefactoringFindDefinition.findActualDefinition(null, mod, "mantissa.strip", selected, 6, 20, nature,
                completionCache);
        assertEquals(0, selected.size());
View Full Code Here

                "                parent = result\n"
                +
                "        return result\n" +
                "\n" +
                "";
        IModule mod = SourceModule.createModuleFromDoc(null, new Document(str), nature);
        ICompletionCache completionCache = new CompletionCache();
        ArrayList<IDefinition> selected = new ArrayList<IDefinition>();
        PyRefactoringFindDefinition.findActualDefinition(null, mod, "parent.find", selected, 10, 33, nature,
                completionCache);
        assertEquals(0, selected.size());
View Full Code Here

TOP

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

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.