Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.

Tue, 10 Sep 2013 19:45:37 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Sep 2013 19:45:37 +0200
changeset 2904
1da821da961e
parent 2902
15a5fe0b0a09
child 2905
a1ae4b297bc0

Changed editor code to allow multiple syntax error messages per line and changed PEP-8 dialog to show E901 errors as error instead of warning.

Plugins/CheckerPlugins/Pep8/Pep8Dialog.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py	Tue Sep 10 19:05:23 2013 +0200
+++ b/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py	Tue Sep 10 19:45:37 2013 +0200
@@ -590,12 +590,16 @@
             lineno = item.data(0, self.lineRole)
             position = item.data(0, self.positionRole)
             message = item.data(0, self.messageRole)
+            code = item.data(0, self.codeRole)
             
             vm = e5App().getObject("ViewManager")
             vm.openSourceFile(fn, lineno=lineno, pos=position + 1)
             editor = vm.getOpenEditor(fn)
             
-            editor.toggleFlakesWarning(lineno, True, message)
+            if code == "E901":
+                editor.toggleSyntaxError(lineno, 0, True, message, True)
+            else:
+                editor.toggleFlakesWarning(lineno, True, message)
     
     @pyqtSlot()
     def on_resultList_itemSelectionChanged(self):
--- a/QScintilla/Editor.py	Tue Sep 10 19:05:23 2013 +0200
+++ b/QScintilla/Editor.py	Tue Sep 10 19:45:37 2013 +0200
@@ -158,7 +158,7 @@
         self.bookmarks = []         # bookmarks are just a list of handles to the
                                     # bookmark markers
         self.syntaxerrors = {}      # key:   marker handle
-                                    # value: error message, error index
+                                    # value: list of (error message, error index)
         self.warnings = {}          # key:   marker handle
                                     # value: list of warning messages
         self.notcoveredMarkers = []  # just a list of marker handles
@@ -5111,11 +5111,16 @@
             if not (markers & (1 << self.syntaxerror)):
                 handle = self.markerAdd(line - 1, self.syntaxerror)
                 index += self.indentation(line - 1)
-                self.syntaxerrors[handle] = (msg, index)
+                self.syntaxerrors[handle] = [(msg, index)]
                 self.syntaxerrorToggled.emit(self)
-                if show:
-                    self.setCursorPosition(line - 1, index)
-                    self.ensureLineVisible(line - 1)
+            else:
+                for handle in list(self.syntaxerrors.keys()):
+                    if self.markerLine(handle) == line - 1 and \
+                       (msg, index) not in self.syntaxerrors[handle]:
+                        self.syntaxerrors[handle].append((msg, index))
+            if show:
+                self.setCursorPosition(line - 1, index)
+                self.ensureLineVisible(line - 1)
         else:
             for handle in list(self.syntaxerrors.keys()):
                 if self.markerLine(handle) == line - 1:
@@ -5156,7 +5161,7 @@
             index = 0
             for handle in self.syntaxerrors.keys():
                 if self.markerLine(handle) == seline:
-                    index = self.syntaxerrors[handle][1]
+                    index = self.syntaxerrors[handle][0][1]
             self.setCursorPosition(seline, index)
         self.ensureLineVisible(seline)
         
@@ -5180,9 +5185,10 @@
         
         for handle in list(self.syntaxerrors.keys()):
             if self.markerLine(handle) == line:
+                errors = [e[0] for e in self.syntaxerrors[handle]]
                 E5MessageBox.critical(self,
                     self.trUtf8("Syntax Error"),
-                    self.syntaxerrors[handle][0])
+                    "\n".join(errors))
                 break
         else:
             E5MessageBox.critical(self,
@@ -5192,7 +5198,8 @@
     ############################################################################
     ## Flakes warning handling methods below
     ############################################################################
-
+    
+    # TODO: add flag for PEP-8 messages and record this flag in self.warnings
     def toggleFlakesWarning(self, line, warning, msg=""):
         """
         Public method to toggle a flakes warning indicator.
@@ -5319,6 +5326,7 @@
     ## Annotation handling methods below
     ############################################################################
     
+    # TODO: add additional annotations style (green) for PEP-8 warnings
     def __setAnnotationStyles(self):
         """
         Private slot to define the style used by inline annotations.
@@ -5340,6 +5348,7 @@
                 self.annotationErrorStyle,
                 Preferences.getEditorColour("AnnotationsErrorBackground"))
         
+    # TODO: show pep-8 warnings in a different color (green) with prefix 'Style:'
     def __setAnnotation(self, line):
         """
         Private method to set the annotations for the given line.
@@ -5360,9 +5369,9 @@
             # step 2: do syntax errors
             for handle in list(self.syntaxerrors.keys()):
                 if self.markerLine(handle) == line:
-                    errorAnnotations.append(
-                        self.trUtf8("Error: {0}").format(
-                            self.syntaxerrors[handle][0]))
+                    for msg, _ in self.syntaxerrors[handle]:
+                        errorAnnotations.append(
+                            self.trUtf8("Error: {0}").format(msg))
             
             wLen = len(warningAnnotations)
             eLen = len(errorAnnotations)

eric ide

mercurial