Class: BEL::Completion::MatchNamespaceValueRule
- Inherits:
-
Object
- Object
- BEL::Completion::MatchNamespaceValueRule
- Defined in:
- lib/bel/completion_rule.rb
Overview
MatchNamespaceValueRule defines a namespace value completion rule.
Constant Summary
Constants included from Quoting
Quoting::KeywordMatcher, Quoting::Keywords, Quoting::LenientQuotedMatcher, Quoting::NonWordMatcher, Quoting::QuoteNotEscapedMatcher, Quoting::StrictQuotedMatcher
Instance Method Summary collapse
Methods included from Quoting
#always_quote, #ensure_quotes, #identifier_value?, #quote, #quote_if_needed, #quoted?, #quotes_required?, #remove_quotes, #string_value?, #unquote, #unquoted?
Methods included from Rule
Instance Method Details
#_apply(token_list, active_token, active_token_index, options = {}) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/bel/completion_rule.rb', line 191 def _apply(token_list, active_token, active_token_index, = {}) search = .delete(:search) namespaces = .delete(:namespaces) return EMPTY_MATCH if !search || !namespaces || token_list.empty? if active_token.type == :IDENT && active_token.value.length > 1 previous_token = token_list[active_token_index - 1] if previous_token and previous_token.type == :COLON # search within a namespace prefix_token = token_list[active_token_index - 2] if prefix_token and prefix_token.type == :IDENT namespace = namespaces.find(prefix_token.value.downcase).first if namespace return search.search( "#{active_token.value}*", :namespace_concept, namespace.uri.to_s, nil, :start => 0, :size => 10, :exclude_identifier_schemes => false ). map { |search_result| map_namespace_value(search_result.pref_label) }.to_a end end else return search.search( "#{active_token.value}*", :namespace_concept, nil, nil, :start => 0, :size => 10, :exclude_identifier_schemes => true ). map { |search_result| ns = namespaces.find(search_result.scheme_uri).first map_namespace_value_with_prefix(ns, search_result.pref_label) }.to_a end end return EMPTY_MATCH end |