diff options
author | tomoya ishida <[email protected]> | 2023-11-30 01:30:08 +0900 |
---|---|---|
committer | git <[email protected]> | 2023-11-29 16:30:13 +0000 |
commit | 86d9a6dcb61b47bcacfe98200cb6d47da6bb1134 (patch) | |
tree | 1c5a777119c0fb94341857139059faee446ac636 /lib/irb/context.rb | |
parent | b549722eefaf1d7b43b607d96778f82fecc92e43 (diff) |
[ruby/irb] Use gem repl_type_completor, remove type_completion
implementation
(https://github.com/ruby/irb/pull/772)
https://github.com/ruby/irb/commit/a4868a5373
Diffstat (limited to 'lib/irb/context.rb')
-rw-r--r-- | lib/irb/context.rb | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/irb/context.rb b/lib/irb/context.rb index 3442fbf4da..ffbba4e8b1 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -176,26 +176,22 @@ module IRB RegexpCompletor.new end - TYPE_COMPLETION_REQUIRED_PRISM_VERSION = '0.18.0' - private def build_type_completor - unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') && RUBY_ENGINE != 'truffleruby' - warn 'TypeCompletion requires RUBY_VERSION >= 3.0.0' + if RUBY_ENGINE == 'truffleruby' + # Avoid SynatxError. truffleruby does not support endless method definition yet. + warn 'TypeCompletor is not supported on TruffleRuby yet' return end + begin - require 'prism' + require 'repl_type_completor' rescue LoadError => e - warn "TypeCompletion requires Prism: #{e.message}" + warn "TypeCompletor requires `gem repl_type_completor`: #{e.message}" return end - unless Gem::Version.new(Prism::VERSION) >= Gem::Version.new(TYPE_COMPLETION_REQUIRED_PRISM_VERSION) - warn "TypeCompletion requires Prism::VERSION >= #{TYPE_COMPLETION_REQUIRED_PRISM_VERSION}" - return - end - require 'irb/type_completion/completor' - TypeCompletion::Types.preload_in_thread - TypeCompletion::Completor.new + + ReplTypeCompletor.preload_rbs + TypeCompletor.new(self) end def save_history=(val) |