diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-11-13 12:01:38 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-11-13 12:03:47 +0100 |
| commit | 8dbbe68527e0855b87910fe367ef29f96a670408 (patch) | |
| tree | b80403da30012f623fe1d2d298dbd1def19f90a8 /crates/typst-ide/src/analyze.rs | |
| parent | 737895d769188f6fc154523e67a9102bc24c872e (diff) | |
Backport IDE improvements0.12.0-with-extras
Diffstat (limited to 'crates/typst-ide/src/analyze.rs')
| -rw-r--r-- | crates/typst-ide/src/analyze.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs index c3779556..6d4ba28f 100644 --- a/crates/typst-ide/src/analyze.rs +++ b/crates/typst-ide/src/analyze.rs @@ -6,11 +6,12 @@ use typst::foundations::{Context, Label, Scopes, Styles, Value}; use typst::introspection::Introspector; use typst::model::{BibliographyElem, Document}; use typst::syntax::{ast, LinkedNode, Span, SyntaxKind}; -use typst::World; + +use crate::IdeWorld; /// Try to determine a set of possible values for an expression. pub fn analyze_expr( - world: &dyn World, + world: &dyn IdeWorld, node: &LinkedNode, ) -> EcoVec<(Value, Option<Styles>)> { let Some(expr) = node.cast::<ast::Expr>() else { @@ -38,15 +39,15 @@ pub fn analyze_expr( } } - return typst::trace(world, node.span()); + return typst::trace(world.upcast(), node.span()); } }; eco_vec![(val, None)] } -/// Try to load a module from the current source file. -pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> { +/// Tries to load a module from the given `source` node. +pub fn analyze_import(world: &dyn IdeWorld, source: &LinkedNode) -> Option<Value> { // Use span in the node for resolving imports with relative paths. let source_span = source.span(); let (source, _) = analyze_expr(world, source).into_iter().next()?; @@ -58,7 +59,7 @@ pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> { let traced = Traced::default(); let mut sink = Sink::new(); let engine = Engine { - world: world.track(), + world: world.upcast().track(), introspector: introspector.track(), traced: traced.track(), sink: sink.track_mut(), |
