Representing collected and deduplicated definitions and usages #
Converts an Import to its LSP-internal representation.
Equations
- Lean.Server.ImportInfo.ofImport i = { module := i.module.toString, isPrivate := !i.isExported, isAll := i.importAll, isMeta := i.isMeta }
Instances For
Collects ImportInfo for all import statements in headerStx.
Equations
- Lean.Server.collectImports headerStx = Array.map Lean.Server.ImportInfo.ofImport (Lean.Elab.headerToImports headerStx false)
Instances For
Global reference. Used by the language server to figure out which identifiers refer to which other identifiers across the whole project.
- ident : Lsp.RefIdentIdentifier of this reference. 
- aliases : Array Lsp.RefIdentIdentifiers that are logically identical to this reference. 
- range : Lsp.RangeRange where this reference occurs. 
- stx : SyntaxSyntax of this reference. 
- ci : Elab.ContextInfoContextInfoat the point of elaboration of this reference.
- info : Elab.InfoAdditional InfoTreeinformation for this reference.
- isBinder : BoolWhether this reference declares ident.
Instances For
Definition and usages of an identifier within a single module.
- All usage - References of the identifier in a single module.
Instances For
No definition, no usages.
Instances For
Adds ref to i.
If i has no definition and ref is a declaration, it becomes the definition.
If i already has a definition and ref is also a declaration, it is not added to i.
Otherwise, ref is added to i.usages.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Converts i to a JSON-serializable Lsp.RefInfo.
Equations
- One or more equations did not get rendered due to their size.
Instances For
All references from within a module for all identifiers used in a single module.
Instances For
Adds ref to the RefInfo corresponding to ref.ident in self. See RefInfo.addRef.
Equations
- self.addRef ref = Std.TreeMap.insert self ref.ident ((Std.TreeMap.getD self ref.ident Lean.Server.RefInfo.empty).addRef ref)
Instances For
Converts refs to a JSON-serializable Lsp.ModuleRefs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
No definition, no usages
Instances For
Finds the first definition or usage in self where the RefInfo.Location.range
contains the given pos. The includeStop parameter can be used to toggle between closed-interval
and half-open-interval behavior for the range. Closed-interval behavior matches the expectation of
VSCode when selecting an identifier at a cursor position (see #767).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Find all identifiers in self with a reference in this module that contains pos in its range.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Finds the first range in self that contains pos.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Content of individual .ilean files
- version : NatVersion number of the ilean format. 
- module : NameName of the module that this ilean data has been collected for. 
- directImports : Array Lsp.ImportInfoDirect imports of the module. 
- references : Lsp.ModuleRefsAll references of this module. 
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reads and parses the .ilean file at path.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Collecting and deduplicating definitions and usages #
Gets the name of the module that contains declName.
Equations
- Lean.Server.getModuleContainingDecl? env declName = match env.getModuleIdxFor? declName with | some modIdx => env.allImportedModuleNames[modIdx]? | x => some env.header.mainModule
Instances For
Determines the RefIdent for the Info i of an identifier in module and
whether it is a declaration.
Equations
- One or more equations did not get rendered due to their size.
- Lean.Server.identOf ci i = none
Instances For
Finds all references in trees.
Equations
- One or more equations did not get rendered due to their size.
Instances For
There are several different identifiers that should be considered equal for the purpose of finding all references of an identifier:
- FVarIds of a function parameter in the function's signature and body
- Chains of helper definitions like those created for do-reassignment x := e
- Overlapping definitions like those defined by wheredeclarations that define both an FVar (for local usage) and a constant (for non-local usage)
- Identifiers connected by FVarAliasInfosuch as variables before and aftermatchgeneralization
In the first three cases that are not explicitly denoted as aliases with an FVarAliasInfo, the
corresponding References have the exact same range.
This function finds all definitions that have the exact same range as another definition or usage
and collapses them into a single identifier. It also collapses identifiers connected by
an FVarAliasInfo.
When collapsing identifiers, it prefers using a RefIdent.const name over a RefIdent.fvar id for
all identifiers that are being collapsed into one.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Groups refs by identifier and range s.t. references with the same identifier and range
are added to the aliases of the representative of the group.
Yields to separate groups for declaration and usages if allowSimultaneousBinderUse is set.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Finds all references in trees and deduplicates the result.
See dedupReferences and combineIdents.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Collecting and maintaining reference info from different sources #
Represents a direct import of a module in the references data structure.
- module : NameModule name of the module that is imported. 
- uri : Lsp.DocumentUriURI of the module that is imported. 
- isAll : BoolWhether the allflag is set on this import.
- isPrivate : BoolWhether the privateflag is set on this import.
- metaKind : Lsp.LeanImportMetaKindKind of metaannotation on this import.
Instances For
Equations
Instances For
Reduces identicalImports with the same module name by merging their flags.
Yields none if identicalImports is empty or identicalImports contains an import that
has a name or uri that is not identical to the others.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Index that allows efficiently looking up the imports of a module by module name. Since the same module can be imported multiple times with different attributes, each module name maps to an array of imports.
Equations
Instances For
Direct imports of a module, containing an ordered representation and an index for fast lookups.
- ordered : Array ModuleImportImports as they occurred in the module. 
- index : ModuleImportIndexIndex that allows efficiently looking up the imports of a module by module name. Since the same module can be imported multiple times with different attributes, each module name maps to an array of imports. 
Instances For
Converts a list of LSP module imports to the module imports of the references data structure.
Removes all imports for which we cannot resolve the corresponding DocumentUri.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reference information from a loaded ILean file.
- moduleUri : Lsp.DocumentUriURI of the module of this ILean. 
- ileanPath : System.FilePathPath to the ILean file. 
- directImports : DirectImportsDirect imports of the module of this ILean. 
- refs : Lsp.ModuleRefsReference information from this ILean. 
Instances For
Paths and module references for every module name. Loaded from .ilean files.
Instances For
Transient reference information from a file worker. We track this information so that we have up-to-date reference information before a file has been built.
- moduleUri : Lsp.DocumentUriURI of the module that the file worker is associated with. 
- version : NatDocument version for which these references have been collected. 
- directImports : DirectImportsDirect imports of the module that the file worker is associated with. 
- refs : Lsp.ModuleRefsReferences provided by the worker. 
Instances For
Document versions and module references for every module name. Loaded from the current state in a file worker.
Equations
Instances For
References from ilean files and current ilean information from file workers.
- ileans : ILeanMapReferences loaded from ilean files 
- workers : WorkerRefMapReferences from workers, overriding the corresponding ilean files 
Instances For
Instances For
Equations
No ilean files, no information from workers.
Instances For
Adds the contents of an ilean file ilean at path to self.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Removes the ilean file data at path from self.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Replaces the direct imports of a worker for the module name in self with
a new set of direct imports.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Updates the worker references in self with the refs of the worker managing the module name.
Replaces the current references with refs if version is newer than the current version managed
in refs and otherwise merges the reference data if version is equal to the current version.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Replaces the worker references in self with the refs of the worker managing the module name
if version is newer than the current version managed in refs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Erases all worker references in self for the worker managing name.
Equations
- self.removeWorkerRefs name = { ileans := self.ileans, workers := Std.TreeMap.erase self.workers name }
Instances For
Map from each module to all of its references. The current references in a file worker take precedence over those in .ilean files.
Equations
Instances For
Yields a map from all modules to all of their references.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Map from each module to all of its direct imports. The current references in a file worker take precedence over those in .ilean files.
Equations
Instances For
Yields a map from all modules to all of their direct imports.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Gets the references for mod.
The current references in a file worker take precedence over those in .ilean files.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Gets the direct imports of mod.
The current imports in a file worker take precedence over those in .ilean files.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Yields all references in self for ident, as well as the DocumentUri that each
reference occurs in.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Yields all references in module at pos.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Yields the first reference in module at pos.
Equations
- self.findRange? module pos includeStop = do let __discr ← self.getModuleRefs? module match __discr with | (fst, refs) => refs.findRange? pos includeStop
Instances For
Location and parent declaration of a reference.
- location : Lsp.LocationLocation of the reference. 
- module : NameModule name of the reference. 
- parentInfo? : Option Lsp.RefInfo.ParentDeclParent declaration of the reference. 
Instances For
Yields locations and parent declaration for all references referring to ident.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Yields the definition location of ident.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A match in References.definitionsMatching.
- mod : NameResult of filterMapMod.
- modUri : Lsp.DocumentUriURI for mod.
- ident : αResult of filterMapIdent.
- range : Lsp.RangeDefinition range of matched identifier. 
Instances For
Yields all definitions matching the given filter.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Yields all imports that import the given requestedMod.
Equations
- One or more equations did not get rendered due to their size.