summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-09 10:17:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-09 10:17:33 +0000
commit72df0a8e4703c4e14cb2014d59d8ddad09a47859 (patch)
treec15b2730aa63ed9540d4abe1c1f0baf527a9515b
parent8776a09d4eed5662ee28eff0d829e880cc001684 (diff)
Add ignored_sp event
* ext/ripper/lib/ripper/lexer.rb (Ripper::Lexer): add ignored_sp event which will be fired from Ripper::Lexer#on_heredoc_dedent method. [ruby-core:91727] [Bug #15648] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/ripper/lib/ripper/lexer.rb6
-rw-r--r--test/ripper/test_scanner_events.rb7
2 files changed, 13 insertions, 0 deletions
diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb
index 344328482b8..95e1ebcdfe3 100644
--- a/ext/ripper/lib/ripper/lexer.rb
+++ b/ext/ripper/lib/ripper/lexer.rb
@@ -83,6 +83,12 @@ class Ripper
private
+ unless SCANNER_EVENT_TABLE.key?(:ignored_sp)
+ SCANNER_EVENT_TABLE[:ignored_sp] = 1
+ SCANNER_EVENTS << :ignored_sp
+ EVENTS << :ignored_sp
+ end
+
def on_heredoc_dedent(v, w)
ignored_sp = []
heredoc = @buf.last
diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb
index db15fd46ae6..1184b23435b 100644
--- a/test/ripper/test_scanner_events.rb
+++ b/test/ripper/test_scanner_events.rb
@@ -888,6 +888,13 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('ignored_nl', "1;\r\n")
end
+ def test_ignored_sp
+ assert_equal [],
+ scan('ignored_sp', "<<~EOS\nheredoc\nEOS")
+ assert_equal [" "],
+ scan('ignored_sp', "<<~EOS\n heredoc\nEOS")
+ end
+
def test___end__
assert_equal [],
scan('__end__', "")