RefactoringRope/CodeAssistClient.py

changeset 360
2b35968f3d02
parent 354
a967ff16629a
child 362
792c2651fbd7
equal deleted inserted replaced
359:5e0c63a80d6a 360:2b35968f3d02
6 """ 6 """
7 Module implementing the code assist client interface to rope. 7 Module implementing the code assist client interface to rope.
8 """ 8 """
9 9
10 import sys 10 import sys
11 import os
12 import contextlib 11 import contextlib
13 12
14 sys.path.insert(0, os.path.dirname(__file__)) 13 try:
15 14 from E5Network.E5JsonClient import E5JsonClient
16 import rope.base.libutils 15 except ImportError:
17 import rope.contrib.codeassist 16 # TODO: delete JsonClient once ported to eric7
18 from rope.base.exceptions import BadIdentifierError, ModuleSyntaxError 17 from JsonClient import JsonClient as E5JsonClient
19 18
20 from JsonClient import JsonClient 19
21 20 class CodeAssistClient(E5JsonClient):
22
23 class CodeAssistClient(JsonClient):
24 """ 21 """
25 Class implementing the code assist client interface to rope. 22 Class implementing the code assist client interface to rope.
26 """ 23 """
27 IdProject = "Project" 24 IdProject = "Project"
28 25
51 "getDocumentation": self.__getDocumentation, 48 "getDocumentation": self.__getDocumentation,
52 "gotoDefinition": self.__gotoDefinition, 49 "gotoDefinition": self.__gotoDefinition,
53 "reportChanged": self.__reportChanged, 50 "reportChanged": self.__reportChanged,
54 } 51 }
55 52
53 from FileSystemCommands import RefactoringClientFileSystemCommands
54 self.__fsCommands = RefactoringClientFileSystemCommands(self)
55
56 self.__projectpath = projectPath 56 self.__projectpath = projectPath
57 self.__project = rope.base.project.Project(self.__projectpath) 57 self.__project = rope.base.project.Project(
58 self.__projectpath, fscommands=self.__fsCommands)
58 self.__project.validate(self.__project.root) 59 self.__project.validate(self.__project.root)
59 60
60 self.__id = idString 61 self.__id = idString
61 62
62 def handleCall(self, method, params): 63 def handleCall(self, method, params):
113 @param params dictionary containing the method parameters sent by 114 @param params dictionary containing the method parameters sent by
114 the server 115 the server
115 @type dict 116 @type dict
116 """ 117 """
117 self.__project.close() 118 self.__project.close()
118 self.__project = rope.base.project.Project(self.__projectpath) 119 self.__project = rope.base.project.Project(
120 self.__projectpath, fscommands=self.__fsCommands)
119 self.__project.validate(self.__project.root) 121 self.__project.validate(self.__project.root)
120 122
121 def __closeProject(self, params): 123 def __closeProject(self, params):
122 """ 124 """
123 Private slot to validate the project. 125 Private slot to validate the project.
431 rope.base.libutils.report_change( 433 rope.base.libutils.report_change(
432 self.__project, filename, oldSource) 434 self.__project, filename, oldSource)
433 435
434 436
435 if __name__ == '__main__': 437 if __name__ == '__main__':
436 if len(sys.argv) != 5: 438 if len(sys.argv) != 6:
437 print('Host, port, id and project path parameters are missing. Abort.') 439 print('Host, port, id, project path and module path parameters are'
440 ' missing. Abort.')
438 sys.exit(1) 441 sys.exit(1)
439 442
440 host, port, idString, projectPath = sys.argv[1:] 443 host, port, idString, projectPath, modulePath = sys.argv[1:]
441 444
442 # Create a Qt4/5 application object in order to allow the processing of 445 sys.path.insert(1, modulePath)
446 try:
447 import rope.base.project
448 import rope.base.libutils
449 import rope.contrib.codeassist
450 from rope.base.exceptions import BadIdentifierError, ModuleSyntaxError
451 except ImportError:
452 sys.exit(42)
453
454 # Create a Qt5 application object in order to allow the processing of
443 # modules containing Qt stuff. 455 # modules containing Qt stuff.
444 try: 456 try:
445 from PyQt5.QtCore import QCoreApplication 457 from PyQt5.QtCore import QCoreApplication
446 except ImportError: 458 except ImportError:
447 try: 459 QCoreApplication = None
448 from PyQt4.QtCore import QCoreApplication
449 except ImportError:
450 QCoreApplication = None
451 if QCoreApplication is not None: 460 if QCoreApplication is not None:
452 app = QCoreApplication(sys.argv) 461 app = QCoreApplication(sys.argv)
453 462
454 client = CodeAssistClient(host, int(port), idString, projectPath) 463 client = CodeAssistClient(host, int(port), idString, projectPath)
455 # Start the main loop 464 # Start the main loop

eric ide

mercurial