pub struct DocumentStore { /* private fields */ }Implementations§
Source§impl DocumentStore
impl DocumentStore
pub fn new() -> Self
Sourcepub fn analysis_session(&self, php_version: PhpVersion) -> Arc<AnalysisSession>
pub fn analysis_session(&self, php_version: PhpVersion) -> Arc<AnalysisSession>
Get or build the AnalysisSession for the given PHP version. Rebuilds
when the version changes (e.g. user flipped config). The session owns
its own salsa db and AnalysisCache; lazy-loads vendor files via the
shared PSR-4 map.
Sourcepub fn workspace_php_version(&self) -> PhpVersion
pub fn workspace_php_version(&self) -> PhpVersion
Current PHP version tracked by the workspace input.
Sourcepub fn psr4_arc(&self) -> Arc<RwLock<Psr4Map>>
pub fn psr4_arc(&self) -> Arc<RwLock<Psr4Map>>
Return the Arc<RwLock<Psr4Map>> so callers can share it.
Backend clones this arc at construction time so writes to the lock
(e.g. loading composer.json on initialized) are immediately visible
to lazy_load_psr4_imports without extra plumbing.
Sourcepub fn mirror_text(&self, uri: &Url, text: &str) -> SourceFile
pub fn mirror_text(&self, uri: &Url, text: &str) -> SourceFile
Mirror a file’s current text into the salsa layer. Creates the
SourceFile input on first sight, otherwise updates text on the
existing input (bumping the salsa revision so downstream queries
invalidate). Returns the SourceFile handle for this uri.
B4a: called from every text-changing mutation site. Reads still come
from the legacy map — this mirror is not yet observed by production
code paths.
Sourcepub fn mirror_text_arc(&self, uri: &Url, text_arc: Arc<str>) -> SourceFile
pub fn mirror_text_arc(&self, uri: &Url, text_arc: Arc<str>) -> SourceFile
Like [mirror_text] but takes an already-allocated Arc<str>.
Callers that already hold an Arc<str> (e.g. index_from_doc reusing
ParsedDoc::source_arc()) use this to avoid a second allocation and to
ensure text_cache and parsed_cache hold the same Arc pointer —
enabling Arc::ptr_eq validation in get_parsed_cached.
Sourcepub fn source_file(&self, uri: &Url) -> Option<SourceFile>
pub fn source_file(&self, uri: &Url) -> Option<SourceFile>
Return the salsa SourceFile handle for a URL, if one exists.
Sourcepub fn seed_cached_slice(&self, uri: &Url, slice: Arc<StubSlice>) -> bool
pub fn seed_cached_slice(&self, uri: &Url, slice: Arc<StubSlice>) -> bool
Phase K2: pre-seed a StubSlice loaded from the on-disk cache
onto the SourceFile input for uri. The next file_definitions
call for that file returns the cached slice directly, skipping
parse + DefinitionCollector.
Must be called before any file_definitions(db, sf) call for
this file — otherwise salsa has already memoized the fresh-parse
result and setting cached_slice now would only bump the revision
without actually using the cache. In practice the workspace-scan
path seeds immediately after mirror_text and before any query
runs.
Returns false when uri was not mirrored (caller should mirror
first); returns true on success.
Sourcepub fn with_host<R>(&self, f: impl FnOnce(&AnalysisHost) -> R) -> R
pub fn with_host<R>(&self, f: impl FnOnce(&AnalysisHost) -> R) -> R
Run f with a borrow of the AnalysisHost. Used by tests and by the
upcoming *_salsa accessors to query the salsa layer.
Sourcepub fn evict_token_cache(&self, uri: &Url)
pub fn evict_token_cache(&self, uri: &Url)
Evict the semantic-tokens cache for uri. Called by Backend when a
file is closed; diff-based tokens computed against the old revision
are no longer meaningful.
Sourcepub fn index(&self, uri: Url, text: &str)
pub fn index(&self, uri: Url, text: &str)
Register a file in the salsa layer without marking it open.
Salsa’s parsed_doc query parses lazily on first read; diagnostics
are populated by did_open when the editor actually opens the file.
Sourcepub fn index_from_doc(&self, uri: Url, doc: &ParsedDoc)
pub fn index_from_doc(&self, uri: Url, doc: &ParsedDoc)
Index a file using an already-parsed ParsedDoc, avoiding a second parse.
Prefer this over [index] when the caller already has a ParsedDoc (e.g.
after running DefinitionCollector during workspace scan). Reuses the
Arc<str> already owned by doc so that text_cache and SourceFile::text
share the same pointer — enabling the Arc::ptr_eq fast path in
get_parsed_cached on the first subsequent salsa query, without an extra
Arc::from(source) allocation.
pub fn remove(&self, uri: &Url)
Sourcepub fn get_doc_salsa(&self, uri: &Url) -> Option<Arc<ParsedDoc>>
pub fn get_doc_salsa(&self, uri: &Url) -> Option<Arc<ParsedDoc>>
Salsa-backed parsed document.
Salsa-backed parsed document for any mirrored file (open or
background-indexed). Returns None only when the file is not known
to the store. Callers that want “only if open” should gate on
Backend::open_files at the call site (see Backend::get_doc).
Sourcepub fn get_index_salsa(&self, uri: &Url) -> Option<Arc<FileIndex>>
pub fn get_index_salsa(&self, uri: &Url) -> Option<Arc<FileIndex>>
Salsa-backed compact symbol index.
Sourcepub fn sync_workspace_files(&self)
pub fn sync_workspace_files(&self)
Refresh workspace.files to mirror the current source_files set.
Called by get_codebase_salsa. Skips the setter when the file list
hasn’t changed — salsa’s set_field unconditionally bumps revision,
which would invalidate every downstream query (codebase, file_refs).
Dedup is essential for memoization across LSP requests.
Sourcepub fn set_php_version(&self, version: PhpVersion)
pub fn set_php_version(&self, version: PhpVersion)
Update the PHP version tracked by the workspace. Salsa will invalidate
all semantic_issues queries so diagnostics are re-evaluated.
Skips the setter when the version hasn’t changed to avoid spurious
query invalidation.
Sourcepub fn get_symbol_refs_salsa(
&self,
_key: &str,
) -> Vec<(Arc<str>, u32, u16, u16)>
pub fn get_symbol_refs_salsa( &self, _key: &str, ) -> Vec<(Arc<str>, u32, u16, u16)>
Stub kept for the legacy RefLookup closure shape consumed by
find_references_codebase_with_target. Always returns empty; the
AST walker handles all reference scanning. Session-backed refs go
through Self::session_references_to instead.
Sourcepub fn session_references_to(
&self,
symbol: &Symbol,
) -> Vec<(Arc<str>, u32, u32, u32)>
pub fn session_references_to( &self, symbol: &Symbol, ) -> Vec<(Arc<str>, u32, u32, u32)>
Session-backed workspace reference lookup. Returns (file, line, col)
locations for every occurrence of symbol in the files that the
AnalysisSession has ingested so far. The session’s reference index
is built incrementally during ingest_file, so refs for files the
session hasn’t seen yet (background-indexed but never opened) won’t
appear here — those are covered by the AST-walker fallback in the
references handler.
Returns LSP-style 0-based line/column.
Sourcepub fn get_workspace_index_salsa(&self) -> Arc<WorkspaceIndexData>
pub fn get_workspace_index_salsa(&self) -> Arc<WorkspaceIndexData>
Phase J: salsa-memoized aggregate workspace index.
Returns the shared Arc<WorkspaceIndexData> with flat
(Url, Arc<FileIndex>) list plus pre-built classes_by_name and
subtypes_of reverse maps. Used by workspace_symbols,
prepare_type_hierarchy, supertypes_of, subtypes_of, and
find_implementations so they don’t each rebuild the aggregate per
request. Invalidates automatically when any file’s file_index
changes.
Sourcepub fn warm_reference_index(&self)
pub fn warm_reference_index(&self)
No-op after mir 0.22 migration. The session manages its own warm-up
via ingest_file / analyze_dependents_of; there’s nothing for us
to pre-warm here.
Sourcepub fn source_text(&self, uri: &Url) -> Option<Arc<str>>
pub fn source_text(&self, uri: &Url) -> Option<Arc<str>>
Return the raw source text for uri if it has been mirrored into the
salsa workspace. Used by the references handler to pre-filter session
results by checking whether a file mentions the owning class name.
Sourcepub fn ensure_all_files_ingested(&self)
pub fn ensure_all_files_ingested(&self)
Run Pass 1 + Pass 2 analysis on every mirrored workspace file so that
type-aware queries (e.g. session.references_to) see the full workspace.
Reference locations are only recorded during Pass 2 (FileAnalyzer::analyze).
ingest_file alone (Pass 1) is not sufficient. Only needed for cross-file
queries like textDocument/references that rely on the reference index.
The session’s internal cache makes re-analysis of unchanged files cheap.
Sourcepub fn get_method_returns_salsa(
&self,
uri: &Url,
) -> Option<Arc<MethodReturnsMap>>
pub fn get_method_returns_salsa( &self, uri: &Url, ) -> Option<Arc<MethodReturnsMap>>
Salsa-backed per-file method-return-type map.
Sourcepub fn store_token_cache(
&self,
uri: &Url,
result_id: String,
tokens: Arc<Vec<SemanticToken>>,
)
pub fn store_token_cache( &self, uri: &Url, result_id: String, tokens: Arc<Vec<SemanticToken>>, )
Cache the semantic tokens computed for a delta response.
result_id is an opaque string (a hash of the token data) returned to the client.
Sourcepub fn get_token_cache(
&self,
uri: &Url,
result_id: &str,
) -> Option<Arc<Vec<SemanticToken>>>
pub fn get_token_cache( &self, uri: &Url, result_id: &str, ) -> Option<Arc<Vec<SemanticToken>>>
Return the cached tokens if result_id matches the stored one.
Sourcepub fn get_semantic_issues_salsa(&self, uri: &Url) -> Option<Arc<[Issue]>>
pub fn get_semantic_issues_salsa(&self, uri: &Url) -> Option<Arc<[Issue]>>
Raw semantic issues for a file, computed via mir’s session-based
FileAnalyzer. The session lazy-loads dependencies via PSR-4 so the
LSP no longer needs to mirror vendor up-front. Callers apply their
own DiagnosticsConfig filter via
crate::semantic_diagnostics::issues_to_diagnostics.
Sourcepub fn docs_for(&self, open_urls: &[Url]) -> Vec<(Url, Arc<ParsedDoc>)>
pub fn docs_for(&self, open_urls: &[Url]) -> Vec<(Url, Arc<ParsedDoc>)>
Returns (uri, doc) for files currently open in the editor.
Resolve open_urls (from Backend::open_urls()) to parsed docs.
Files not mirrored in the salsa layer are filtered out silently.
Sourcepub fn doc_with_others(
&self,
uri: &Url,
doc: Arc<ParsedDoc>,
open_urls: &[Url],
) -> Vec<(Url, Arc<ParsedDoc>)>
pub fn doc_with_others( &self, uri: &Url, doc: Arc<ParsedDoc>, open_urls: &[Url], ) -> Vec<(Url, Arc<ParsedDoc>)>
(primary, doc) first, then every other open file’s parsed doc.
The open_urls slice should include uri — this helper filters it out.
Sourcepub fn other_docs(
&self,
uri: &Url,
open_urls: &[Url],
) -> Vec<(Url, Arc<ParsedDoc>)>
pub fn other_docs( &self, uri: &Url, open_urls: &[Url], ) -> Vec<(Url, Arc<ParsedDoc>)>
Parsed docs for every entry in open_urls except uri.
Sourcepub fn other_docs_with_returns(
&self,
uri: &Url,
open_urls: &[Url],
) -> Vec<(Url, Arc<ParsedDoc>, Arc<MethodReturnsMap>)>
pub fn other_docs_with_returns( &self, uri: &Url, open_urls: &[Url], ) -> Vec<(Url, Arc<ParsedDoc>, Arc<MethodReturnsMap>)>
Batched salsa fetch for every entry in open_urls except uri:
returns each (uri, ParsedDoc, MethodReturnsMap) triple in a single
snapshot_query so cancellation retries don’t run N times.
Sourcepub fn all_indexes(&self) -> Vec<(Url, Arc<FileIndex>)>
pub fn all_indexes(&self) -> Vec<(Url, Arc<FileIndex>)>
Compact symbol index for every mirrored file.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DocumentStore
impl !RefUnwindSafe for DocumentStore
impl Send for DocumentStore
impl Sync for DocumentStore
impl Unpin for DocumentStore
impl UnsafeUnpin for DocumentStore
impl !UnwindSafe for DocumentStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more