--- a/RefactoringRope/CodeAssistClient.py Sun May 09 14:30:51 2021 +0200 +++ b/RefactoringRope/CodeAssistClient.py Mon May 10 20:13:48 2021 +0200 @@ -8,19 +8,16 @@ """ import sys -import os import contextlib -sys.path.insert(0, os.path.dirname(__file__)) - -import rope.base.libutils -import rope.contrib.codeassist -from rope.base.exceptions import BadIdentifierError, ModuleSyntaxError - -from JsonClient import JsonClient +try: + from E5Network.E5JsonClient import E5JsonClient +except ImportError: + # TODO: delete JsonClient once ported to eric7 + from JsonClient import JsonClient as E5JsonClient -class CodeAssistClient(JsonClient): +class CodeAssistClient(E5JsonClient): """ Class implementing the code assist client interface to rope. """ @@ -53,8 +50,12 @@ "reportChanged": self.__reportChanged, } + from FileSystemCommands import RefactoringClientFileSystemCommands + self.__fsCommands = RefactoringClientFileSystemCommands(self) + self.__projectpath = projectPath - self.__project = rope.base.project.Project(self.__projectpath) + self.__project = rope.base.project.Project( + self.__projectpath, fscommands=self.__fsCommands) self.__project.validate(self.__project.root) self.__id = idString @@ -115,7 +116,8 @@ @type dict """ self.__project.close() - self.__project = rope.base.project.Project(self.__projectpath) + self.__project = rope.base.project.Project( + self.__projectpath, fscommands=self.__fsCommands) self.__project.validate(self.__project.root) def __closeProject(self, params): @@ -433,21 +435,28 @@ if __name__ == '__main__': - if len(sys.argv) != 5: - print('Host, port, id and project path parameters are missing. Abort.') + if len(sys.argv) != 6: + print('Host, port, id, project path and module path parameters are' + ' missing. Abort.') sys.exit(1) - host, port, idString, projectPath = sys.argv[1:] + host, port, idString, projectPath, modulePath = sys.argv[1:] - # Create a Qt4/5 application object in order to allow the processing of + sys.path.insert(1, modulePath) + try: + import rope.base.project + import rope.base.libutils + import rope.contrib.codeassist + from rope.base.exceptions import BadIdentifierError, ModuleSyntaxError + except ImportError: + sys.exit(42) + + # Create a Qt5 application object in order to allow the processing of # modules containing Qt stuff. try: from PyQt5.QtCore import QCoreApplication except ImportError: - try: - from PyQt4.QtCore import QCoreApplication - except ImportError: - QCoreApplication = None + QCoreApplication = None if QCoreApplication is not None: app = QCoreApplication(sys.argv)