diff options
author | Earlopain <[email protected]> | 2024-10-03 13:34:57 +0200 |
---|---|---|
committer | git <[email protected]> | 2024-10-03 12:52:02 +0000 |
commit | 66124cdb17f5152e7b1b269ca62be1773b127b2b (patch) | |
tree | 33de5f8bf96901b5ab8b7ea254bbb6d8a486311d | |
parent | cd96af2cb88a0b98add14eacf0005a8bee505d5d (diff) |
[ruby/prism] Use `partial_script` for the parser translators
Followup to https://github.com/ruby/prism/pull/3079
https://github.com/ruby/prism/commit/68f434e356
-rw-r--r-- | lib/prism/translation/parser.rb | 6 | ||||
-rw-r--r-- | lib/prism/translation/ripper.rb | 6 | ||||
-rw-r--r-- | lib/prism/translation/ruby_parser.rb | 4 |
3 files changed, 6 insertions, 10 deletions
diff --git a/lib/prism/translation/parser.rb b/lib/prism/translation/parser.rb index 8c7eb3aa75..969f2b95b0 100644 --- a/lib/prism/translation/parser.rb +++ b/lib/prism/translation/parser.rb @@ -51,7 +51,7 @@ module Prism source = source_buffer.source offset_cache = build_offset_cache(source) - result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]], encoding: false), offset_cache) + result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), partial_script: true, encoding: false), offset_cache) build_ast(result.value, offset_cache) ensure @@ -64,7 +64,7 @@ module Prism source = source_buffer.source offset_cache = build_offset_cache(source) - result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]], encoding: false), offset_cache) + result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), partial_script: true, encoding: false), offset_cache) [ build_ast(result.value, offset_cache), @@ -83,7 +83,7 @@ module Prism offset_cache = build_offset_cache(source) result = begin - unwrap(Prism.parse_lex(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]], encoding: false), offset_cache) + unwrap(Prism.parse_lex(source, filepath: source_buffer.name, version: convert_for_prism(version), partial_script: true, encoding: false), offset_cache) rescue ::Parser::SyntaxError raise if !recover end diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index cafe8c3f63..018842715b 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -3269,11 +3269,7 @@ module Prism # Lazily initialize the parse result. def result - @result ||= - begin - scopes = RUBY_VERSION >= "3.3.0" ? [] : [[]] - Prism.parse(source, scopes: scopes) - end + @result ||= Prism.parse(source, partial_script: true) end ########################################################################## diff --git a/lib/prism/translation/ruby_parser.rb b/lib/prism/translation/ruby_parser.rb index 4ccff0b600..189038d008 100644 --- a/lib/prism/translation/ruby_parser.rb +++ b/lib/prism/translation/ruby_parser.rb @@ -1596,13 +1596,13 @@ module Prism # Parse the given source and translate it into the seattlerb/ruby_parser # gem's Sexp format. def parse(source, filepath = "(string)") - translate(Prism.parse(source, filepath: filepath, scopes: [[]]), filepath) + translate(Prism.parse(source, filepath: filepath, partial_script: true), filepath) end # Parse the given file and translate it into the seattlerb/ruby_parser # gem's Sexp format. def parse_file(filepath) - translate(Prism.parse_file(filepath, scopes: [[]]), filepath) + translate(Prism.parse_file(filepath, partial_script: true), filepath) end class << self |