--- a/RefactoringRope/RefactoringClient.py Sat Sep 23 12:16:59 2017 +0200 +++ b/RefactoringRope/RefactoringClient.py Sat Sep 23 12:39:00 2017 +0200 @@ -72,6 +72,8 @@ "CalculateUseFunctionChanges": self.__calculateUseFunctionChanges, "CalculateIntroduceFactoryChanges": self.__calculateIntroduceFactoryChanges, + "CalculateIntroduceParameterChanges": + self.__calculateIntroduceParameterChanges, } from FileSystemCommands import RefactoringClientFileSystemCommands @@ -1001,6 +1003,45 @@ result.update(errorDict) self.sendJson("Changes", result) + + def __calculateIntroduceParameterChanges(self, params): + """ + Private method to calculate the 'Introduce Parameter' 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"] + parameterName = params["Name"] + + errorDict = {} + changes = [] + result = { + "ChangeGroup": changeGroup, + "Title": title, + } + + import rope.refactor.introduce_parameter + resource = rope.base.libutils.path_to_resource( + self.__project, filename) + try: + introducer = rope.refactor.introduce_parameter.IntroduceParameter( + self.__project, resource, offset) + changes = introducer.get_changes(parameterName) + 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__':