Class: BEL::Completion::MatchNamespacePrefixRule
- Inherits:
-
Object
- Object
- BEL::Completion::MatchNamespacePrefixRule
- Includes:
- Rule
- Defined in:
- lib/bel/completion_rule.rb
Overview
MatchNamespacePrefixRule defines a namespace completion rule. TODO Namespces should be passed as state, not hardcoded.
Instance Method Summary collapse
Methods included from Rule
Instance Method Details
#_apply(token_list, active_token, active_token_index, options = {}) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/bel/completion_rule.rb', line 151 def _apply(token_list, active_token, active_token_index, = {}) if token_list.empty? or active_token.type == :O_PAREN return SORTED_NAMESPACES.map { |ns_prefix| map_namespace_prefix(ns_prefix) } end # first token is always function return [] if active_token == token_list[0] if active_token.type == :IDENT value = active_token.value.downcase return SORTED_NAMESPACES.find_all { |x| x.downcase.include? value }.map { |ns_prefix| map_namespace_prefix(ns_prefix) } end return EMPTY_MATCH end |