irb 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/irb.rb CHANGED
@@ -6,7 +6,6 @@
6
6
  #
7
7
 
8
8
  require "prism"
9
- require "ripper"
10
9
  require "reline"
11
10
 
12
11
  require_relative "irb/init"
@@ -22,6 +21,7 @@ require_relative "irb/color"
22
21
 
23
22
  require_relative "irb/version"
24
23
  require_relative "irb/easter-egg"
24
+ require_relative "irb/startup_message"
25
25
  require_relative "irb/debug"
26
26
  require_relative "irb/pager"
27
27
 
@@ -51,7 +51,13 @@ module IRB
51
51
  irb = Irb.new(nil, @CONF[:SCRIPT])
52
52
  else
53
53
  irb = Irb.new
54
+
55
+ # Only display the banner in the irb executable
56
+ if @CONF[:SHOW_BANNER] && ap_path&.end_with?("exe/irb")
57
+ StartupMessage.display
58
+ end
54
59
  end
60
+
55
61
  irb.run(@CONF)
56
62
  end
57
63
 
@@ -266,11 +272,10 @@ module IRB
266
272
  code << line
267
273
  return code if command?(code)
268
274
 
269
- tokens, opens, terminated = @scanner.check_code_state(code, local_variables: @context.local_variables)
275
+ continue, opens, terminated = @scanner.check_code_state(code, local_variables: @context.local_variables)
270
276
  return code if terminated
271
277
 
272
278
  line_offset += 1
273
- continue = @scanner.should_continue?(tokens)
274
279
  prompt = generate_prompt(opens, continue, line_offset)
275
280
  end
276
281
  end
@@ -331,7 +336,7 @@ module IRB
331
336
  else
332
337
  next true if command?(code)
333
338
 
334
- _tokens, _opens, terminated = @scanner.check_code_state(code, local_variables: @context.local_variables)
339
+ _continue, _opens, terminated = @scanner.check_code_state(code, local_variables: @context.local_variables)
335
340
  terminated
336
341
  end
337
342
  end
@@ -339,13 +344,17 @@ module IRB
339
344
  if @context.io.respond_to?(:dynamic_prompt)
340
345
  @context.io.dynamic_prompt do |lines|
341
346
  code = lines.map{ |l| l + "\n" }.join
342
- tokens = RubyLex.ripper_lex_without_warning(code, local_variables: @context.local_variables)
343
347
  parse_lex_result = Prism.parse_lex(code, scopes: [@context.local_variables])
344
348
  line_results = IRB::NestingParser.parse_by_line(parse_lex_result)
349
+
350
+ tokens = parse_lex_result.value[1].map(&:first)
351
+ tokens_by_line = tokens.group_by {|t| t.location.start_line - 1 }
352
+
345
353
  tokens_until_line = []
346
354
  line_results.map.with_index do |(_prev_opens, next_opens, _min_depth), line_num_offset|
347
- tokens_until_line << tokens.shift while !tokens.empty? && tokens.first.pos[0] <= line_num_offset + 1
348
- continue = @scanner.should_continue?(tokens_until_line)
355
+ line = lines[line_num_offset]
356
+ tokens_until_line.concat(tokens_by_line[line_num_offset] || [])
357
+ continue = @scanner.should_continue?(tokens_until_line, line, line_num_offset + 1)
349
358
  generate_prompt(next_opens, continue, line_num_offset)
350
359
  end
351
360
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aycabta
@@ -159,6 +159,7 @@ files:
159
159
  - lib/irb/ruby-lex.rb
160
160
  - lib/irb/ruby_logo.aa
161
161
  - lib/irb/source_finder.rb
162
+ - lib/irb/startup_message.rb
162
163
  - lib/irb/statement.rb
163
164
  - lib/irb/version.rb
164
165
  - lib/irb/workspace.rb