mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
irb: add more syntax errors colorizing support (#3967)
This commit is contained in:
parent
c0a2d322c6
commit
9b7ceb6765
Notes:
git
2020-12-29 16:07:46 +09:00
Merged-By: k0kubun <takashikkbn@gmail.com>
2 changed files with 18 additions and 0 deletions
|
@ -60,6 +60,10 @@ module IRB # :nodoc:
|
||||||
on_words_beg: [[RED, BOLD], ALL],
|
on_words_beg: [[RED, BOLD], ALL],
|
||||||
on_parse_error: [[RED, REVERSE], ALL],
|
on_parse_error: [[RED, REVERSE], ALL],
|
||||||
compile_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
|
rescue NameError
|
||||||
# Give up highlighting Ripper-incompatible older Ruby
|
# Give up highlighting Ripper-incompatible older Ruby
|
||||||
|
|
|
@ -82,10 +82,24 @@ module TestIRB
|
||||||
tests.merge!({
|
tests.merge!({
|
||||||
"[1]]]\u0013" => "[#{BLUE}#{BOLD}1#{CLEAR}]#{RED}#{REVERSE}]#{CLEAR}#{RED}#{REVERSE}]#{CLEAR}#{RED}#{REVERSE}^S#{CLEAR}",
|
"[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
|
else
|
||||||
tests.merge!({
|
tests.merge!({
|
||||||
"[1]]]\u0013" => "[1]]]^S",
|
"[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
|
end
|
||||||
|
|
||||||
tests.each do |code, result|
|
tests.each do |code, result|
|
||||||
|
|
Loading…
Reference in a new issue