85 "RequestFieldName": self.__requestFieldName, |
85 "RequestFieldName": self.__requestFieldName, |
86 "CalculateEncapsulateFieldChanges": |
86 "CalculateEncapsulateFieldChanges": |
87 self.__calculateEncapsulateFieldChanges, |
87 self.__calculateEncapsulateFieldChanges, |
88 "CalculateLocalToAttributeChanges": |
88 "CalculateLocalToAttributeChanges": |
89 self.__calculateLocalToAttributeChanges, |
89 self.__calculateLocalToAttributeChanges, |
|
90 "CalculateMethodObjectChanges": |
|
91 self.__calculateMethodObjectChanges, |
90 } |
92 } |
91 |
93 |
92 from FileSystemCommands import RefactoringClientFileSystemCommands |
94 from FileSystemCommands import RefactoringClientFileSystemCommands |
93 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
95 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
94 |
96 |
1474 |
1476 |
1475 result["Subcommand"] = "ChangesCalculated" |
1477 result["Subcommand"] = "ChangesCalculated" |
1476 result.update(errorDict) |
1478 result.update(errorDict) |
1477 |
1479 |
1478 self.sendJson("Changes", result) |
1480 self.sendJson("Changes", result) |
|
1481 |
|
1482 def __calculateMethodObjectChanges(self, params): |
|
1483 """ |
|
1484 Private method to calculate the 'Method to Method Object' changes |
|
1485 based on the parameters sent by the server. |
|
1486 |
|
1487 @param params dictionary containing the method parameters sent by |
|
1488 the server |
|
1489 @type dict |
|
1490 """ |
|
1491 changeGroup = params["ChangeGroup"] |
|
1492 title = params["Title"] |
|
1493 filename = params["FileName"] |
|
1494 offset = params["Offset"] |
|
1495 name = params["Name"] |
|
1496 |
|
1497 errorDict = {} |
|
1498 changes = None |
|
1499 result = { |
|
1500 "ChangeGroup": changeGroup, |
|
1501 "Title": title, |
|
1502 } |
|
1503 |
|
1504 import rope.refactor.method_object |
|
1505 resource = rope.base.libutils.path_to_resource( |
|
1506 self.__project, filename) |
|
1507 try: |
|
1508 converter = rope.refactor.method_object.MethodObject( |
|
1509 self.__project, resource, offset) |
|
1510 changes = converter.get_changes(name) |
|
1511 except Exception as err: |
|
1512 errorDict = self.__handleRopeError(err) |
|
1513 |
|
1514 self.__changes[changeGroup] = changes |
|
1515 |
|
1516 result["Subcommand"] = "ChangesCalculated" |
|
1517 result.update(errorDict) |
|
1518 |
|
1519 self.sendJson("Changes", result) |
1479 |
1520 |
1480 |
1521 |
1481 if __name__ == '__main__': |
1522 if __name__ == '__main__': |
1482 if len(sys.argv) != 4: |
1523 if len(sys.argv) != 4: |
1483 print('Host, port and project path parameters are missing. Abort.') |
1524 print('Host, port and project path parameters are missing. Abort.') |