MCPcopy Index your code
hub / github.com/dbcli/mycli / find_matches

Method find_matches

mycli/sqlcompleter.py:1369–1401  ·  view source on GitHub ↗

Find completion matches for the given text. Given the user's input text and a collection of available completions, find completions matching the last word of the text. If `start_only` is True, the text will match an available completion only at the beginning

(
        self,
        orig_text: str,
        collection: Collection,
        start_only: bool = False,
        fuzzy: bool = True,
        casing: str | None = None,
        text_before_cursor: str = '',
    )

Source from the content-addressed store, hash-verified

1367 return (apply_case(completion) for completion in completions)
1368
1369 def find_matches(
1370 self,
1371 orig_text: str,
1372 collection: Collection,
1373 start_only: bool = False,
1374 fuzzy: bool = True,
1375 casing: str | None = None,
1376 text_before_cursor: str = '',
1377 ) -> Generator[tuple[str, int], None, None]:
1378 """Find completion matches for the given text.
1379
1380 Given the user's input text and a collection of available
1381 completions, find completions matching the last word of the
1382 text.
1383
1384 If `start_only` is True, the text will match an available
1385 completion only at the beginning. Otherwise, a completion is
1386 considered a match if the text appears anywhere within it.
1387
1388 yields prompt_toolkit Completion instances for any matches found
1389 in the collection of available completions.
1390 """
1391 last = last_word(orig_text, include='most_punctuations')
1392 text = last.lower()
1393 quoted_collection = self.quote_collection_if_needed(text, collection, text_before_cursor)
1394
1395 if fuzzy:
1396 completions = self.find_fuzzy_matches(last, text, quoted_collection)
1397 else:
1398 completions = self.find_perfect_matches(text, quoted_collection, start_only)
1399
1400 casing = self.resolve_casing(casing, last)
1401 return self.apply_casing(completions, casing)
1402
1403 def get_completions(
1404 self,

Callers 2

get_completionsMethod · 0.95
collect_matchesFunction · 0.95

Calls 6

find_fuzzy_matchesMethod · 0.95
find_perfect_matchesMethod · 0.95
resolve_casingMethod · 0.95
apply_casingMethod · 0.95
last_wordFunction · 0.90

Tested by 1

collect_matchesFunction · 0.76