Class: IRB::TypeCompletor
- Inherits:
-
BaseCompletor
- Object
- BaseCompletor
- IRB::TypeCompletor
- Defined in:
- lib/irb/completion.rb
Overview
:nodoc:
Constant Summary
Constants inherited from BaseCompletor
BaseCompletor::GEM_PATHS, BaseCompletor::HELP_COMMAND_PREPOSING
Instance Method Summary collapse
- #completion_candidates(preposing, target, _postposing, bind:) ⇒ Object
- #doc_namespace(preposing, matched, _postposing, bind:) ⇒ Object
-
#initialize(context) ⇒ TypeCompletor
constructor
A new instance of TypeCompletor.
- #inspect ⇒ Object
Methods inherited from BaseCompletor
#command_candidates, #retrieve_files_to_require_from_load_path, #retrieve_files_to_require_relative_from_current_dir, #retrieve_gem_and_system_load_path
Constructor Details
#initialize(context) ⇒ TypeCompletor
Returns a new instance of TypeCompletor.
87 88 89 |
# File 'lib/irb/completion.rb', line 87 def initialize(context) @context = context end |
Instance Method Details
#completion_candidates(preposing, target, _postposing, bind:) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/irb/completion.rb', line 95 def completion_candidates(preposing, target, _postposing, bind:) # When completing the argument of `help` command, only commands should be candidates return command_candidates(target) if preposing.match?(HELP_COMMAND_PREPOSING) commands = if preposing.empty? command_candidates(target) # It doesn't make sense to propose commands with other preposing else [] end result = ReplTypeCompletor.analyze(preposing + target, binding: bind, filename: @context.irb_path) return commands unless result encoded_candidates = result.completion_candidates.filter_map do |i| encoded = i.encode(Encoding.default_external) target + encoded rescue Encoding::UndefinedConversionError # If the string cannot be converted, we just ignore it nil end commands | encoded_candidates end |
#doc_namespace(preposing, matched, _postposing, bind:) ⇒ Object
120 121 122 123 |
# File 'lib/irb/completion.rb', line 120 def doc_namespace(preposing, matched, _postposing, bind:) result = ReplTypeCompletor.analyze(preposing + matched, binding: bind, filename: @context.irb_path) result&.doc_namespace('') end |
#inspect ⇒ Object
91 92 93 |
# File 'lib/irb/completion.rb', line 91 def inspect ReplTypeCompletor.info end |