Class: Yoda::Services::CodeCompletion::LocalVariableProvider
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- Yoda::Services::CodeCompletion::LocalVariableProvider
- Defined in:
- lib/yoda/services/code_completion/local_variable_provider.rb
Instance Attribute Summary
Attributes inherited from BaseProvider
#ast, #environment, #evaluator, #location
Instance Method Summary collapse
Methods inherited from BaseProvider
Constructor Details
This class inherits a constructor from Yoda::Services::CodeCompletion::BaseProvider
Instance Method Details
#candidates ⇒ Array<Model::CompletionItem>
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/yoda/services/code_completion/local_variable_provider.rb', line 14 def candidates return [] unless providable? local_variables.select { |variable_name, _| variable_name.to_s.start_with?(index_word) }.map do |variable_name, type_expression| Model::CompletionItem.new( description: Model::Descriptions::VariableDescription.new(variable: variable_name, type: type_expression), range: substitution_range, kind: :variable, ) end end |
#providable? ⇒ true, false
7 8 9 10 11 |
# File 'lib/yoda/services/code_completion/local_variable_provider.rb', line 7 def providable? return false unless current_node return true if index_word false end |