Skip to content

Commit 6cfcae2

Browse files
authored
Merge pull request #491 from aycabta/fix-for-symbol-detection-when-nested-method
Fix for symbol detection when nested method
2 parents e9ab533 + 5a1d0f8 commit 6cfcae2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ def identify_identifier
10851085
token.concat getc
10861086
end
10871087
elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_DOT ||
1088-
@lex_state == :EXPR_ARG
1088+
@lex_state == :EXPR_ARG || @lex_state == :EXPR_MID
10891089
@lex_state = :EXPR_ARG
10901090
else
10911091
@lex_state = :EXPR_END

test/test_rdoc_ruby_lex.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,21 @@ def test_class_tokenize_particular_kind_of_symbols
883883
assert_equal expected, tokens
884884
end
885885

886+
def test_class_tokenize_symbol_for_nested_method
887+
tokens = RDoc::RubyLex.tokenize 'return untrace_var :name', nil
888+
889+
expected = [
890+
@TK::TkRETURN .new( 0, 1, 0, "return"),
891+
@TK::TkSPACE .new( 6, 1, 6, " "),
892+
@TK::TkIDENTIFIER.new( 7, 1, 7, "untrace_var"),
893+
@TK::TkSPACE .new(18, 1, 18, " "),
894+
@TK::TkSYMBOL .new(19, 1, 19, ":name"),
895+
@TK::TkNL .new(24, 1, 24, "\n"),
896+
]
897+
898+
assert_equal expected, tokens
899+
end
900+
886901
def test_class_tokenize_symbol_with_quote
887902
tokens = RDoc::RubyLex.tokenize <<RUBY, nil
888903
a.include?()?"a":"b"

0 commit comments

Comments
 (0)