[Pydev-cvs] org.python.pydev/PySrc test_pyserver.py,1.7,1.8 pycompletionserver.py,1.10,1.11 refactor
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2004-09-20 19:09:36
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11446/PySrc Modified Files: test_pyserver.py pycompletionserver.py refactoring.py simpleinspect.py test_refactoring.py Log Message: Changed search for bicycle repair man search and added a refactor view to show which files are modified. Index: pycompletionserver.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/pycompletionserver.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pycompletionserver.py 17 Sep 2004 19:22:04 -0000 1.10 --- pycompletionserver.py 20 Sep 2004 19:08:41 -0000 1.11 *************** *** 22,26 **** MSG_CHANGE_DIR = '@@CHANGE_DIR:' MSG_OK = '@@MSG_OK_END@@' ! MSG_REFACTOR = '@@REFACTOR' MSG_PROCESSING = '@@PROCESSING_END@@' MSG_PROCESSING_PROGRESS = '@@PROCESSING:%sEND@@' --- 22,26 ---- MSG_CHANGE_DIR = '@@CHANGE_DIR:' MSG_OK = '@@MSG_OK_END@@' ! MSG_BIKE = '@@BIKE' MSG_PROCESSING = '@@PROCESSING_END@@' MSG_PROCESSING_PROGRESS = '@@PROCESSING:%sEND@@' *************** *** 179,184 **** returnMsg = MSG_OK ! elif data.startswith(MSG_REFACTOR): ! data = data.replace(MSG_REFACTOR, '') data = urllib.unquote_plus(data) returnMsg = refactoring.HandleRefactorMessage(data, keepAliveThread) --- 179,184 ---- returnMsg = MSG_OK ! elif data.startswith(MSG_BIKE): ! data = data.replace(MSG_BIKE, '') data = urllib.unquote_plus(data) returnMsg = refactoring.HandleRefactorMessage(data, keepAliveThread) Index: simpleinspect.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/simpleinspect.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** simpleinspect.py 20 Sep 2004 12:46:07 -0000 1.3 --- simpleinspect.py 20 Sep 2004 19:08:41 -0000 1.4 *************** *** 7,10 **** d = dict() d['__eraseThisTips'] = [] ! exec __eraseThisV in d return d['__eraseThisTips'] --- 7,11 ---- d = dict() d['__eraseThisTips'] = [] ! dGlobals = dict() #we don't want the globals ! exec __eraseThisV in dGlobals, d return d['__eraseThisTips'] Index: test_refactoring.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/test_refactoring.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_refactoring.py 16 Sep 2004 15:27:25 -0000 1.2 --- test_refactoring.py 20 Sep 2004 19:08:41 -0000 1.3 *************** *** 104,111 **** self.assertEquals(getRenameRefactored(), contents) ! if __name__ == '__main__': ! unittest.main() --- 104,137 ---- self.assertEquals(getRenameRefactored(), contents) + def testFind(self): + r = refactoring.Refactoring() + s = r.findDefinition(FILE, 7+1, 4) ! s = s.replace('[(','').replace(')]','').split(',') ! self.assert_( s[0].endswith('temporary_file.py')) ! self.assertEquals('2', s[1]) #line ! self.assertEquals('6', s[2]) #col ! self.assertEquals('100', s[3]) #accuracy ! ! createFile(FILE, getFindFile()) ! s = r.findDefinition(FILE, 5+1, 2) ! s1 = r.findDefinition(FILE, 5+1, 3) ! s2 = r.findDefinition(FILE, 5+1, 4) ! self.assert_(s == s1 == s2) + def getFindFile(): + s = \ + ''' + class C: + def aaa(self): + return 0 + c = C() + c.aaa() + ''' + return s + + if __name__ == '__main__': + # unittest.main() + unittest.TestMethod(Test, 'Test.testFind') Index: test_pyserver.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/test_pyserver.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_pyserver.py 17 Sep 2004 17:35:55 -0000 1.7 --- test_pyserver.py 20 Sep 2004 19:08:41 -0000 1.8 *************** *** 71,80 **** #now that we have the connections all set up, check the code completion messages. ! msg = urllib.quote('import math\n') sToWrite.send('@@GLOBALS:%sEND@@'%msg) #only 1 global should be returned: math itself. completions = self.readMsg() ! msg = urllib.quote('This module is always available. It provides access to the\n'\ 'mathematical functions defined by the C standard.') self.assertEquals('@@COMPLETIONS((math,%s))END@@'%msg, --- 71,80 ---- #now that we have the connections all set up, check the code completion messages. ! msg = urllib.quote_plus('import math\n') sToWrite.send('@@GLOBALS:%sEND@@'%msg) #only 1 global should be returned: math itself. completions = self.readMsg() ! msg = urllib.quote_plus('This module is always available. It provides access to the\n'\ 'mathematical functions defined by the C standard.') self.assertEquals('@@COMPLETIONS((math,%s))END@@'%msg, *************** *** 82,91 **** ! msg1 = urllib.quote('math') ! msg2 = urllib.quote('import math\n') #check token msg. sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' % (msg1, msg2)) completions = self.readMsg() - self.assert_('@@COMPLETIONS' in completions) --- 82,90 ---- ! msg1 = urllib.quote_plus('math') ! msg2 = urllib.quote_plus('import math\n') #check token msg. sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' % (msg1, msg2)) completions = self.readMsg() self.assert_('@@COMPLETIONS' in completions) *************** *** 109,113 **** pass ''' ! msg = urllib.quote(s) sToWrite.send('@@TOKEN_GLOBALS(C):%s\nEND@@'%s) --- 108,112 ---- pass ''' ! msg = urllib.quote_plus(s) sToWrite.send('@@TOKEN_GLOBALS(C):%s\nEND@@'%s) *************** *** 137,147 **** self.assert_(newDir != None) ! newDir = urllib.quote(newDir) sToWrite.send('@@CHANGE_DIR:%sEND@@'%newDir) ok = self.readMsg() self.assertEquals('@@MSG_OK_END@@' , ok) ! msg1 = urllib.quote('math.acos') #with point ! msg2 = urllib.quote('import math\n') sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' %(msg1, msg2)) completions = self.readMsg() --- 136,146 ---- self.assert_(newDir != None) ! newDir = urllib.quote_plus(newDir) sToWrite.send('@@CHANGE_DIR:%sEND@@'%newDir) ok = self.readMsg() self.assertEquals('@@MSG_OK_END@@' , ok) ! msg1 = urllib.quote_plus('math.acos') #with point ! msg2 = urllib.quote_plus('import math\n') sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' %(msg1, msg2)) completions = self.readMsg() *************** *** 149,154 **** self.assert_('END@@' in completions) ! msg1 = urllib.quote('math acos') #with space ! msg2 = urllib.quote('import math\n') sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' %(msg1, msg2)) completions2 = self.readMsg() --- 148,153 ---- self.assert_('END@@' in completions) ! msg1 = urllib.quote_plus('math acos') #with space ! msg2 = urllib.quote_plus('import math\n') sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' %(msg1, msg2)) completions2 = self.readMsg() *************** *** 177,183 **** createFile(FILE, getInitialFile()) ! sToWrite.send('@@REFACTORrenameByCoordinates %s %s %s %sEND@@'%(FILE, 1+1, 6, 'G')) result = self.readMsg() ! print 'result', result self.sendKillMsg(sToWrite) --- 176,186 ---- createFile(FILE, getInitialFile()) ! sToWrite.send('@@BIKEfindDefinition %s %s %sEND@@'%(FILE, 7+1, 4)) result = self.readMsg() ! self.assert_('BIKE_OK:' in result) ! ! sToWrite.send('@@BIKErenameByCoordinates %s %s %s %sEND@@'%(FILE, 1+1, 6, 'G')) ! result = self.readMsg() ! self.assert_('BIKE_OK:' in result) self.sendKillMsg(sToWrite) Index: refactoring.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/refactoring.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** refactoring.py 17 Sep 2004 19:22:04 -0000 1.5 --- refactoring.py 20 Sep 2004 19:08:41 -0000 1.6 *************** *** 78,81 **** --- 78,93 ---- return str(savedfiles) + + def findDefinition(self, filename, line, column): + defns = self.brmctx.findDefinitionByCoordinates(filename, int(line), int(column)) + + ret = '' + + for ref in defns: + ret += '(%s)'%str(ref) + + return '[%s]' % ret + + __Refactoring = None *************** *** 87,96 **** return __Refactoring ! def releaseRefactorerBuffers(): ! GetRefactorer().warning.close() ! GetRefactorer().progress.close() ! GetRefactorer().warning.__init__() ! GetRefactorer().progress.__init__() def restartRefactorer(): --- 99,109 ---- return __Refactoring ! def restartRefactorerBuffer(): ! r = GetRefactorer() ! r.warning.close() ! r.progress.close() ! r.warning.__init__() ! r.progress.__init__() def restartRefactorer(): *************** *** 113,119 **** try: f = func(*msgSplit) ! releaseRefactorerBuffers() s = urllib.quote_plus(f) ! return 'REFACTOR_OK:%s\nEND@@'%(s) except: import sys --- 126,132 ---- try: f = func(*msgSplit) ! restartRefactorerBuffer() s = urllib.quote_plus(f) ! return 'BIKE_OK:%s\nEND@@'%(s) except: import sys *************** *** 132,136 **** traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file = s) ! releaseRefactorerBuffers() restartRefactorer() s = urllib.quote_plus(s.getvalue()) --- 145,149 ---- traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file = s) ! restartRefactorerBuffer() restartRefactorer() s = urllib.quote_plus(s.getvalue()) |