diff -r 62d9dc4eedd5 -r 89ff060ef0d9 AssistantEric/Assistant.py --- a/AssistantEric/Assistant.py Tue May 25 17:22:05 2021 +0200 +++ b/AssistantEric/Assistant.py Tue May 25 17:48:25 2021 +0200 @@ -11,9 +11,9 @@ import re import imp -from PyQt5.QtCore import QRegExp, QObject +from PyQt6.QtCore import QObject -from E5Gui.E5Application import e5App +from EricWidgets.EricApplication import ericApp from .APIsManager import APIsManager, ApisNameProject @@ -31,15 +31,17 @@ Constructor @param plugin reference to the plugin object - @param parent parent (QObject) + @type AssistantEricPlugin + @param parent parent + @type QObject """ QObject.__init__(self, parent) self.__plugin = plugin self.__ui = parent - self.__project = e5App().getObject("Project") - self.__viewmanager = e5App().getObject("ViewManager") - self.__pluginManager = e5App().getObject("PluginManager") + self.__project = ericApp().getObject("Project") + self.__viewmanager = ericApp().getObject("ViewManager") + self.__pluginManager = ericApp().getObject("PluginManager") self.__apisManager = APIsManager(self.__ui, self) @@ -93,8 +95,10 @@ """ Public method to enable or disable a feature. - @param key feature to set (string) - @param enabled flag indicating the status (boolean) + @param key feature to set + @type str + @param enabled flag indicating the status + @type bool """ for editor in self.__editors[:]: self.__editorClosed(editor) @@ -105,7 +109,8 @@ """ Private slot called, when a new editor was opened. - @param editor reference to the new editor (QScintilla.Editor) + @param editor reference to the new editor + @type Editor """ if self.__plugin.getPreferences("AutoCompletionEnabled"): self.__setAutoCompletionHook(editor) @@ -125,7 +130,8 @@ """ Private slot called, when an editor was closed. - @param editor reference to the editor (QScintilla.Editor) + @param editor reference to the editor + @type Editor """ if editor in self.__editors: editor.editorSaved.disconnect( @@ -171,8 +177,10 @@ Private slot to handle the selection from the completion list to record the selected completion context. - @param userListId the ID of the user list (should be 1) (integer) - @param txt the selected text (string) + @param userListId the ID of the user list (should be 1) + @type int + @param txt the selected text + @type str """ from QScintilla.Editor import EditorAutoCompletionListID @@ -187,7 +195,8 @@ """ Private method to set the autocompletion hook. - @param editor reference to the editor (QScintilla.Editor) + @param editor reference to the editor + @type Editor """ editor.userListActivated.connect(self.__recordSelectedContext) editor.addCompletionListHook("Assistant", self.getCompletionsList) @@ -196,7 +205,8 @@ """ Private method to unset the autocompletion hook. - @param editor reference to the editor (QScintilla.Editor) + @param editor reference to the editor + @type Editor """ editor.userListActivated.disconnect(self.__recordSelectedContext) editor.removeCompletionListHook("Assistant") @@ -206,9 +216,11 @@ Public method to get a list of possible completions. @param editor reference to the editor object, that called this method - (QScintilla.Editor) - @param context flag indicating to autocomplete a context (boolean) - @return list of possible completions (list of strings) + @type Editor + @param context flag indicating to autocomplete a context + @type bool + @return list of possible completions + @rtype list of str """ language = editor.getApiLanguage() completeFromDocumentOnly = False @@ -342,18 +354,28 @@ """ Private method to get the list of possible completions. - @param word word (or wordpart) to complete (string) - @param context flag indicating to autocomplete a context (boolean) - @param prefix prefix of the word to be completed (string) - @param language programming language of the source (string) - @param projectType type of the project (string) - @param module reference to the scanned module info (Module) - @param editor reference to the editor object (QScintilla.Editor.Editor) - @param importCompletion flag indicating an import completion (boolean) + @param word word (or wordpart) to complete + @type str + @param context flag indicating to autocomplete a context + @type bool + @param prefix prefix of the word to be completed + @type str + @param language programming language of the source + @type str + @param projectType type of the project + @type str + @param module reference to the scanned module info + @type Module + @param editor reference to the editor object + @type Editor + @param importCompletion flag indicating an import completion + @type bool @param documentOnly flag indicating to complete from the document only - (boolean) - @param sep separator string (string) - @return list of possible completions (list of strings) + @type bool + @param sep separator string + @type str + @return list of possible completions + @rtype list of str """ apiCompletionsList = [] docCompletionsList = [] @@ -393,13 +415,20 @@ """ Private method to determine a list of completions from an API object. - @param api reference to the API object to be used (APIsManager.DbAPIs) - @param word word (or wordpart) to complete (string) - @param context flag indicating to autocomplete a context (boolean) - @param prefix prefix of the word to be completed (string) - @param module reference to the scanned module info (Module) - @param editor reference to the editor object (QScintilla.Editor.Editor) - @return list of possible completions (list of strings) + @param api reference to the API object to be used + @type APIsManager.DbAPIs + @param word word (or wordpart) to complete + @type str + @param context flag indicating to autocomplete a context + @type bool + @param prefix prefix of the word to be completed + @type str + @param module reference to the scanned module info + @type Module + @param editor reference to the editor object + @type Editor + @return list of possible completions + @rtype list of str """ completionsList = [] if api is not None: @@ -446,10 +475,10 @@ entry += "?{0}".format(completion["pictureId"]) else: cont = False - re = QRegExp( - QRegExp.escape(entry) + "\?\d{,2}") + regexp = re.compile( + re.escape(entry) + r"\?\d{,2}") for comp in completionsList: - if re.exactMatch(comp): + if regexp.fullmatchS(comp): cont = True break if cont: @@ -487,9 +516,9 @@ entry += "?{0}".format(completion["pictureId"]) else: cont = False - re = QRegExp(QRegExp.escape(entry) + "\?\d{,2}") + regexp = re.compile(re.escape(entry) + "\?\d{,2}") for comp in completionsList: - if re.exactMatch(comp): + if regexp.fullmatch(comp): cont = True break if cont: @@ -503,14 +532,22 @@ """ Private method to determine autocompletion proposals from the document. - @param editor reference to the editor object (QScintilla.Editor.Editor) - @param word string to be completed (string) - @param context flag indicating to autocomplete a context (boolean) - @param sep separator string (string) - @param prefix prefix of the word to be completed (string) - @param module reference to the scanned module info (Module) - @keyparam doHierarchy flag indicating a hierarchical search (boolean) - @return list of possible completions (list of strings) + @param editor reference to the editor object + @type Editor + @param word string to be completed + @type str + @param context flag indicating to autocomplete a context + @type bool + @param sep separator string + @type str + @param prefix prefix of the word to be completed + @type str + @param module reference to the scanned module info + @type Module + @param doHierarchy flag indicating a hierarchical search + @type bool + @return list of possible completions + @rtype list of str """ completionsList = [] @@ -682,7 +719,8 @@ """ Private method to set the calltip hook. - @param editor reference to the editor (QScintilla.Editor) + @param editor reference to the editor + @type Editor """ editor.addCallTipHook("Assistant", self.calltips) @@ -690,7 +728,8 @@ """ Private method to unset the calltip hook. - @param editor reference to the editor (QScintilla.Editor) + @param editor reference to the editor + @type Editor """ editor.removeCallTipHook("Assistant") @@ -698,11 +737,14 @@ """ Public method to return a list of calltips. - @param editor reference to the editor (QScintilla.Editor) - @param pos position in the text for the calltip (integer) + @param editor reference to the editor + @type Editor + @param pos position in the text for the calltip + @type int @param commas minimum number of commas contained in the calltip - (integer) - @return list of possible calltips (list of strings) + @type int + @return list of possible calltips + @rtype list of str """ language = editor.getApiLanguage() completeFromDocumentOnly = False @@ -786,14 +828,20 @@ """ Private method to determine calltips from APIs. - @param api reference to the API object to be used (APIsManager.DbAPIs) - @param word function to get calltips for (string) + @param api reference to the API object to be used + @type APIsManager.DbAPIs + @param word function to get calltips for + @type str @param commas minimum number of commas contained in the calltip - (integer) - @param prefix prefix of the word to be completed (string) - @param module reference to the scanned module info (Module) - @param editor reference to the editor object (QScintilla.Editor) - @return list of calltips (list of string) + @type int + @param prefix prefix of the word to be completed + @type str + @param module reference to the scanned module info + @type Module + @param editor reference to the editor object + @type Editor + @return list of calltips + @rtype list of str """ calltips = [] if prefix and module and prefix == "self": @@ -823,12 +871,18 @@ """ Private method to determine calltips from the document. - @param word function to get calltips for (string) - @param prefix prefix of the word to be completed (string) - @param module reference to the scanned module info (Module) - @param editor reference to the editor object (QScintilla.Editor) - @keyparam doHierarchy flag indicating a hierarchical search (boolean) - @return list of calltips (list of string) + @param word function to get calltips for + @type str + @param prefix prefix of the word to be completed + @type str + @param module reference to the scanned module info + @type Module + @param editor reference to the editor object + @type Editor + @param doHierarchy flag indicating a hierarchical search + @type bool + @return list of calltips + @rtype list of str """ calltips = [] if module and bool(editor.getLexer()):