68 "CalculateInlineChanges": self.__calculateInlineChanges, |
68 "CalculateInlineChanges": self.__calculateInlineChanges, |
69 "RequestMoveType": self.__requestMoveType, |
69 "RequestMoveType": self.__requestMoveType, |
70 "CalculateMoveChanges": self.__calculateMoveChanges, |
70 "CalculateMoveChanges": self.__calculateMoveChanges, |
71 "RequestUseFunction": self.__requestUseFunction, |
71 "RequestUseFunction": self.__requestUseFunction, |
72 "CalculateUseFunctionChanges": self.__calculateUseFunctionChanges, |
72 "CalculateUseFunctionChanges": self.__calculateUseFunctionChanges, |
|
73 "CalculateIntroduceFactoryChanges": |
|
74 self.__calculateIntroduceFactoryChanges, |
73 } |
75 } |
74 |
76 |
75 from FileSystemCommands import RefactoringClientFileSystemCommands |
77 from FileSystemCommands import RefactoringClientFileSystemCommands |
76 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
78 self.__fsCommands = RefactoringClientFileSystemCommands(self) |
77 |
79 |
951 |
953 |
952 result["Subcommand"] = "ChangesCalculated" |
954 result["Subcommand"] = "ChangesCalculated" |
953 result.update(errorDict) |
955 result.update(errorDict) |
954 |
956 |
955 self.sendJson("Changes", result) |
957 self.sendJson("Changes", result) |
|
958 |
|
959 def __calculateIntroduceFactoryChanges(self, params): |
|
960 """ |
|
961 Private method to calculate the 'Introduce Factory' changes based on |
|
962 the parameters sent by the server. |
|
963 |
|
964 @param params dictionary containing the method parameters sent by |
|
965 the server |
|
966 @type dict |
|
967 """ |
|
968 changeGroup = params["ChangeGroup"] |
|
969 title = params["Title"] |
|
970 filename = params["FileName"] |
|
971 offset = params["Offset"] |
|
972 factoryName = params["Name"] |
|
973 globalFactory = params["GlobalFactory"] |
|
974 |
|
975 errorDict = {} |
|
976 changes = [] |
|
977 result = { |
|
978 "ChangeGroup": changeGroup, |
|
979 "Title": title, |
|
980 } |
|
981 |
|
982 import rope.refactor.introduce_factory |
|
983 resource = rope.base.libutils.path_to_resource( |
|
984 self.__project, filename) |
|
985 self.__progressHandle = ProgressHandle(self, title, True) |
|
986 try: |
|
987 introducer = \ |
|
988 rope.refactor.introduce_factory.IntroduceFactoryRefactoring( |
|
989 self.__project, resource, offset) |
|
990 changes = introducer.get_changes( |
|
991 factoryName, global_factory=globalFactory, |
|
992 task_handle=self.__progressHandle) |
|
993 except Exception as err: |
|
994 errorDict = self.__handleRopeError(err) |
|
995 self.__progressHandle.reset() |
|
996 self.__progressHandle = None |
|
997 |
|
998 self.__changes[changeGroup] = changes |
|
999 |
|
1000 result["Subcommand"] = "ChangesCalculated" |
|
1001 result.update(errorDict) |
|
1002 |
|
1003 self.sendJson("Changes", result) |
|
1004 |
956 |
1005 |
957 if __name__ == '__main__': |
1006 if __name__ == '__main__': |
958 if len(sys.argv) != 4: |
1007 if len(sys.argv) != 4: |
959 print('Host, port and project path parameters are missing. Abort.') |
1008 print('Host, port and project path parameters are missing. Abort.') |
960 sys.exit(1) |
1009 sys.exit(1) |