78 "CalculateRestructureChanges": self.__calculateRestructureChanges, |
78 "CalculateRestructureChanges": self.__calculateRestructureChanges, |
79 "RequestSignature": self.__requestSignature, |
79 "RequestSignature": self.__requestSignature, |
80 "CalculateSignatureChanges": self.__calculateSignatureChanges, |
80 "CalculateSignatureChanges": self.__calculateSignatureChanges, |
81 "CalculateInlineArgumentDefaultChanges": |
81 "CalculateInlineArgumentDefaultChanges": |
82 self.__calculateInlineArgumentDefaultChanges, |
82 self.__calculateInlineArgumentDefaultChanges, |
|
83 "CalculateModuleToPackageChanges": |
|
84 self.__calculateModuleToPackageChanges, |
83 } |
85 } |
84 |
86 |
85 from FileSystemCommands import RefactoringClientFileSystemCommands |
87 from FileSystemCommands import RefactoringClientFileSystemCommands |
86 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
88 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
87 |
89 |
1261 offset = params["Offset"] |
1262 offset = params["Offset"] |
1262 argumentIndex = params["Index"] |
1263 argumentIndex = params["Index"] |
1263 |
1264 |
1264 errorDict = {} |
1265 errorDict = {} |
1265 result = { |
1266 result = { |
1266 "Subcommand": "Signature", |
|
1267 "ChangeGroup": changeGroup, |
1267 "ChangeGroup": changeGroup, |
1268 "Title": title, |
1268 "Title": title, |
1269 } |
1269 } |
1270 |
1270 |
1271 resource = rope.base.libutils.path_to_resource( |
1271 resource = rope.base.libutils.path_to_resource( |
1287 |
1287 |
1288 result["Subcommand"] = "ChangesCalculated" |
1288 result["Subcommand"] = "ChangesCalculated" |
1289 result.update(errorDict) |
1289 result.update(errorDict) |
1290 |
1290 |
1291 self.sendJson("Changes", result) |
1291 self.sendJson("Changes", result) |
|
1292 |
|
1293 def __calculateModuleToPackageChanges(self, params): |
|
1294 """ |
|
1295 Private method to calculate the 'Module to Package' changes |
|
1296 based on the parameters sent by the server. |
|
1297 |
|
1298 @param params dictionary containing the method parameters sent by |
|
1299 the server |
|
1300 @type dict |
|
1301 """ |
|
1302 changeGroup = params["ChangeGroup"] |
|
1303 title = params["Title"] |
|
1304 filename = params["FileName"] |
|
1305 |
|
1306 errorDict = {} |
|
1307 result = { |
|
1308 "ChangeGroup": changeGroup, |
|
1309 "Title": title, |
|
1310 } |
|
1311 |
|
1312 import rope.refactor.topackage |
|
1313 resource = rope.base.libutils.path_to_resource( |
|
1314 self.__project, filename) |
|
1315 try: |
|
1316 changes = rope.refactor.topackage.ModuleToPackage( |
|
1317 self.__project, resource).get_changes() |
|
1318 except Exception as err: |
|
1319 errorDict = self.__handleRopeError(err) |
|
1320 |
|
1321 self.__changes[changeGroup] = changes |
|
1322 |
|
1323 # send the change description first |
|
1324 if changes: |
|
1325 description = changes.description |
|
1326 else: |
|
1327 description = "" |
|
1328 self.sendJson("Changes", { |
|
1329 "ChangeGroup": changeGroup, |
|
1330 "Title": title, |
|
1331 "Subcommand": "ChangeDescription", |
|
1332 "Description": description, |
|
1333 }) |
|
1334 |
|
1335 result["Subcommand"] = "ChangesCalculated" |
|
1336 result.update(errorDict) |
|
1337 |
|
1338 self.sendJson("Changes", result) |
1292 |
1339 |
1293 |
1340 |
1294 if __name__ == '__main__': |
1341 if __name__ == '__main__': |
1295 if len(sys.argv) != 4: |
1342 if len(sys.argv) != 4: |
1296 print('Host, port and project path parameters are missing. Abort.') |
1343 print('Host, port and project path parameters are missing. Abort.') |