Skip to content

Fix for symbol detection when nested method #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ def identify_identifier
token.concat getc
end
elsif @lex_state == :EXPR_BEG || @lex_state == :EXPR_DOT ||
@lex_state == :EXPR_ARG
@lex_state == :EXPR_ARG || @lex_state == :EXPR_MID
@lex_state = :EXPR_ARG
else
@lex_state = :EXPR_END
Expand Down
15 changes: 15 additions & 0 deletions test/test_rdoc_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,21 @@ def test_class_tokenize_particular_kind_of_symbols
assert_equal expected, tokens
end

def test_class_tokenize_symbol_for_nested_method
tokens = RDoc::RubyLex.tokenize 'return untrace_var :name', nil

expected = [
@TK::TkRETURN .new( 0, 1, 0, "return"),
@TK::TkSPACE .new( 6, 1, 6, " "),
@TK::TkIDENTIFIER.new( 7, 1, 7, "untrace_var"),
@TK::TkSPACE .new(18, 1, 18, " "),
@TK::TkSYMBOL .new(19, 1, 19, ":name"),
@TK::TkNL .new(24, 1, 24, "\n"),
]

assert_equal expected, tokens
end

def test_class_tokenize_symbol_with_quote
tokens = RDoc::RubyLex.tokenize <<RUBY, nil
a.include?()?"a":"b"
Expand Down