class Yoda::Evaluation::CommentCompletion::TypeProvider
Public Instance Methods
available?()
click to toggle source
@return [true, false]
# File lib/yoda/evaluation/comment_completion/type_provider.rb, line 6 def available? [:type, :type_tag_type].include?(current_comment_token_query.current_state) end
candidates()
click to toggle source
@return [Array<Model::CompletionItem>]
# File lib/yoda/evaluation/comment_completion/type_provider.rb, line 11 def candidates description_candidates.map { |description| Model::CompletionItem.new(description: description, range: substitution_range) } end
Private Instance Methods
description_candidates()
click to toggle source
@return [Array<Model::Descriptions::Base>]
# File lib/yoda/evaluation/comment_completion/type_provider.rb, line 18 def description_candidates return [] unless available? scoped_path = Model::ScopedPath.new(lexical_scope(namespace), index_word) Store::Query::FindConstant.new(registry).select_with_prefix(scoped_path).map { |obj| Model::Descriptions::ValueDescription.new(obj) } end
index_word()
click to toggle source
@return [String]
# File lib/yoda/evaluation/comment_completion/type_provider.rb, line 41 def index_word current_comment_token_query.at_sign? ? '' : current_comment_token_query.current_word end
lexical_scope(namespace)
click to toggle source
@param namespace [Parsing::NodeObjects::Namespace] @return [Array<Path>]
# File lib/yoda/evaluation/comment_completion/type_provider.rb, line 52 def lexical_scope(namespace) namespace.paths_from_root.reverse.map { |name| Model::Path.build(name.empty? ? 'Object' : name.gsub(/\A::/, '')) } end
namespace()
click to toggle source
@return [Parsing::NodeObjects::Namespace, nil]
# File lib/yoda/evaluation/comment_completion/type_provider.rb, line 46 def namespace current_commenting_node_query.current_namespace end
substitution_range()
click to toggle source
@return [Parsing::Range, nil]
# File lib/yoda/evaluation/comment_completion/type_provider.rb, line 25 def substitution_range return nil unless available? # @todo Move this routine to Parsing module if current_comment_token_query.current_range range = current_comment_token_query.current_range.move( row: current_comment_query.begin_point_of_current_comment_block.row - 1, column: current_comment_query.begin_point_of_current_comment_block.column, ) cut_point = current_comment_token_query.at_sign? ? 1 : (current_comment_token_query.current_word.rindex('::') || -2) + 2 Parsing::Range.new(range.begin_location.move(row: 0, column: cut_point), range.end_location) else Parsing::Range.new(location, location) end end