RefactoringRope/CodeAssistServer.py

branch
eric7
changeset 414
af1d72eccf91
parent 413
a4cba20ad7ab
child 420
fa31c3a0df1d
equal deleted inserted replaced
413:a4cba20ad7ab 414:af1d72eccf91
17 17
18 from eric7 import Globals, Preferences 18 from eric7 import Globals, Preferences
19 from eric7.EricNetwork.EricJsonServer import EricJsonServer 19 from eric7.EricNetwork.EricJsonServer import EricJsonServer
20 from eric7.EricWidgets import EricMessageBox 20 from eric7.EricWidgets import EricMessageBox
21 from eric7.EricWidgets.EricApplication import ericApp 21 from eric7.EricWidgets.EricApplication import ericApp
22 from eric7.QScintilla.Editor import Editor
23 22
24 try: 23 try:
25 from eric7.SystemUtilities.PythonUtilities import ( 24 from eric7.SystemUtilities.PythonUtilities import (
26 getPythonExecutable, 25 getPythonExecutable,
27 getPythonLibraryDirectory, 26 getPythonLibraryDirectory,
28 ) 27 )
29 except ImportError: 28 except ImportError:
30 # imports for eric < 23.1 29 # imports for eric < 23.1
31 from eric7.Globals import getPythonExecutable, getPythonLibraryDirectory 30 from eric7.Globals import getPythonExecutable, getPythonLibraryDirectory
32 31
33 32 try:
34 class CodeAssistServer(EricJsonServer): 33 from eric7.QScintilla.Editor import EditorIconId
35 """ 34
36 Class implementing the autocompletion interface to rope. 35 PictureIDs = {
37 """ 36 "class": "?{0}".format(EditorIconId.Class),
38 37 "_class": "?{0}".format(EditorIconId.ClassProtected),
39 IdProject = "Project" 38 "__class": "?{0}".format(EditorIconId.ClassPrivate),
39 "instance": "?{0}".format(EditorIconId.Class),
40 "_instance": "?{0}".format(EditorIconId.ClassProtected),
41 "__instance": "?{0}".format(EditorIconId.ClassPrivate),
42 "function": "?{0}".format(EditorIconId.Method),
43 "_function": "?{0}".format(EditorIconId.MethodProtected),
44 "__function": "?{0}".format(EditorIconId.MethodPrivate),
45 "module": "?{0}".format(EditorIconId.Module),
46 "_module": "?{0}".format(EditorIconId.Module),
47 "__module": "?{0}".format(EditorIconId.Module),
48 "None": "",
49 }
50 except ImportError:
51 # backward compatibility for eric < 24.2
52 from eric7.QScintilla.Editor import Editor
40 53
41 PictureIDs = { 54 PictureIDs = {
42 "class": "?{0}".format(Editor.ClassID), 55 "class": "?{0}".format(Editor.ClassID),
43 "_class": "?{0}".format(Editor.ClassProtectedID), 56 "_class": "?{0}".format(Editor.ClassProtectedID),
44 "__class": "?{0}".format(Editor.ClassPrivateID), 57 "__class": "?{0}".format(Editor.ClassPrivateID),
51 "module": "?{0}".format(Editor.ModuleID), 64 "module": "?{0}".format(Editor.ModuleID),
52 "_module": "?{0}".format(Editor.ModuleID), 65 "_module": "?{0}".format(Editor.ModuleID),
53 "__module": "?{0}".format(Editor.ModuleID), 66 "__module": "?{0}".format(Editor.ModuleID),
54 "None": "", 67 "None": "",
55 } 68 }
69
70
71 class CodeAssistServer(EricJsonServer):
72 """
73 Class implementing the autocompletion interface to rope.
74 """
75
76 IdProject = "Project"
56 77
57 def __init__(self, plugin, parent=None): 78 def __init__(self, plugin, parent=None):
58 """ 79 """
59 Constructor 80 Constructor
60 81
325 @type dict 346 @type dict
326 """ 347 """
327 names = [] 348 names = []
328 for completion in result["Completions"]: 349 for completion in result["Completions"]:
329 name = completion["Name"] 350 name = completion["Name"]
330 351 name += PictureIDs.get(completion["CompletionType"], "")
331 name += CodeAssistServer.PictureIDs.get(completion["CompletionType"], "")
332 names.append(name) 352 names.append(name)
333 353
334 if "Error" not in result: 354 if "Error" not in result:
335 editor = self.__vm.getOpenEditor(result["FileName"]) 355 editor = self.__vm.getOpenEditor(result["FileName"])
336 if editor is not None: 356 if editor is not None:

eric ide

mercurial