58 "History": self.__processHistory, |
58 "History": self.__processHistory, |
59 "PreviewChanges": self.__previewChanges, |
59 "PreviewChanges": self.__previewChanges, |
60 "ApplyChanges": self.__applyChanges, |
60 "ApplyChanges": self.__applyChanges, |
61 "ClearChanges": self.__clearChanges, |
61 "ClearChanges": self.__clearChanges, |
62 "CalculateRenameChanges": self.__calculateRenameChanges, |
62 "CalculateRenameChanges": self.__calculateRenameChanges, |
|
63 "CalculateChangeOccurrencesChanges": |
|
64 self.__calculateChangeOccurrencesChanges, |
63 } |
65 } |
64 |
66 |
65 from FileSystemCommands import RefactoringClientFileSystemCommands |
67 from FileSystemCommands import RefactoringClientFileSystemCommands |
66 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
68 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
67 |
69 |
385 self.sendJson("HistoryResult", result) |
387 self.sendJson("HistoryResult", result) |
386 |
388 |
387 elif subcommand == "GetChange": |
389 elif subcommand == "GetChange": |
388 result = { |
390 result = { |
389 "Subcommand": "ChangeDescription", |
391 "Subcommand": "ChangeDescription", |
390 "Description": self.__changes["History"][params["Id"]]\ |
392 "Description": |
391 .get_description() |
393 self.__changes["History"][params["Id"]].get_description() |
392 } |
394 } |
393 |
395 |
394 self.sendJson("HistoryResult", result) |
396 self.sendJson("HistoryResult", result) |
395 |
397 |
396 elif subcommand in ["Undo", "Redo"]: |
398 elif subcommand in ["Undo", "Redo"]: |
592 }) |
594 }) |
593 |
595 |
594 answer = self.poll(waitMethod="ConfirmUnsure") |
596 answer = self.poll(waitMethod="ConfirmUnsure") |
595 |
597 |
596 return answer["Answer"] |
598 return answer["Answer"] |
|
599 |
|
600 def __calculateChangeOccurrencesChanges(self, params): |
|
601 """ |
|
602 Private method to calculate the rename changes based on the parameters |
|
603 sent by the server. |
|
604 |
|
605 @param params dictionary containing the method parameters sent by |
|
606 the server |
|
607 @type dict |
|
608 """ |
|
609 changeGroup = params["ChangeGroup"] |
|
610 title = params["Title"] |
|
611 filename = params["FileName"] |
|
612 offset = params["Offset"] |
|
613 newName = params["NewName"] |
|
614 onlyCalls = params["OnlyCalls"] |
|
615 reads = params["Reads"] |
|
616 writes = params["Writes"] |
|
617 |
|
618 errorDict = {} |
|
619 changes = [] |
|
620 result = { |
|
621 "ChangeGroup": changeGroup, |
|
622 "Title": title, |
|
623 } |
|
624 |
|
625 import rope.refactor.rename |
|
626 resource = rope.base.libutils.path_to_resource( |
|
627 self.__project, filename) |
|
628 try: |
|
629 renamer = rope.refactor.rename.ChangeOccurrences( |
|
630 self.__project, resource, offset) |
|
631 except Exception as err: |
|
632 errorDict = self.__handleRopeError(err) |
|
633 result.update(errorDict) |
|
634 self.sendJson("Changes", result) |
|
635 return |
|
636 |
|
637 try: |
|
638 changes = renamer.get_changes( |
|
639 newName, only_calls=onlyCalls, reads=reads, writes=writes) |
|
640 except Exception as err: |
|
641 errorDict = self.__handleRopeError(err) |
|
642 |
|
643 self.__changes[changeGroup] = changes |
|
644 |
|
645 result["Subcommand"] = "ChangesCalculated" |
|
646 result.update(errorDict) |
|
647 |
|
648 self.sendJson("Changes", result) |
597 |
649 |
598 if __name__ == '__main__': |
650 if __name__ == '__main__': |
599 if len(sys.argv) != 4: |
651 if len(sys.argv) != 4: |
600 print('Host, port and project path parameters are missing. Abort.') |
652 print('Host, port and project path parameters are missing. Abort.') |
601 sys.exit(1) |
653 sys.exit(1) |