73 "CalculateIntroduceFactoryChanges": |
73 "CalculateIntroduceFactoryChanges": |
74 self.__calculateIntroduceFactoryChanges, |
74 self.__calculateIntroduceFactoryChanges, |
75 "CalculateIntroduceParameterChanges": |
75 "CalculateIntroduceParameterChanges": |
76 self.__calculateIntroduceParameterChanges, |
76 self.__calculateIntroduceParameterChanges, |
77 "CalculateImportsChanges": self.__calculateImportsChanges, |
77 "CalculateImportsChanges": self.__calculateImportsChanges, |
|
78 "CalculateRestructureChanges": self.__calculateRestructureChanges, |
78 } |
79 } |
79 |
80 |
80 from FileSystemCommands import RefactoringClientFileSystemCommands |
81 from FileSystemCommands import RefactoringClientFileSystemCommands |
81 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
82 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
82 |
83 |
1098 |
1099 |
1099 result["Subcommand"] = "ChangesCalculated" |
1100 result["Subcommand"] = "ChangesCalculated" |
1100 result.update(errorDict) |
1101 result.update(errorDict) |
1101 |
1102 |
1102 self.sendJson("Changes", result) |
1103 self.sendJson("Changes", result) |
|
1104 |
|
1105 def __calculateRestructureChanges(self, params): |
|
1106 """ |
|
1107 Private method to calculate the 'Restructure' changes based on the |
|
1108 parameters sent by the server. |
|
1109 |
|
1110 @param params dictionary containing the method parameters sent by |
|
1111 the server |
|
1112 @type dict |
|
1113 """ |
|
1114 changeGroup = params["ChangeGroup"] |
|
1115 title = params["Title"] |
|
1116 pattern = params["Pattern"] |
|
1117 goal = params["Goal"] |
|
1118 args = params["Args"] |
|
1119 imports = params["Imports"] |
|
1120 |
|
1121 errorDict = {} |
|
1122 changes = [] |
|
1123 result = { |
|
1124 "ChangeGroup": changeGroup, |
|
1125 "Title": title, |
|
1126 } |
|
1127 |
|
1128 import rope.refactor.restructure |
|
1129 self.__project.validate(self.__project.root) |
|
1130 self.__progressHandle = ProgressHandle(self, title, True) |
|
1131 try: |
|
1132 restructuring = rope.refactor.restructure.Restructure( |
|
1133 self.__project, pattern, goal, args=args, imports=imports) |
|
1134 changes = restructuring.get_changes( |
|
1135 task_handle=self.__progressHandle) |
|
1136 except Exception as err: |
|
1137 errorDict = self.__handleRopeError(err) |
|
1138 self.__progressHandle.reset() |
|
1139 self.__progressHandle = None |
|
1140 |
|
1141 self.__changes[changeGroup] = changes |
|
1142 |
|
1143 result["Subcommand"] = "ChangesCalculated" |
|
1144 result.update(errorDict) |
|
1145 |
|
1146 self.sendJson("Changes", result) |
1103 |
1147 |
1104 |
1148 |
1105 if __name__ == '__main__': |
1149 if __name__ == '__main__': |
1106 if len(sys.argv) != 4: |
1150 if len(sys.argv) != 4: |
1107 print('Host, port and project path parameters are missing. Abort.') |
1151 print('Host, port and project path parameters are missing. Abort.') |