9
#kind of hack to get the bicicle repair man without having it in the pythonpath.
10
sys.path.insert(1, os.path.join(os.path.dirname(sys.argv[0]),
12
import ThirdParty.brm.bike as bike
16
class Refactoring(object):
19
self.progress = StringIO.StringIO()
20
self.warning = StringIO.StringIO()
23
def getLastProgressMsg(self):
24
progress = self.progress.getvalue().split('\n')
27
while msg == '' and i > -5:
35
def getLastProgressMsgs(self, v):
36
progress = self.progress.getvalue().split('\n')
41
msg += progress[i]+'\n'
49
Private slot to handle the Reset action.
51
self.brmctx = bike.init()
52
self.brmctx.setProgressLogger(self.progress)
53
self.brmctx.setWarningLogger(self.warning)
55
def handleReset(self):
57
Private slot to handle the Reset action.
62
def extractMethod(self, filename, startline, startcolumn,
63
endline, endcolumn, newname):
65
Receives all as a string and changes to correct type.
67
self.brmctx.extractMethod(filename, int(startline), int(startcolumn),
68
int(endline), int(endcolumn),
70
savedfiles = self.brmctx.save()
71
return str(savedfiles)
74
def renameByCoordinates(self, filename, line, column, newname):
76
Receives all as a string and changes to correct type.
78
self.brmctx.renameByCoordinates(filename, int(line), int(column), newname)
79
savedfiles = self.brmctx.save()
80
return str(savedfiles)
83
def inlineLocalVariable(self, filename, line, column):
85
Receives all as a string and changes to correct type.
87
self.brmctx.inlineLocalVariable(filename, int(line), int(column))
88
savedfiles = self.brmctx.save()
89
return str(savedfiles)
92
def extractLocalVariable(self,filename, begin_line, begin_col,
93
end_line, end_col, newname):
95
Receives all as a string and changes to correct type.
97
self.brmctx.extractLocalVariable(filename, int(begin_line), int(begin_col),
98
int(end_line), int(end_col), newname)
99
savedfiles = self.brmctx.save()
100
return str(savedfiles)
103
def findDefinition(self, filename, line, column):
105
Receives all as a string and changes to correct type.
107
defns = self.brmctx.findDefinitionByCoordinates(filename, int(line), int(column))
112
ret += '(%s)'%str(ref)
121
if __Refactoring is None:
122
__Refactoring = Refactoring()
126
def restartRefactorerBuffer():
132
r.progress.__init__()
134
def restartRefactorer():
136
__Refactoring = Refactoring()
138
def HandleRefactorMessage(msg, keepAliveThread):
140
The message received should have: the method of the class and its parameters.
142
msgSplit = msg.split('|')
144
func = msgSplit.pop(0)
146
refactorer = GetRefactorer()
147
func = getattr(refactorer, func)
149
keepAliveThread.processMsgFunc = refactorer.getLastProgressMsg
153
restartRefactorerBuffer()
154
s = urllib.quote_plus(f)
155
return 'BIKE_OK:%s\nEND@@'%(s)
158
s = StringIO.StringIO()
159
exc_info = sys.exc_info()
161
print >> s, str(exc_info[1])
163
print >> s, '\nWARNINGS:\n'
164
print >> s, refactorer.warning.getvalue()
166
print >> s, '\nPROGRESS:\n'
167
print >> s, refactorer.getLastProgressMsgs(8)
169
print >> s, '\nDETAILS:\n'
170
traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file = s)
172
restartRefactorerBuffer()
174
s = urllib.quote_plus(s.getvalue())
175
return 'ERROR:%s\nEND@@'%(s)