diff -r 2cdb7c48b719 -r 04583cac110f RefactoringRope/RefactoringClient.py --- a/RefactoringRope/RefactoringClient.py Tue Sep 19 18:59:14 2017 +0200 +++ b/RefactoringRope/RefactoringClient.py Tue Sep 19 19:40:18 2017 +0200 @@ -60,6 +60,8 @@ "ApplyChanges": self.__applyChanges, "ClearChanges": self.__clearChanges, "CalculateRenameChanges": self.__calculateRenameChanges, + "CalculateChangeOccurrencesChanges": + self.__calculateChangeOccurrencesChanges, } from FileSystemCommands import RefactoringClientFileSystemCommands @@ -387,8 +389,8 @@ elif subcommand == "GetChange": result = { "Subcommand": "ChangeDescription", - "Description": self.__changes["History"][params["Id"]]\ - .get_description() + "Description": + self.__changes["History"][params["Id"]].get_description() } self.sendJson("HistoryResult", result) @@ -594,6 +596,56 @@ answer = self.poll(waitMethod="ConfirmUnsure") return answer["Answer"] + + def __calculateChangeOccurrencesChanges(self, params): + """ + Private method to calculate the rename changes based on the parameters + sent by the server. + + @param params dictionary containing the method parameters sent by + the server + @type dict + """ + changeGroup = params["ChangeGroup"] + title = params["Title"] + filename = params["FileName"] + offset = params["Offset"] + newName = params["NewName"] + onlyCalls = params["OnlyCalls"] + reads = params["Reads"] + writes = params["Writes"] + + errorDict = {} + changes = [] + result = { + "ChangeGroup": changeGroup, + "Title": title, + } + + import rope.refactor.rename + resource = rope.base.libutils.path_to_resource( + self.__project, filename) + try: + renamer = rope.refactor.rename.ChangeOccurrences( + self.__project, resource, offset) + except Exception as err: + errorDict = self.__handleRopeError(err) + result.update(errorDict) + self.sendJson("Changes", result) + return + + try: + changes = renamer.get_changes( + newName, only_calls=onlyCalls, reads=reads, writes=writes) + except Exception as err: + errorDict = self.__handleRopeError(err) + + self.__changes[changeGroup] = changes + + result["Subcommand"] = "ChangesCalculated" + result.update(errorDict) + + self.sendJson("Changes", result) if __name__ == '__main__': if len(sys.argv) != 4: