diff options
author | Schneems <[email protected]> | 2023-12-04 15:23:41 -0600 |
---|---|---|
committer | git <[email protected]> | 2023-12-05 17:51:28 +0000 |
commit | 62c96959114ea165f7434da9edc42d15e4aaebfa (patch) | |
tree | 6bb150da5f217babb4a0dd5d1e54def300b140a9 /lib/syntax_suggest/api.rb | |
parent | cce29750d797a85ac89540b9ad47816131652a2f (diff) |
[ruby/syntax_suggest] Support lexing with Prism
https://github.com/ruby/syntax_suggest/commit/7f4176a914
Diffstat (limited to 'lib/syntax_suggest/api.rb')
-rw-r--r-- | lib/syntax_suggest/api.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/syntax_suggest/api.rb b/lib/syntax_suggest/api.rb index e8b39f29f7..59f47ee4f3 100644 --- a/lib/syntax_suggest/api.rb +++ b/lib/syntax_suggest/api.rb @@ -5,23 +5,27 @@ require_relative "version" require "tmpdir" require "stringio" require "pathname" +require "timeout" -# rubocop:disable Style/IdenticalConditionalBranches -if ENV["SYNTAX_SUGGEST_DISABLE_PRISM"] # For testing dual ripper/prism support - require "ripper" +# We need Ripper loaded for `Prism.lex_compat` even if we're using Prism +# for lexing and parsing +require "ripper" + +# Prism is the new parser, replacing Ripper +# +# We need to "dual boot" both for now because syntax_suggest +# supports older rubies that do not ship with syntax suggest. +# +# We also need the ability to control loading of this library +# so we can test that both modes work correctly in CI. +if (value = ENV["SYNTAX_SUGGEST_DISABLE_PRISM"]) + warn "Skipping loading prism due to SYNTAX_SUGGEST_DISABLE_PRISM=#{value}" else - # TODO remove require - # Allow both to be loaded to enable more atomic commits - require "ripper" begin require "prism" rescue LoadError - require "ripper" end end -# rubocop:enable Style/IdenticalConditionalBranches - -require "timeout" module SyntaxSuggest # Used to indicate a default value that cannot |