object Fuzzy
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 before p)
- 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# (missing io separator, the java/ 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.
- Alphabetic
- By Inheritance
- Fuzzy
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bloomFilterQueryStrings(query: String, includeTrigrams: Boolean = true): Iterable[CharSequence]
Companion to
bloomFilterSymbolStrings. -
def
bloomFilterSymbolStrings(symbols: Iterable[String], result: Set[CharSequence] = mutable.Set.empty): Set[CharSequence]
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: predicatesymbols.exists(symbol => Fuzzy.matches(query, symbol))impliesbloomFilterQueryStrings(query).forall(bloom.mightContain)wherebloom = 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
InputFileChunkedStreamwe insert the following substrings:- All prefixes of the individual names
Input,File,ChunkedandStream, example: "I", "In", "Inp", ..., "Strea", "Stream". - All trigrams of uppercase characters, example: "IFC", "IFS", "FCS".- symbols
all symbols in a source file or a package.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
matches(query: CharSequence, symbol: CharSequence, skipNames: Int): Boolean
Returns true if the query matches the given symbol.
Returns true if the query matches the given symbol.
- query
the search query like "m.Pos"
- symbol
the symbol to test the query against like "scala/meta/inputs/Position#"
- skipNames
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."
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )