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

Method get_function_matches

pgcli/pgcompleter.py:655–687  ·  view source on GitHub ↗
(self, suggestion, word_before_cursor, alias=False)

Source from the content-addressed store, hash-verified

653 return self.find_matches(word_before_cursor, conds, meta="join")
654
655 def get_function_matches(self, suggestion, word_before_cursor, alias=False):
656 if suggestion.usage == "from":
657 # Only suggest functions allowed in FROM clause
658
659 def filt(f):
660 return (
661 not f.is_aggregate
662 and not f.is_window
663 and not f.is_extension
664 and (f.is_public or f.schema_name in self.search_path or f.schema_name == suggestion.schema)
665 )
666
667 else:
668 alias = False
669
670 def filt(f):
671 return not f.is_extension and (f.is_public or f.schema_name == suggestion.schema)
672
673 arg_mode = {"signature": "signature", "special": None}.get(suggestion.usage, "call")
674
675 # Function overloading means we way have multiple functions of the same
676 # name at this point, so keep unique names only
677 all_functions = self.populate_functions(suggestion.schema, filt)
678 funcs = {self._make_cand(f, alias, suggestion, arg_mode) for f in all_functions}
679
680 matches = self.find_matches(word_before_cursor, funcs, meta="function")
681
682 if not suggestion.schema and not suggestion.usage:
683 # also suggest hardcoded functions using startswith matching
684 predefined_funcs = self.find_matches(word_before_cursor, self.functions, mode="strict", meta="function")
685 matches.extend(predefined_funcs)
686
687 return matches
688
689 def get_schema_matches(self, suggestion, word_before_cursor):
690 schema_names = self.dbmetadata["tables"].keys()

Callers 1

Calls 3

populate_functionsMethod · 0.95
_make_candMethod · 0.95
find_matchesMethod · 0.95

Tested by

no test coverage detected