diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-11-10 12:15:28 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-11-13 10:21:40 +0100 |
| commit | a5a4b0b72fcf948bc58dd5800eefbabb1d67a43d (patch) | |
| tree | 3860f05b073a26b25584734a7b9aa61a67c9c61e /crates/typst-ide/src/analyze.rs | |
| parent | 03ba5a0cb123fbfcb36dddfd1de4d710fef09a98 (diff) | |
Introduce `IdeWorld` trait
Diffstat (limited to 'crates/typst-ide/src/analyze.rs')
| -rw-r--r-- | crates/typst-ide/src/analyze.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs index 75ffaede..ce7fe478 100644 --- a/crates/typst-ide/src/analyze.rs +++ b/crates/typst-ide/src/analyze.rs @@ -5,12 +5,13 @@ 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 typst_eval::Vm; +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,7 +39,7 @@ pub fn analyze_expr( } } - return typst::trace(world, node.span()); + return typst::trace(world.upcast(), node.span()); } }; @@ -46,7 +47,7 @@ pub fn analyze_expr( } /// Try to load a module from the current source file. -pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> { +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()?; @@ -59,7 +60,7 @@ pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> { let mut sink = Sink::new(); let engine = Engine { routines: &typst::ROUTINES, - world: world.track(), + world: world.upcast().track(), introspector: introspector.track(), traced: traced.track(), sink: sink.track_mut(), |
