Class: BEL::Completion::MatchFunctionRule

Inherits:
Object
  • Object
show all
Includes:
Rule
Defined in:
lib/bel/completion_rule.rb

Instance Method Summary collapse

Methods included from Rule

#apply

Instance Method Details

#_apply(token_list, active_token, active_token_index, options = {}) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/bel/completion_rule.rb', line 107

def _apply(token_list, active_token, active_token_index, options = {})
  if token_list.empty? or active_token.type == :O_PAREN
    return SORTED_FUNCTIONS.map { |fx| map_function(fx) }.uniq.sort_by { |fx|
      fx[:label]
    }
  end

  if active_token.type == :IDENT
    value = active_token.value.downcase
    return SORTED_FUNCTIONS.find_all { |x|
      x.downcase.include? value
    }.map { |fx| map_function(fx) }.uniq.sort_by { |fx| fx[:label] }
  end

  return EMPTY_MATCH
end