MCPcopy Index your code
hub / github.com/dbcli/pgcli / get_completions

Method get_completions

pgcli/pgcompleter.py:457–485  ·  view source on GitHub ↗
(self, document, complete_event, smart_completion=None)

Source from the content-addressed store, hash-verified

455 return self.casing.get(word, word)
456
457 def get_completions(self, document, complete_event, smart_completion=None):
458 word_before_cursor = document.get_word_before_cursor(WORD=True)
459
460 if smart_completion is None:
461 smart_completion = self.smart_completion
462
463 # If smart_completion is off then match any word that starts with
464 # 'word_before_cursor'.
465 if not smart_completion:
466 matches = self.find_matches(word_before_cursor, self.all_completions, mode="strict")
467 completions = [m.completion for m in matches]
468 return sorted(completions, key=operator.attrgetter("text"))
469
470 matches = []
471 suggestions = suggest_type(document.text, document.text_before_cursor)
472
473 for suggestion in suggestions:
474 suggestion_type = type(suggestion)
475 _logger.debug("Suggestion type: %r", suggestion_type)
476
477 # Map suggestion type to method
478 # e.g. 'table' -> self.get_table_matches
479 matcher = self.suggestion_matchers[suggestion_type]
480 matches.extend(matcher(self, suggestion, word_before_cursor))
481
482 # Sort matches so highest priorities are first
483 matches = sorted(matches, key=operator.attrgetter("priority"), reverse=True)
484
485 return [m.completion for m in matches]
486
487 def get_column_matches(self, suggestion, word_before_cursor):
488 tables = suggestion.table_refs

Callers 1

get_path_matchesMethod · 0.45

Calls 2

find_matchesMethod · 0.95
suggest_typeFunction · 0.85

Tested by

no test coverage detected