Queries fewer characters than this variable are treated as exact searches.
Queries fewer characters than this variable are treated as exact searches.
For example, the query "S" returns only symbols with the exact name "S" and not symbols like "Stream".
Companion to bloomFilterSymbolStrings
.
Companion to bloomFilterSymbolStrings
.
Returns the set of strings to insert into a bloom filter index of a single package or file.
Returns the set of strings to insert into a bloom filter index of a single package or file.
Given a query and set of symbols where there exists at least one symbol where Fuzzy.matches(query, symbol)
,
this method must meet the following constraints:
predicate symbols.exists(symbol => Fuzzy.matches(query, symbol))
implies bloomFilterQueryStrings(query).forall(bloom.mightContain)
where bloom = BloomFilter(bloomFilterSymbolStrings)
What this method roughly tries to achieve is extract the substrings of the symbols that can appear in queries.
For example, given the symbol InputFileChunkedStream
we insert the following substrings:
- All prefixes of the individual names Input
, File
, Chunked
and Stream
,
example: "I", "In", "Inp", ..., "Strea", "Stream".
- All trigrams of uppercase characters, example: "IFC", "IFS", "FCS".
Returns true if this char sequence contains only digit characters.
Returns true if this char sequence contains only digit characters.
Returns true if the query matches the given symbol.
Returns true if the query matches the given symbol.
the search query like "m.Pos"
the symbol to test the query against like "scala/meta/inputs/Position#"
the number of names in the symbol to jump over. For regular search, use 0. Use 1 to let the query "m.Pos" match "scala/meta/Position#Range."
Returns true if all characters in the query have a case in-sensitive matching character in the symbol, in-order
Returns true if all characters in the query have a case in-sensitive matching character in the symbol, in-order
Matching examples:
- int toInt
- int instance // Because in
and t
- int intNumber
Non-matching examples: - int inSub // missing t
the query string, like "int"
the symbol to test for matching against the query string, like "toInt".
Returns the length of the last name in this symbol.
Returns the length of the last name in this symbol.
Example: scala/Option$Some.class returns length of "Some"
Metals fuzzy search for strings.
Goals: - predictable, the user should understand why particular results matched a given query. When the search is too fuzzy the results become noisy and the user has little control over how to narrow the results. - fast, we perform fuzzy search on a lot of string in critical paths on ever user keystroke. We avoid allocations and backtracking when possible even if it comes at the price of less readable code.
The following pairs of (query, symbol) match. - InStr java/io/InputFileStream# - IFS java/io/InputFileStream# - i.InStr java/io/InputFileStream# - j.i.InStr java/io/InputFileStream# - M.Entry java/util/Map#Entry# (inner classes are like packages)
The following pairs of (query, symbol) do not match. - IpStr java/io/InputFileStream# (missing leading
n
beforep
) - instr java/io/InputFileStream# (lowercase queries are exact, WorkspaceSymbolProvider works around this limitation by guessing multiple capitalizations of all-lowercase queries) - MapEntry java/io/InputFileStream# (missing.
separator after "Map") - j.InStr java/io/InputFileStream# (missingio
separator, thejava/
package must be direct parent)Glossary and conventions used in this file: - query, what the user typed to look up a symbol. - symbol, a SemanticDB Java/Scala symbol (https://scalameta.org/docs/semanticdb/specification.html) or a java.util.zip.ZipEntry name pointing to a classfile. - delimiter, one of the characters '.' or '/' or '#' that separate package/class/object/trait names in SemanticDB symbols, or '$' that separates inner classes in classfile names. - name, characters between delimiters like "io" in "java/io/InputStream". - main name, the last name in the query or symbol. For example, "Pos" is the main name in "s.m.Pos". - qa, the start index in the query string. - qb, the end index in the query string. - sa, the start index in the symbol string. - sb, the end index in the symbol string.