[前][次][番号順一覧][スレッド一覧]

ruby-changes:64655

From: Nobuhiro <ko1@a...>
Date: Tue, 29 Dec 2020 16:07:38 +0900 (JST)
Subject: [ruby-changes:64655] 9b7ceb6765 (master): irb: add more syntax errors colorizing support (#3967)

https://git.ruby-lang.org/ruby.git/commit/?id=9b7ceb6765

From 9b7ceb676540d0061b2a31fee2da84ae31f93bae Mon Sep 17 00:00:00 2001
From: Nobuhiro IMAI <nov@y...>
Date: Tue, 29 Dec 2020 16:07:20 +0900
Subject: irb: add more syntax errors colorizing support (#3967)


diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index 56f5c4c..e3f4a1d 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -60,6 +60,10 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L60
         on_words_beg:       [[RED, BOLD],             ALL],
         on_parse_error:     [[RED, REVERSE],          ALL],
         compile_error:      [[RED, REVERSE],          ALL],
+        on_assign_error:    [[RED, REVERSE],          ALL],
+        on_alias_error:     [[RED, REVERSE],          ALL],
+        on_class_name_error:[[RED, REVERSE],          ALL],
+        on_param_error:     [[RED, REVERSE],          ALL],
       }
     rescue NameError
       # Give up highlighting Ripper-incompatible older Ruby
diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb
index 03c4ab7..c0682b1 100644
--- a/test/irb/test_color.rb
+++ b/test/irb/test_color.rb
@@ -82,9 +82,23 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_color.rb#L82
         tests.merge!({
           "[1]]]\u0013" => "[#{BLUE}#{BOLD}1#{CLEAR}]#{RED}#{REVERSE}]#{CLEAR}#{RED}#{REVERSE}]#{CLEAR}#{RED}#{REVERSE}^S#{CLEAR}",
         })
+        tests.merge!({
+          "def req(true) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}true#{CLEAR}) #{RED}#{REVERSE}end#{CLEAR}",
+          "nil = 1" => "#{RED}#{REVERSE}nil#{CLEAR} = #{BLUE}#{BOLD}1#{CLEAR}",
+          "alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} #{RED}#{REVERSE}$1#{CLEAR}",
+          "class bad; end" => "#{GREEN}class#{CLEAR} #{RED}#{REVERSE}bad#{CLEAR}; #{GREEN}end#{CLEAR}",
+          "def req(@a) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}@a#{CLEAR}) #{GREEN}end#{CLEAR}",
+        })
       else
         tests.merge!({
           "[1]]]\u0013" => "[1]]]^S",
+          })
+        tests.merge!({
+          "def req(true) end" => "def req(true) end",
+          "nil = 1" => "#{CYAN}#{BOLD}nil#{CLEAR} = #{BLUE}#{BOLD}1#{CLEAR}",
+          "alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} $1",
+          "class bad; end" => "#{GREEN}class#{CLEAR} bad; #{GREEN}end#{CLEAR}",
+          "def req(@a) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(@a) #{GREEN}end#{CLEAR}",
         })
       end
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]