diff -r 6b3530ce34d0 -r da88cb84ae30 RefactoringRope/CodeAssistServer.py --- a/RefactoringRope/CodeAssistServer.py Sun Nov 11 17:44:55 2018 +0100 +++ b/RefactoringRope/CodeAssistServer.py Sun Nov 11 17:46:25 2018 +0100 @@ -17,6 +17,8 @@ from E5Gui.E5Application import e5App from E5Gui import E5MessageBox +from QScintilla.Editor import Editor + from .JsonServer import JsonServer import Globals @@ -30,6 +32,22 @@ """ IdProject = "Project" + PictureIDs = { + "class": "?{0}".format(Editor.ClassID), + "_class": "?{0}".format(Editor.ClassProtectedID), + "__class": "?{0}".format(Editor.ClassPrivateID), + "instance": "?{0}".format(Editor.ClassID), + "_instance": "?{0}".format(Editor.ClassProtectedID), + "__instance": "?{0}".format(Editor.ClassPrivateID), + "function": "?{0}".format(Editor.MethodID), + "_function": "?{0}".format(Editor.MethodProtectedID), + "__function": "?{0}".format(Editor.MethodPrivateID), + "module": "?{0}".format(Editor.ModuleID), + "_module": "?{0}".format(Editor.ModuleID), + "__module": "?{0}".format(Editor.ModuleID), + "None": "", + } + def __init__(self, plugin, parent=None): """ Constructor @@ -279,12 +297,20 @@ @param result dictionary containing the result sent by the client @type dict """ + names = [] + for completion in result["Completions"]: + name = completion['Name'] + + name += CodeAssistServer.PictureIDs.get( + completion['CompletionType'], '') + names.append(name) + if self.__asyncCompletions: # asynchronous variant for eric6 17.11 and later if "Error" not in result: editor = self.__vm.getOpenEditor(result["FileName"]) if editor is not None: - editor.completionsListReady(result["Completions"], + editor.completionsListReady(names, result["CompletionText"]) else: # synchronous variant for eric6 before 17.11 @@ -380,8 +406,10 @@ if self.__documentationViewer is None: return - language = editor.getLanguage() - if not self.isSupportedLanguage(language): + idString = self.__idString(editor) + + if not idString: + language = editor.getLanguage() if Preferences.getDocuViewer("ShowInfoAsRichText"): warning = self.tr("Language <b>{0}</b> is not supported.")\ .format(language) @@ -392,10 +420,6 @@ warning, isWarning=True) return - idString = self.__idString(editor) - if not idString: - return - filename = editor.getFileName() source = editor.text() line, index = editor.getCursorPosition() @@ -485,12 +509,12 @@ """ if params["ExceptionType"] == "ProtocolError": self.__ui.appendToStderr( - self.tr("""The data received from the code assist""" - """ server could not be decoded. Please report""" - """ this issue with the received data to the""" - """ eric bugs email address.\n""" - """Error: {0}\n""" - """Data: {1}\n""").format( + self.tr("The data received from the code assist" + " server could not be decoded. Please report" + " this issue with the received data to the" + " eric bugs email address.\n" + "Error: {0}\n" + "Data:\n{1}\n").format( params["ExceptionValue"], params["ProtocolData"])) else: @@ -780,6 +804,7 @@ @param editor reference to the editor @type QScintilla.Editor.Editor """ + # TODO: special treatment for project files if self.isSupportedLanguage(editor.getLanguage()): if self.__plugin.getPreferences("CodeAssistEnabled") and \ editor.getCompletionListHook("rope") is None: