summaryrefslogtreecommitdiff
path: root/crates/typst-ide/src/analyze.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-ide/src/analyze.rs')
-rw-r--r--crates/typst-ide/src/analyze.rs13
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(),