Class: BEL::Completion::MatchNamespaceValueRule
- Inherits:
-
Object
- Object
- BEL::Completion::MatchNamespaceValueRule
- Defined in:
- lib/bel/completion_rule.rb
Constant Summary
Constants included from Quoting
Quoting::KeywordMatcher, Quoting::NonWordMatcher
Instance Method Summary collapse
Methods included from Quoting
#always_quote, #ensure_quotes, #quotes_required?, #remove_quotes
Methods included from Rule
Instance Method Details
#_apply(token_list, active_token, active_token_index, options = {}) ⇒ Object
184 185 186 187 188 189 190 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 |
# File 'lib/bel/completion_rule.rb', line 184 def _apply(token_list, active_token, active_token_index, = {}) search = .delete(:search) return EMPTY_MATCH if not search or 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 = BEL::Namespace::NAMESPACE_LATEST[prefix_token.value.to_sym] if namespace scheme_uri = namespace[1] return search.search_namespace( URI(scheme_uri), "#{active_token.value}*", :start => 0, :size => 10 ). map { |search_result| map_namespace_value(search_result.pref_label) }.to_a end end else return search.search( active_token.value, :start => 0, :size => 10 ). map { |search_result| map_namespace_value(search_result.pref_label) }.to_a end end return EMPTY_MATCH end |