mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-23 12:46:43 +00:00
dev: stateful requests now accept snapshot (#1581)
* dev: stateful requests now accept snapshot * dev: add some convenient methods * dev: remove unused latest_doc state * dev: use graph * docs: comment * fix: bad flag
This commit is contained in:
parent
5b42231a77
commit
10ec787cc9
29 changed files with 383 additions and 504 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use std::sync::OnceLock;
|
||||
|
||||
use tinymist_std::typst::TypstDocument;
|
||||
use typst::syntax::Span;
|
||||
|
||||
use crate::{
|
||||
|
|
@ -25,15 +26,12 @@ pub struct ReferencesRequest {
|
|||
impl StatefulRequest for ReferencesRequest {
|
||||
type Response = Vec<LspLocation>;
|
||||
|
||||
fn request(
|
||||
self,
|
||||
ctx: &mut LocalContext,
|
||||
doc: Option<VersionedDocument>,
|
||||
) -> Option<Self::Response> {
|
||||
fn request(self, ctx: &mut LocalContext, graph: LspComputeGraph) -> Option<Self::Response> {
|
||||
let doc = graph.snap.success_doc.as_ref();
|
||||
let source = ctx.source_by_path(&self.path).ok()?;
|
||||
let syntax = ctx.classify_for_decl(&source, self.position)?;
|
||||
|
||||
let locations = find_references(ctx, &source, doc.as_ref(), syntax)?;
|
||||
let locations = find_references(ctx, &source, doc, syntax)?;
|
||||
|
||||
crate::log_debug_ct!("references: {locations:?}");
|
||||
Some(locations)
|
||||
|
|
@ -43,7 +41,7 @@ impl StatefulRequest for ReferencesRequest {
|
|||
pub(crate) fn find_references(
|
||||
ctx: &mut LocalContext,
|
||||
source: &Source,
|
||||
doc: Option<&VersionedDocument>,
|
||||
doc: Option<&TypstDocument>,
|
||||
syntax: SyntaxClass<'_>,
|
||||
) -> Option<Vec<LspLocation>> {
|
||||
let finding_label = match syntax {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue