File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -139,20 +139,19 @@ def set_prompt(p = nil, &block)
139
139
def self . ripper_lex_without_warning ( code , context : nil )
140
140
verbose , $VERBOSE = $VERBOSE, nil
141
141
if context
142
- lvars = context & .workspace &.binding &.local_variables
142
+ lvars = context . workspace &.binding &.local_variables
143
143
if lvars && !lvars . empty?
144
144
code = "#{ lvars . join ( '=' ) } =nil\n #{ code } "
145
145
line_no = 0
146
146
else
147
147
line_no = 1
148
148
end
149
149
end
150
- tokens = nil
150
+
151
151
compile_with_errors_suppressed ( code , line_no : line_no ) do |inner_code , line_no |
152
152
lexer = Ripper ::Lexer . new ( inner_code , '-' , line_no )
153
153
if lexer . respond_to? ( :scan ) # Ruby 2.7+
154
- tokens = [ ]
155
- lexer . scan . each do |t |
154
+ lexer . scan . each_with_object ( [ ] ) do |t , tokens |
156
155
next if t . pos . first == 0
157
156
prev_tk = tokens . last
158
157
position_overlapped = prev_tk && t . pos [ 0 ] == prev_tk . pos [ 0 ] && t . pos [ 1 ] < prev_tk . pos [ 1 ] + prev_tk . tok . bytesize
@@ -163,10 +162,9 @@ def self.ripper_lex_without_warning(code, context: nil)
163
162
end
164
163
end
165
164
else
166
- tokens = lexer . parse . reject { |it | it . pos . first == 0 }
165
+ lexer . parse . reject { |it | it . pos . first == 0 }
167
166
end
168
167
end
169
- tokens
170
168
ensure
171
169
$VERBOSE = verbose
172
170
end
You can’t perform that action at this time.
0 commit comments