src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerUtilities.py

branch
eric7
changeset 10046
35b27af462ef
parent 9653
e67609152c5e
child 10362
cfa7034cccf6
diff -r f5c57f8d17a4 -r 35b27af462ef src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerUtilities.py
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerUtilities.py	Sat May 20 19:50:13 2023 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerUtilities.py	Sun May 21 15:26:11 2023 +0200
@@ -9,6 +9,8 @@
 
 from eric7.EricGui import EricPixmapCache
 
+from .translations import messageCategoryRe
+
 
 def setItemIcon(itm, column, msgCode, severity=None):
     """
@@ -23,32 +25,44 @@
     @param severity severity for message code 'S' (defaults to None)
     @type str (optional)
     """
-    if msgCode.startswith(("W", "-", "C", "M")):
+    match = messageCategoryRe.match(msgCode)
+    if match:
+        # the message code is OK
+        messageCategory = match.group(1)
+
+        if messageCategory in ("W", "C", "M"):
+            itm.setIcon(column, EricPixmapCache.getIcon("warning"))
+        elif messageCategory == "E":
+            itm.setIcon(column, EricPixmapCache.getIcon("syntaxError"))
+        elif messageCategory in ("A", "N"):
+            itm.setIcon(column, EricPixmapCache.getIcon("namingError"))
+        elif messageCategory == "D":
+            itm.setIcon(column, EricPixmapCache.getIcon("docstringError"))
+        elif messageCategory == "I":
+            itm.setIcon(column, EricPixmapCache.getIcon("imports"))
+        elif messageCategory == "NO":
+            itm.setIcon(column, EricPixmapCache.getIcon("nameOrderError"))
+        elif messageCategory == "P":
+            itm.setIcon(column, EricPixmapCache.getIcon("dirClosed"))
+        elif messageCategory == "Y":
+            itm.setIcon(column, EricPixmapCache.getIcon("filePython"))
+        elif messageCategory == "S":
+            if severity is None:
+                itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
+            else:
+                if severity == "H":
+                    itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
+                elif severity == "M":
+                    itm.setIcon(column, EricPixmapCache.getIcon("securityMedium"))
+                elif severity == "L":
+                    itm.setIcon(column, EricPixmapCache.getIcon("securityHigh"))
+                else:
+                    itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
+        else:
+            # unknown category prefix => warning
+            itm.setIcon(column, EricPixmapCache.getIcon("warning"))
+    elif msgCode.startswith("-"):
         itm.setIcon(column, EricPixmapCache.getIcon("warning"))
-    elif msgCode.startswith("E"):
-        itm.setIcon(column, EricPixmapCache.getIcon("syntaxError"))
-    elif msgCode.startswith(("A", "N")):
-        itm.setIcon(column, EricPixmapCache.getIcon("namingError"))
-    elif msgCode.startswith("D"):
-        itm.setIcon(column, EricPixmapCache.getIcon("docstringError"))
-    elif msgCode.startswith("I"):
-        itm.setIcon(column, EricPixmapCache.getIcon("imports"))
-    elif msgCode.startswith("P"):
-        itm.setIcon(column, EricPixmapCache.getIcon("dirClosed"))
-    elif msgCode.startswith("Y"):
-        itm.setIcon(column, EricPixmapCache.getIcon("filePython"))
-    elif msgCode.startswith("S"):
-        if severity is None:
-            itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
-        else:
-            if severity == "H":
-                itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
-            elif severity == "M":
-                itm.setIcon(column, EricPixmapCache.getIcon("securityMedium"))
-            elif severity == "L":
-                itm.setIcon(column, EricPixmapCache.getIcon("securityHigh"))
-            else:
-                itm.setIcon(column, EricPixmapCache.getIcon("securityLow"))
     else:
         # unknown category prefix => warning
         itm.setIcon(column, EricPixmapCache.getIcon("warning"))

eric ide

mercurial