summaryrefslogtreecommitdiff
path: root/crates/typst-ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-ide/src')
-rw-r--r--crates/typst-ide/src/analyze.rs17
-rw-r--r--crates/typst-ide/src/complete.rs26
-rw-r--r--crates/typst-ide/src/jump.rs7
-rw-r--r--crates/typst-ide/src/lib.rs4
-rw-r--r--crates/typst-ide/src/tooltip.rs21
5 files changed, 34 insertions, 41 deletions
diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs
index 4d12e1c5..2d48039b 100644
--- a/crates/typst-ide/src/analyze.rs
+++ b/crates/typst-ide/src/analyze.rs
@@ -1,8 +1,11 @@
use comemo::Track;
use ecow::{eco_vec, EcoString, EcoVec};
-use typst::doc::Frame;
-use typst::eval::{Route, Scopes, Tracer, Value, Vm};
-use typst::model::{DelayedErrors, Introspector, Label, Locator, Vt};
+use typst::diag::DelayedErrors;
+use typst::eval::{Route, Tracer, Vm};
+use typst::foundations::{Label, Scopes, Value};
+use typst::introspection::{Introspector, Locator};
+use typst::layout::{Frame, Vt};
+use typst::model::BibliographyElem;
use typst::syntax::{ast, LinkedNode, Span, SyntaxKind};
use typst::World;
@@ -75,13 +78,9 @@ pub fn analyze_import(world: &dyn World, source: &LinkedNode) -> Option<Value> {
/// - All labels and descriptions for them, if available
/// - A split offset: All labels before this offset belong to nodes, all after
/// belong to a bibliography.
-pub fn analyze_labels(
- world: &dyn World,
- frames: &[Frame],
-) -> (Vec<(Label, Option<EcoString>)>, usize) {
+pub fn analyze_labels(frames: &[Frame]) -> (Vec<(Label, Option<EcoString>)>, usize) {
let mut output = vec![];
let introspector = Introspector::new(frames);
- let items = &world.library().items;
// Labels in the document.
for elem in introspector.all() {
@@ -102,7 +101,7 @@ pub fn analyze_labels(
let split = output.len();
// Bibliography keys.
- for (key, detail) in (items.bibliography_keys)(introspector.track()) {
+ for (key, detail) in BibliographyElem::keys(introspector.track()) {
output.push((Label::new(&key), detail));
}
diff --git a/crates/typst-ide/src/complete.rs b/crates/typst-ide/src/complete.rs
index 71ae95db..5cff5a81 100644
--- a/crates/typst-ide/src/complete.rs
+++ b/crates/typst-ide/src/complete.rs
@@ -4,21 +4,21 @@ use std::collections::{BTreeSet, HashSet};
use ecow::{eco_format, EcoString};
use if_chain::if_chain;
use serde::{Deserialize, Serialize};
-use typst::doc::Frame;
-use typst::eval::{
- format_str, repr, AutoValue, CastInfo, Func, Library, NoneValue, Repr, Scope, Type,
- Value,
+use typst::foundations::{
+ fields_on, format_str, mutable_methods_on, repr, AutoValue, CastInfo, Func, Label,
+ NoneValue, Repr, Scope, Type, Value,
};
-use typst::geom::Color;
-use typst::model::Label;
+use typst::layout::Frame;
use typst::syntax::{
ast, is_id_continue, is_id_start, is_ident, LinkedNode, Source, SyntaxKind,
};
+use typst::text::RawElem;
+use typst::visualize::Color;
use typst::World;
use unscanny::Scanner;
-use crate::analyze::analyze_labels;
-use crate::{analyze_expr, analyze_import, plain_docs_sentence, summarize_font_family};
+use crate::analyze::{analyze_expr, analyze_import, analyze_labels};
+use crate::{plain_docs_sentence, summarize_font_family};
/// Autocomplete a cursor position in a source file.
///
@@ -367,7 +367,7 @@ fn field_access_completions(ctx: &mut CompletionContext, value: &Value) {
}
}
- for &(method, args) in typst::eval::mutable_methods_on(value.ty()) {
+ for &(method, args) in mutable_methods_on(value.ty()) {
ctx.completions.push(Completion {
kind: CompletionKind::Func,
label: method.into(),
@@ -380,7 +380,7 @@ fn field_access_completions(ctx: &mut CompletionContext, value: &Value) {
})
}
- for &field in typst::eval::fields_on(value.ty()) {
+ for &field in fields_on(value.ty()) {
// Complete the field name along with its value. Notes:
// 1. No parentheses since function fields cannot currently be called
// with method syntax;
@@ -967,7 +967,6 @@ fn code_completions(ctx: &mut CompletionContext, hash: bool) {
struct CompletionContext<'a> {
world: &'a (dyn World + 'a),
frames: &'a [Frame],
- library: &'a Library,
global: &'a Scope,
math: &'a Scope,
text: &'a str,
@@ -996,7 +995,6 @@ impl<'a> CompletionContext<'a> {
Some(Self {
world,
frames,
- library,
global: library.global.scope(),
math: library.math.scope(),
text,
@@ -1074,7 +1072,7 @@ impl<'a> CompletionContext<'a> {
/// Add completions for raw block tags.
fn raw_completions(&mut self) {
- for (name, mut tags) in (self.library.items.raw_languages)() {
+ for (name, mut tags) in RawElem::languages() {
let lower = name.to_lowercase();
if !tags.contains(&lower.as_str()) {
tags.push(lower.as_str());
@@ -1096,7 +1094,7 @@ impl<'a> CompletionContext<'a> {
/// Add completions for labels and references.
fn label_completions(&mut self) {
- let (labels, split) = analyze_labels(self.world, self.frames);
+ let (labels, split) = analyze_labels(self.frames);
let head = &self.text[..self.from];
let at = head.ends_with('@');
diff --git a/crates/typst-ide/src/jump.rs b/crates/typst-ide/src/jump.rs
index a33e743c..700f475f 100644
--- a/crates/typst-ide/src/jump.rs
+++ b/crates/typst-ide/src/jump.rs
@@ -1,10 +1,11 @@
use std::num::NonZeroUsize;
use ecow::EcoString;
-use typst::doc::{Destination, Frame, FrameItem, Meta, Position};
-use typst::geom::{Geometry, Point, Size};
-use typst::model::Introspector;
+use typst::introspection::{Introspector, Meta};
+use typst::layout::{Frame, FrameItem, Point, Position, Size};
+use typst::model::Destination;
use typst::syntax::{FileId, LinkedNode, Source, Span, SyntaxKind};
+use typst::visualize::Geometry;
use typst::World;
/// Where to [jump](jump_from_click) to.
diff --git a/crates/typst-ide/src/lib.rs b/crates/typst-ide/src/lib.rs
index 3ab367dc..173a4264 100644
--- a/crates/typst-ide/src/lib.rs
+++ b/crates/typst-ide/src/lib.rs
@@ -13,9 +13,7 @@ pub use self::tooltip::{tooltip, Tooltip};
use std::fmt::Write;
use ecow::{eco_format, EcoString};
-use typst::font::{FontInfo, FontStyle};
-
-use self::analyze::*;
+use typst::text::{FontInfo, FontStyle};
/// Extract the first sentence of plain text of a piece of documentation.
///
diff --git a/crates/typst-ide/src/tooltip.rs b/crates/typst-ide/src/tooltip.rs
index d3f040e7..4f079166 100644
--- a/crates/typst-ide/src/tooltip.rs
+++ b/crates/typst-ide/src/tooltip.rs
@@ -2,14 +2,15 @@ use std::fmt::Write;
use ecow::{eco_format, EcoString};
use if_chain::if_chain;
-use typst::doc::Frame;
-use typst::eval::{repr, CapturesVisitor, CastInfo, Repr, Tracer, Value};
-use typst::geom::{round_2, Length, Numeric};
+use typst::eval::{CapturesVisitor, Tracer};
+use typst::foundations::{repr, CastInfo, Repr, Value};
+use typst::layout::{Frame, Length};
use typst::syntax::{ast, LinkedNode, Source, SyntaxKind};
+use typst::util::{round_2, Numeric};
use typst::World;
-use crate::analyze::analyze_labels;
-use crate::{analyze_expr, plain_docs_sentence, summarize_font_family};
+use crate::analyze::{analyze_expr, analyze_labels};
+use crate::{plain_docs_sentence, summarize_font_family};
/// Describe the item under the cursor.
pub fn tooltip(
@@ -25,7 +26,7 @@ pub fn tooltip(
named_param_tooltip(world, &leaf)
.or_else(|| font_tooltip(world, &leaf))
- .or_else(|| label_tooltip(world, frames, &leaf))
+ .or_else(|| label_tooltip(frames, &leaf))
.or_else(|| expr_tooltip(world, &leaf))
.or_else(|| closure_tooltip(&leaf))
}
@@ -144,18 +145,14 @@ fn length_tooltip(length: Length) -> Option<Tooltip> {
}
/// Tooltip for a hovered reference or label.
-fn label_tooltip(
- world: &dyn World,
- frames: &[Frame],
- leaf: &LinkedNode,
-) -> Option<Tooltip> {
+fn label_tooltip(frames: &[Frame], leaf: &LinkedNode) -> Option<Tooltip> {
let target = match leaf.kind() {
SyntaxKind::RefMarker => leaf.text().trim_start_matches('@'),
SyntaxKind::Label => leaf.text().trim_start_matches('<').trim_end_matches('>'),
_ => return None,
};
- for (label, detail) in analyze_labels(world, frames).0 {
+ for (label, detail) in analyze_labels(frames).0 {
if label.as_str() == target {
return Some(Tooltip::Text(detail?));
}