@@ -27,19 +27,19 @@ class CodeLine
2727 # Returns an array of CodeLine objects
2828 # from the source string
2929 def self . from_source ( source )
30- lex_array_for_line = LexAll . new ( source : source ) . each_with_object ( Hash . new { |h , k | h [ k ] = [ ] } ) { |lex , hash | hash [ lex . line ] << lex }
30+ tokens_for_line = LexAll . new ( source : source ) . each_with_object ( Hash . new { |h , k | h [ k ] = [ ] } ) { |token , hash | hash [ token . line ] << token }
3131 source . lines . map . with_index do |line , index |
3232 CodeLine . new (
3333 line : line ,
3434 index : index ,
35- lex : lex_array_for_line [ index + 1 ]
35+ tokens : tokens_for_line [ index + 1 ]
3636 )
3737 end
3838 end
3939
40- attr_reader :line , :index , :lex , :line_number , :indent
41- def initialize ( line :, index :, lex :)
42- @lex = lex
40+ attr_reader :line , :index , :tokens , :line_number , :indent
41+ def initialize ( line :, index :, tokens :)
42+ @tokens = tokens
4343 @line = line
4444 @index = index
4545 @original = line
@@ -180,12 +180,12 @@ def ignore_newline_not_beg?
180180 # expect(lines.first.trailing_slash?).to eq(true)
181181 #
182182 def trailing_slash?
183- last = @lex . last
183+ last = @tokens . last
184184
185185 # Older versions of prism diverged slightly from Ripper in compatibility mode
186186 case last &.type
187187 when :on_sp
188- last . token == TRAILING_SLASH
188+ last . value == TRAILING_SLASH
189189 when :on_tstring_end
190190 true
191191 else
@@ -209,21 +209,21 @@ def trailing_slash?
209209 end_count = 0
210210
211211 @ignore_newline_not_beg = false
212- @lex . each do |lex |
213- kw_count += 1 if lex . is_kw?
214- end_count += 1 if lex . is_end?
212+ @tokens . each do |token |
213+ kw_count += 1 if token . is_kw?
214+ end_count += 1 if token . is_end?
215215
216- if lex . type == :on_ignored_nl
217- @ignore_newline_not_beg = !lex . expr_beg?
216+ if token . type == :on_ignored_nl
217+ @ignore_newline_not_beg = !token . expr_beg?
218218 end
219219
220220 if in_oneliner_def . nil?
221- in_oneliner_def = :ENDFN if lex . state . allbits? ( Ripper ::EXPR_ENDFN )
222- elsif lex . state . allbits? ( Ripper ::EXPR_ENDFN )
221+ in_oneliner_def = :ENDFN if token . state . allbits? ( Ripper ::EXPR_ENDFN )
222+ elsif token . state . allbits? ( Ripper ::EXPR_ENDFN )
223223 # Continue
224- elsif lex . state . allbits? ( Ripper ::EXPR_BEG )
225- in_oneliner_def = :BODY if lex . token == "="
226- elsif lex . state . allbits? ( Ripper ::EXPR_END )
224+ elsif token . state . allbits? ( Ripper ::EXPR_BEG )
225+ in_oneliner_def = :BODY if token . value == "="
226+ elsif token . state . allbits? ( Ripper ::EXPR_END )
227227 # We found an endless method, count it
228228 oneliner_count += 1 if in_oneliner_def == :BODY
229229
0 commit comments