Package org.python.pydev.editor.refactoring

Examples of org.python.pydev.editor.refactoring.RefactoringRequest


        //        from f1 import *
        //        print Class1

        String line = "print Class1";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "testrecwild/__init__.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 1, line.length());

        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(new File(TestDependent.TEST_PYSRC_LOC + "testrecwild/f2.py"), pointers[0].file);
View Full Code Here


        //        from someparent.somechild import configport config
        //        config.whateveryoulike()

        String line = "config.whateveryoulike()";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "otherparent/navigationtest.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 1, 0);

        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);
        if (pointers.length != 1) {
            for (ItemPointer pointer : pointers) {
                System.out.println(pointer);
View Full Code Here

        //      from testlib.unittest import TestCase
        //      print TestCase

        String line = "print TestCase";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "extendable/deepimport.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 1, line.length());

        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(new File(TestDependent.TEST_PYSRC_LOC + "testlib/unittest/testcase.py"), pointers[0].file);
View Full Code Here

    public void testSearchImport2() throws Exception {
        //import mod2
        //mod2.Foo
        String line = "mod2.Foo";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "extendable/searching/mod3.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 1, line.length());

        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(new File(TestDependent.TEST_PYSRC_LOC + "extendable/searching/mod1/foo.py"), pointers[0].file);
View Full Code Here

        //                print aa.static1() - line 4
        //                print aa.static2()       

        String line = "print aa.static1()";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "extendable/parameters.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 4, line.length());

        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(new File(TestDependent.TEST_PYSRC_LOC + "extendable/static.py"), pointers[0].file);
View Full Code Here

    public void testBuiltinSearch() throws Exception {
        //      import os
        String line = "import os";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "simpleosimport.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 0, line.length()); //find the os module

        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(new File(TestDependent.PYTHON_LIB + "os.py"), pointers[0].file);
View Full Code Here

    public void testBuiltinSearch2() throws Exception {
        //      import os.path.normpath
        String line = "import os.path.normpath";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "definitions/__init__.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 0, line.length()); //find the os.path.normpath func pos

        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        File linuxFile = new File(TestDependent.PYTHON_LIB + "posixpath.py");
View Full Code Here

        //    @staticmethod     
        //    def static2(self):
        //        pass
        String line = "    def static1(self):";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "extendable/static.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 3, line.length() - "1(self):".length()); //find the 'static1' method itself

        refactoringRequest.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_DEFINITION_IN_ADDITIONAL_INFO,
                false);
        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(file, pointers[0].file);
View Full Code Here

        //    @staticmethod     
        //    def static2(self):
        //        pass
        String line = "class TestStatic(object):";
        final File file = new File(TestDependent.TEST_PYSRC_LOC + "extendable/static.py");
        RefactoringRequest refactoringRequest = createRefactoringRequest(line, file);
        refactoringRequest.ps = new PySelection(refactoringRequest.getDoc(), 0, line.length()
                - "Static(object):".length()); //find the 'TestStatic' class itself

        refactoringRequest.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_DEFINITION_IN_ADDITIONAL_INFO,
                false);
        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(file, pointers[0].file);
View Full Code Here

    public void testOnSameName() throws Exception {
        String str = "" + "class Foo:\n" + "    def m1(self):\n" + //this line, col 9
                "        m1 = 10\n" + "        print m1\n" + "        print self.m1\n" + "";

        RefactoringRequest refactoringRequest = createRefactoringRequest(new Document(str), "foo", 1, 9);

        refactoringRequest.setAdditionalInfo(AstEntryRefactorerRequestConstants.FIND_DEFINITION_IN_ADDITIONAL_INFO,
                false);
        ItemPointer[] pointers = refactorer.findDefinition(refactoringRequest);

        assertEquals(1, pointers.length);
        assertEquals(1, pointers[0].start.line);
View Full Code Here

TOP

Related Classes of org.python.pydev.editor.refactoring.RefactoringRequest

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.