The memory-compressed version of PackageIndex.
A CharSequence which is the concatenation of two strings.
A CharSequence which is the concatenation of two strings.
This class is the equivalent of doing string1 + string2
but in constant time
and with no copying.
Implementation of the documentation(symbol: String): Option[SymbolDocumentation]
method in SymbolSearch
.
Implementation of the documentation(symbol: String): Option[SymbolDocumentation]
method in SymbolSearch
.
Handles both javadoc and scaladoc.
Retrieves all the symbols defined in a document
Retrieves all the symbols defined in a document
If the document doesn't parse, we fall back to the latest known snapshot of the document, if present.
A char sequence that represents an exact symbol search.
A char sequence that represents an exact symbol search.
For example, ExactSymbolSearch("S")
is added to a bloom filter
to indicate a souce file has a symbol with the exact name "S".
Extracts Javadoc from Java source code.
A pair of tokens that align with each other across two different files
An index to lookup classfiles contained in a given classpath.
Extracts Scaladoc from Scala source code.
A definition of a global symbol produced by mtags.
A wrapper around a bloom filter that is optimized for fast insertions of strings with shared prefixes.
A wrapper around a bloom filter that is optimized for fast insertions of strings with shared prefixes.
To index a classpath, Metals walks through all possible prefixes of a given classfile path. For example, given the string "InputStream.class" Metals builds a bloom filter containing the set of the following strings: I, In, Inp, Inpu, Input, S, St, Str, Stre, Strea and Stream.
The naive approach to construct a bloom filter of all those prefix strings
is to create a BloomFilter[CharSequence]
and insert all those prefixes.
This approach has sub-optimal performance because it requires a quadratic
number of iterations on the characters of the classfile path.
This class implements an optimized approach to build that bloom filter in a
way that requires only a linear pass on the characters of the classfile
path. The trick is to construct a BloomFilter[Long]
instead of
BloomFilter[CharSequence]
and incrementally build the hashcode of each
prefix string as we iterate over each character in the string.
Additionally, this class exposes a mightContain(Long)
method that speeds
up search queries by allowing the client to pre-compute the hash of the
query string and re-use mightContain
calls to multiple bloom filters. For
every single fuzzy symbol search (which happens on every single scope
completion request) we usually perform several thousand bloom filter
mightContain
calls so should also help avoid a non-trivial amount of
unnecessary hashing.
Helper to map between position between two similar strings.
Manages parsing of Scala source files into Scalameta syntax trees.
Manages parsing of Scala source files into Scalameta syntax trees.
- provides the latest good Scalameta tree for a given source file
similar as Buffers
provides the current text content.
- produces diagnostics for syntax errors.
A query for workspace/symbol.
A query for workspace/symbol.
the user query itself.
all query alternatives for this query. For non-lowercase queries this list has always length 1 but for all-lowercase queries we have combinations of query with guesses for which characters in the query should be capitalized.
A symbol documenation with all empty values
Metals fuzzy search for strings.
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.
Locates zip file on disk that contains the source code for the JDK.
Client implementation of how to interpret TextEdit
from LSP, used for testing purposes.
The memory-compressed version of PackageIndex.
all packages in the index
the fuzzy search bloom filter for all members of this package.
the GZIP compressed bytes representing Array[String] for all members of this package. The members are compressed because the strings consume a lot of memory and most queries only require looking at a few packages. We decompress the members only when a search query matches the bloom filter for this package.