@@ -30,7 +30,8 @@ class Pref:
3030 "phpcs_show_quick_panel" ,
3131 "phpcs_php_prefix_path" ,
3232 "phpcs_commands_to_php_prefix" ,
33- "phpcs_icon_scope_color" ,
33+ "phpcs_icon_warning_color" ,
34+ "phpcs_icon_error_color" ,
3435 "phpcs_sniffer_run" ,
3536 "phpcs_command_on_save" ,
3637 "phpcs_executable_path" ,
@@ -108,13 +109,17 @@ def debug_message(msg):
108109
109110class CheckstyleError ():
110111 """Represents an error that needs to be displayed on the UI for the user"""
111- def __init__ (self , line , message ):
112+ def __init__ (self , line , message , severity ):
112113 self .line = line
113114 self .message = message
115+ self .severity = severity
114116
115117 def get_line (self ):
116118 return self .line
117119
120+ def get_severity (self ):
121+ return self .severity
122+
118123 def get_message (self ):
119124 data = self .message
120125
@@ -151,7 +156,7 @@ def get_errors(self, path):
151156
152157 def shell_out (self , cmd ):
153158 data = None
154-
159+
155160 for i , arg in enumerate (cmd ):
156161 if isinstance (arg , str ) and arg .startswith ('~' ):
157162 cmd [i ] = os .path .expanduser (arg )
@@ -236,7 +241,7 @@ def parse_report(self, args):
236241 lines = re .finditer ('.*line="(?P<line>\d+)" column="(?P<column>\d+)" severity="(?P<severity>\w+)" message="(?P<message>.*)" source' , report )
237242
238243 for line in lines :
239- error = CheckstyleError (line .group ('line' ), line .group ('message' ))
244+ error = CheckstyleError (line .group ('line' ), line .group ('message' ), line . group ( 'severity' ) )
240245 self .error_list .append (error )
241246
242247 def get_standards_available (self ):
@@ -513,7 +518,10 @@ def set_status_bar(self):
513518
514519 def generate (self ):
515520 self .error_list = []
516- region_set = []
521+ region_sets = {
522+ "warning" : [],
523+ "error" : []
524+ }
517525 self .error_lines = {}
518526
519527 for shell_command , report , icon in self .checkstyle_reports :
@@ -522,23 +530,31 @@ def generate(self):
522530
523531 debug_message (shell_command + ' found ' + str (len (report )) + ' errors' )
524532 for error in report :
533+
525534 line = int (error .get_line ())
526535 pt = self .view .text_point (line - 1 , 0 )
527536 region_line = self .view .line (pt )
528- region_set .append (region_line )
537+ region_sets [ error . get_severity ()] .append (region_line )
529538 self .error_list .append ('(' + str (line ) + ') ' + error .get_message ())
530539 error .set_point (pt )
531540 self .report .append (error )
532541 self .error_lines [line ] = error .get_message ()
533542
534543 if len (self .error_list ) > 0 :
535544 icon = icon if pref .phpcs_show_gutter_marks else ''
536- outline = sublime .DRAW_OUTLINED if pref .phpcs_outline_for_errors else sublime .HIDDEN
545+ outline = sublime .DRAW_STIPPLED_UNDERLINE | sublime . DRAW_NO_FILL | sublime . DRAW_NO_OUTLINE if pref .phpcs_outline_for_errors else sublime .HIDDEN
537546 if pref .phpcs_show_gutter_marks or pref .phpcs_outline_for_errors :
538- if pref .phpcs_icon_scope_color == None :
539- debug_message ("WARN: phpcs_icon_scope_color is not defined, so resorting to phpcs colour scope" )
540- pref .phpcs_icon_scope_color = "phpcs"
541- self .view .add_regions (shell_command , region_set , pref .phpcs_icon_scope_color , icon , outline )
547+
548+ if pref .phpcs_icon_warning_color == None :
549+ debug_message ("WARN: phpcs_icon_warning_color is not defined, so resorting to phpcs colour scope" )
550+ pref .phpcs_icon_warning_color = "phpcs"
551+
552+ if pref .phpcs_icon_error_color == None :
553+ debug_message ("WARN: phpcs_icon_error_color is not defined, so resorting to phpcs colour scope" )
554+ pref .phpcs_icon_error_color = "phpcs"
555+
556+ self .view .add_regions (shell_command + "Warning" , region_sets ["warning" ], pref .phpcs_icon_warning_color , icon , outline )
557+ self .view .add_regions (shell_command + "Error" , region_sets ["error" ], pref .phpcs_icon_error_color , icon , outline )
542558
543559 if pref .phpcs_show_quick_panel == True :
544560 # Skip showing the errors if we ran on save, and the option isn't set.
0 commit comments