Wed, 03 Jan 2024 17:36:30 +0100
Editor
- Changed the list of supported editor warning types to an enum.Enum.
--- a/src/eric7/APIs/Python3/eric7.api Wed Jan 03 16:29:32 2024 +0100 +++ b/src/eric7/APIs/Python3/eric7.api Wed Jan 03 17:36:30 2024 +0100 @@ -8447,11 +8447,6 @@ eric7.QScintilla.Editor.Editor.StartEditToken?7 eric7.QScintilla.Editor.Editor.SyncToken?7 eric7.QScintilla.Editor.Editor.VcsConflictMarkerLineRegExpList?7 -eric7.QScintilla.Editor.Editor.WarningCode?7 -eric7.QScintilla.Editor.Editor.WarningError?7 -eric7.QScintilla.Editor.Editor.WarningInfo?7 -eric7.QScintilla.Editor.Editor.WarningPython?7 -eric7.QScintilla.Editor.Editor.WarningStyle?7 eric7.QScintilla.Editor.Editor.addCallTipHook?4(key, func) eric7.QScintilla.Editor.Editor.addClone?4(editor) eric7.QScintilla.Editor.Editor.addCompletionListHook?4(key, func, asynchroneous=False) @@ -8681,7 +8676,7 @@ eric7.QScintilla.Editor.Editor.toggleComment?4() eric7.QScintilla.Editor.Editor.toggleCurrentFold?4() eric7.QScintilla.Editor.Editor.toggleSyntaxError?4(line, index, setError, msg="", show=False) -eric7.QScintilla.Editor.Editor.toggleWarning?4(line, col, setWarning, msg="", warningType=WarningCode) +eric7.QScintilla.Editor.Editor.toggleWarning?4(line, col, setWarning, msg="", warningType=EditorWarningKind.Code, ) eric7.QScintilla.Editor.Editor.uncommentLineOrSelection?4() eric7.QScintilla.Editor.Editor.undo?4() eric7.QScintilla.Editor.Editor.undoAvailable?7 @@ -8707,6 +8702,11 @@ eric7.QScintilla.Editor.EditorIconId.MethodProtected?7 eric7.QScintilla.Editor.EditorIconId.Module?7 eric7.QScintilla.Editor.EditorIconId.TemplateImage?7 +eric7.QScintilla.Editor.EditorWarningKind.Code?7 +eric7.QScintilla.Editor.EditorWarningKind.Error?7 +eric7.QScintilla.Editor.EditorWarningKind.Info?7 +eric7.QScintilla.Editor.EditorWarningKind.Python?7 +eric7.QScintilla.Editor.EditorWarningKind.Style?7 eric7.QScintilla.Editor.ReferenceItem?7 eric7.QScintilla.Editor.ReferencesListID?7 eric7.QScintilla.Editor.TemplateCompletionListID?7
--- a/src/eric7/APIs/Python3/eric7.bas Wed Jan 03 16:29:32 2024 +0100 +++ b/src/eric7/APIs/Python3/eric7.bas Wed Jan 03 17:36:30 2024 +0100 @@ -221,6 +221,7 @@ EditorStylesPage ConfigurationPageBase Ui_EditorStylesPage EditorSyntaxPage ConfigurationPageBase Ui_EditorSyntaxPage EditorTypingPage ConfigurationPageBase Ui_EditorTypingPage +EditorWarningKind enum.Enum EmailDialog QDialog Ui_EmailDialog EmailPage ConfigurationPageBase Ui_EmailPage EnchantHighlighter QSyntaxHighlighter
--- a/src/eric7/Documentation/Help/source.qhp Wed Jan 03 16:29:32 2024 +0100 +++ b/src/eric7/Documentation/Help/source.qhp Wed Jan 03 17:36:30 2024 +0100 @@ -5263,6 +5263,7 @@ <keyword name="EditorTypingPage (Module)" id="EditorTypingPage (Module)" ref="eric7.Preferences.ConfigurationPages.EditorTypingPage.html" /> <keyword name="EditorTypingPage.on_languageCombo_activated" id="EditorTypingPage.on_languageCombo_activated" ref="eric7.Preferences.ConfigurationPages.EditorTypingPage.html#EditorTypingPage.on_languageCombo_activated" /> <keyword name="EditorTypingPage.save" id="EditorTypingPage.save" ref="eric7.Preferences.ConfigurationPages.EditorTypingPage.html#EditorTypingPage.save" /> + <keyword name="EditorWarningKind" id="EditorWarningKind" ref="eric7.QScintilla.Editor.html#EditorWarningKind" /> <keyword name="EmailDialog" id="EmailDialog" ref="eric7.UI.EmailDialog.html#EmailDialog" /> <keyword name="EmailDialog (Constructor)" id="EmailDialog (Constructor)" ref="eric7.UI.EmailDialog.html#EmailDialog.__init__" /> <keyword name="EmailDialog (Module)" id="EmailDialog (Module)" ref="eric7.UI.EmailDialog.html" />
--- a/src/eric7/Documentation/Source/eric7.QScintilla.Editor.html Wed Jan 03 16:29:32 2024 +0100 +++ b/src/eric7/Documentation/Source/eric7.QScintilla.Editor.html Wed Jan 03 17:36:30 2024 +0100 @@ -28,6 +28,10 @@ <td><a href="#EditorIconId">EditorIconId</a></td> <td>Class defining the completion icon IDs.</td> </tr> +<tr> +<td><a href="#EditorWarningKind">EditorWarningKind</a></td> +<td>Class defining the kind of warnings supported by the Editor class.</td> +</tr> </table> <h3>Functions</h3> @@ -171,7 +175,7 @@ <h3>Class Attributes</h3> <table> -<tr><td>CancelEditToken</td></tr><tr><td>EncloseChars</td></tr><tr><td>EndEditToken</td></tr><tr><td>RequestSyncToken</td></tr><tr><td>Separator</td></tr><tr><td>StartEditToken</td></tr><tr><td>SyncToken</td></tr><tr><td>VcsConflictMarkerLineRegExpList</td></tr><tr><td>WarningCode</td></tr><tr><td>WarningError</td></tr><tr><td>WarningInfo</td></tr><tr><td>WarningPython</td></tr><tr><td>WarningStyle</td></tr> +<tr><td>CancelEditToken</td></tr><tr><td>EncloseChars</td></tr><tr><td>EndEditToken</td></tr><tr><td>RequestSyncToken</td></tr><tr><td>Separator</td></tr><tr><td>StartEditToken</td></tr><tr><td>SyncToken</td></tr><tr><td>VcsConflictMarkerLineRegExpList</td></tr> </table> <h3>Class Methods</h3> @@ -2312,10 +2316,9 @@ </p> <dl> -<dt><i>warningKind</i> (int)</dt> -<dd> -kind of warning to clear (Editor.WarningCode, - Editor.WarningPython, Editor.WarningStyle) +<dt><i>warningKind</i> (EditorWarningKind)</dt> +<dd> +kind of warning to clear </dd> </dl> <a NAME="Editor.__codeCoverageHideAnnotations" ID="Editor.__codeCoverageHideAnnotations"></a> @@ -7614,7 +7617,7 @@ </dl> <a NAME="Editor.toggleWarning" ID="Editor.toggleWarning"></a> <h4>Editor.toggleWarning</h4> -<b>toggleWarning</b>(<i>line, col, setWarning, msg="", warningType=WarningCode</i>) +<b>toggleWarning</b>(<i>line, col, setWarning, msg="", warningType=EditorWarningKind.Code, </i>) <p> Public method to toggle a warning indicator. @@ -7641,7 +7644,7 @@ <dd> warning message </dd> -<dt><i>warningType</i> (int)</dt> +<dt><i>warningType</i> (EditorWarningKind)</dt> <dd> type of warning message </dd> @@ -7798,4 +7801,36 @@ <div align="right"><a href="#top">Up</a></div> <hr /> +<hr /> +<a NAME="EditorWarningKind" ID="EditorWarningKind"></a> +<h2>EditorWarningKind</h2> + +<p> + Class defining the kind of warnings supported by the Editor class. +</p> +<h3>Derived from</h3> +enum.Enum +<h3>Class Attributes</h3> + +<table> +<tr><td>Code</td></tr><tr><td>Error</td></tr><tr><td>Info</td></tr><tr><td>Python</td></tr><tr><td>Style</td></tr> +</table> +<h3>Class Methods</h3> + +<table> +<tr><td>None</td></tr> +</table> +<h3>Methods</h3> + +<table> +<tr><td>None</td></tr> +</table> +<h3>Static Methods</h3> + +<table> +<tr><td>None</td></tr> +</table> + +<div align="right"><a href="#top">Up</a></div> +<hr /> </body></html> \ No newline at end of file
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Wed Jan 03 16:29:32 2024 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py Wed Jan 03 17:36:30 2024 +0100 @@ -30,6 +30,7 @@ from eric7 import Preferences, Utilities from eric7.EricGui import EricPixmapCache from eric7.EricWidgets.EricApplication import ericApp +from eric7.QScintilla.Editor import EditorWarningKind from eric7.SystemUtilities import FileSystemUtilities from . import CodeStyleCheckerUtilities, pycodestyle @@ -1570,7 +1571,7 @@ editor.toggleSyntaxError(lineno, 0, True, message, True) else: editor.toggleWarning( - lineno, 0, True, message, warningType=editor.WarningStyle + lineno, 0, True, message, warningType=EditorWarningKind.Style ) editor.updateVerticalScrollBar() @@ -1606,7 +1607,7 @@ lineno = citm.data(0, self.lineRole) message = citm.data(0, self.messageRole) editor.toggleWarning( - lineno, 0, True, message, warningType=editor.WarningStyle + lineno, 0, True, message, warningType=EditorWarningKind.Style ) # go through the list again to clear warning markers for files,
--- a/src/eric7/QScintilla/Editor.py Wed Jan 03 16:29:32 2024 +0100 +++ b/src/eric7/QScintilla/Editor.py Wed Jan 03 17:36:30 2024 +0100 @@ -92,6 +92,18 @@ TemplateImage = 100 +class EditorWarningKind(enum.Enum): + """ + Class defining the kind of warnings supported by the Editor class. + """ + + Code = 1 + Python = 2 + Style = 3 + Info = 4 + Error = 5 + + class Editor(QsciScintillaCompat): """ Class implementing the editor component of the eric IDE. @@ -169,13 +181,6 @@ settingsRead = pyqtSignal() mouseDoubleClick = pyqtSignal(QPoint, Qt.MouseButton) - # TODO: convert to an enum.Enum - WarningCode = 1 - WarningPython = 2 - WarningStyle = 3 - WarningInfo = 4 - WarningError = 5 - # Cooperation related definitions Separator = "@@@" @@ -6764,10 +6769,14 @@ self.toggleSyntaxError(lineno, col, True, msg) for _fn, lineno, col, _code, msg in problems.get("py_warnings", []): - self.toggleWarning(lineno, col, True, msg, warningType=Editor.WarningPython) + self.toggleWarning( + lineno, col, True, msg, warningType=EditorWarningKind.Python + ) for _fn, lineno, col, _code, msg in problems.get("warnings", []): - self.toggleWarning(lineno, col, True, msg, warningType=Editor.WarningCode) + self.toggleWarning( + lineno, col, True, msg, warningType=EditorWarningKind.Code + ) self.updateVerticalScrollBar() @@ -7222,7 +7231,12 @@ ########################################################################### def toggleWarning( - self, line, col, setWarning, msg="", warningType=WarningCode # noqa: U100 + self, + line, + col, # noqa: U100 + setWarning, + msg="", + warningType=EditorWarningKind.Code, ): """ Public method to toggle a warning indicator. @@ -7239,7 +7253,7 @@ @param msg warning message @type str @param warningType type of warning message - @type int + @type EditorWarningKind """ if line == 0: line = 1 @@ -7343,44 +7357,43 @@ """ Public slot to clear all pyflakes warnings. """ - self.__clearTypedWarning(Editor.WarningCode) - self.__clearTypedWarning(Editor.WarningPython) + self.__clearTypedWarning(EditorWarningKind.Code) + self.__clearTypedWarning(EditorWarningKind.Python) @pyqtSlot() def clearStyleWarnings(self): """ Public slot to clear all style warnings. """ - self.__clearTypedWarning(Editor.WarningStyle) + self.__clearTypedWarning(EditorWarningKind.Style) @pyqtSlot() def clearInfoWarnings(self): """ Public slot to clear all info warnings. """ - self.__clearTypedWarning(Editor.WarningInfo) + self.__clearTypedWarning(EditorWarningKind.Info) @pyqtSlot() def clearErrorWarnings(self): """ Public slot to clear all error warnings. """ - self.__clearTypedWarning(Editor.WarningError) + self.__clearTypedWarning(EditorWarningKind.Error) @pyqtSlot() def clearCodeWarnings(self): """ Public slot to clear all code warnings. """ - self.__clearTypedWarning(Editor.WarningCode) + self.__clearTypedWarning(EditorWarningKind.Code) def __clearTypedWarning(self, warningKind): """ Private method to clear warnings of a specific kind. - @param warningKind kind of warning to clear (Editor.WarningCode, - Editor.WarningPython, Editor.WarningStyle) - @type int + @param warningKind kind of warning to clear + @type EditorWarningKind """ for handle in list(self._warnings): issues = [] @@ -7512,13 +7525,13 @@ for handle in self._warnings: if self.markerLine(handle) == line: for msg, warningType in self._warnings[handle]: - if warningType == Editor.WarningInfo: + if warningType == EditorWarningKind.Info: infoAnnotations.append(self.tr("Info: {0}").format(msg)) - elif warningType == Editor.WarningError: + elif warningType == EditorWarningKind.Error: errorAnnotations.append(self.tr("Error: {0}").format(msg)) - elif warningType == Editor.WarningStyle: + elif warningType == EditorWarningKind.Style: styleAnnotations.append(self.tr("Style: {0}").format(msg)) - elif warningType == Editor.WarningPython: + elif warningType == EditorWarningKind.Python: warningAnnotations.append(msg) else: warningAnnotations.append(