Package org.python.pydev.core.docutils

Examples of org.python.pydev.core.docutils.PySelection$TddPossibleMatches


                "b, #bar\n" +
                "c)\n"
                +
                "#we want it to appear in this line\n";
        Document document = new Document(strDoc);
        PySelection selection = new PySelection(document);
        assertEquals(4, selection.getLineAvailableForImport(false));
    }
View Full Code Here


                "b,\\\n" +
                "c\n"
                +
                "#we want it to appear in this line\n";
        Document document = new Document(strDoc);
        PySelection selection = new PySelection(document);
        assertEquals(4, selection.getLineAvailableForImport(false));
    }
View Full Code Here

                "def m1():\n" +
                "    testca\n"
                +
                "\n";
        Document document = new Document(strDoc);
        PySelection selection = new PySelection(document);
        assertEquals(3, selection.getLineAvailableForImport(false));
    }
View Full Code Here

                "__version__ = '$Revision: 86849 $'\n" +
                "def m1():\n" +
                "    testca\n" +
                "\n";
        Document document = new Document(strDoc);
        PySelection selection = new PySelection(document);
        assertEquals(1, selection.getLineAvailableForImport(false));
    }
View Full Code Here

        PySelection selection = new PySelection(document);
        assertEquals(1, selection.getLineAvailableForImport(false));
    }

    public void testSelectAll() {
        ps = new PySelection(doc, new TextSelection(doc, 0, 0));
        ps.selectAll(true);
        assertEquals(docContents, ps.getCursorLineContents() +
                "\n");
        assertEquals(docContents, ps.getSelectedText());

        ps = new PySelection(doc, new TextSelection(doc, 0, 9)); //first line selected
        ps.selectAll(true); //changes
        assertEquals(docContents, ps.getCursorLineContents() +
                "\n");
        assertEquals(docContents, ps.getSelectedText());

        ps = new PySelection(doc, new TextSelection(doc, 0, 9)); //first line selected
        ps.selectAll(false); //nothing changes
        assertEquals(ps.getLine(0), ps.getCursorLineContents());
        assertEquals(ps.getLine(0), ps.getSelectedText());
    }
View Full Code Here

    }

    public void testFullRep() throws Exception {
        String s = "v=aa.bb.cc()";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 2, 2));
        assertEquals("aa.bb.cc", ps.getFullRepAfterSelection());

        s = "v=aa.bb.cc";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 2, 2));
        assertEquals("aa.bb.cc", ps.getFullRepAfterSelection());

    }
View Full Code Here

    }

    public void testReplaceToSelection() throws Exception {
        String s = "vvvvppppaaaa";
        doc = new Document(s);
        ps = new PySelection(doc, 4);
        ps.replaceLineContentsToSelection("xxxx");
        assertEquals("xxxxppppaaaa", ps.getDoc().get());
    }
View Full Code Here

    }

    public void testGetInsideParentesis() throws Exception {
        String s = "def m1(self, a, b)";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 0, 0));
        List<String> insideParentesisToks = ps.getInsideParentesisToks(false).o1;
        assertEquals(2, insideParentesisToks.size());
        assertEquals("a", insideParentesisToks.get(0));
        assertEquals("b", insideParentesisToks.get(1));

        s = "def m1(self, a, b, )";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 0, 0));
        insideParentesisToks = ps.getInsideParentesisToks(false).o1;
        assertEquals(2, insideParentesisToks.size());
        assertEquals("a", insideParentesisToks.get(0));
        assertEquals("b", insideParentesisToks.get(1));

        s = "def m1(self, a, b=None)";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 0, 0));
        insideParentesisToks = ps.getInsideParentesisToks(true).o1;
        assertEquals(3, insideParentesisToks.size());
        assertEquals("self", insideParentesisToks.get(0));
        assertEquals("a", insideParentesisToks.get(1));
        assertEquals("b", insideParentesisToks.get(2));

        s = "def m1(self, a, b=None)";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 0, 0));
        insideParentesisToks = ps.getInsideParentesisToks(false).o1;
        assertEquals(2, insideParentesisToks.size());
        assertEquals("a", insideParentesisToks.get(0));
        assertEquals("b", insideParentesisToks.get(1));

        //Note: as Python dropped this support, so did PyDev: in this situation (b,c) is ignored.
        s = "def m1(self, a, (b,c) )";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 0, 0));
        insideParentesisToks = ps.getInsideParentesisToks(false).o1;
        assertEquals(1, insideParentesisToks.size());
        assertEquals("a", insideParentesisToks.get(0));

        s = "def m1(self, a, b, \nc,\nd )";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 0, 0));
        insideParentesisToks = ps.getInsideParentesisToks(false).o1;
        assertEquals(4, insideParentesisToks.size());
        assertEquals("a", insideParentesisToks.get(0));
        assertEquals("b", insideParentesisToks.get(1));
        assertEquals("c", insideParentesisToks.get(2));
        assertEquals("d", insideParentesisToks.get(3));

        s = "def m1(self, a=(1,2))";
        doc = new Document(s);
        ps = new PySelection(doc, new TextSelection(doc, 0, 0));
        insideParentesisToks = ps.getInsideParentesisToks(false).o1;
        assertEquals(1, insideParentesisToks.size());
        assertEquals("a", insideParentesisToks.get(0));

    }
View Full Code Here

    public void testGetLastIf() throws Exception {
        String s = "if False:\n" +
                "    print foo";
        doc = new Document(s);
        ps = new PySelection(doc, doc.getLength());
        assertEquals("if False:", ps.getPreviousLineThatStartsWithToken(PySelection.TOKENS_BEFORE_ELSE));

        s = "bar False:\n" +
                "    print foo";
        doc = new Document(s);
        ps = new PySelection(doc, doc.getLength());
        assertEquals(null, ps.getPreviousLineThatStartsWithToken(PySelection.TOKENS_BEFORE_ELSE));
    }
View Full Code Here

                "    print foo\n" +
                "  a = 10\n" + //as we're already in this indent level, an if in the same level has to be disconsidered!
                "  b = 20" +
                "";
        doc = new Document(s);
        ps = new PySelection(doc, doc.getLength());
        assertEquals("if True:", ps.getPreviousLineThatStartsWithToken(PySelection.TOKENS_BEFORE_ELSE));
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.core.docutils.PySelection$TddPossibleMatches

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.