summaryrefslogtreecommitdiff
path: root/crates/typst-ide
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-12-02 13:37:33 +0100
committerLaurenz <laurmaedje@gmail.com>2024-12-04 10:12:07 +0100
commitf8f2ba6a5f8c8ca7dbb85cf17b73332a0c301c60 (patch)
treeb3bc754509fb3ab4c74493848fe96f116b7907ed /crates/typst-ide
parent76c24ee6e35715cd14bb892d7b6b8d775c680bf7 (diff)
Rename `Document` to `PagedDocument`
Diffstat (limited to 'crates/typst-ide')
-rw-r--r--crates/typst-ide/src/analyze.rs7
-rw-r--r--crates/typst-ide/src/complete.rs13
-rw-r--r--crates/typst-ide/src/definition.rs4
-rw-r--r--crates/typst-ide/src/jump.rs8
-rw-r--r--crates/typst-ide/src/tooltip.rs7
5 files changed, 20 insertions, 19 deletions
diff --git a/crates/typst-ide/src/analyze.rs b/crates/typst-ide/src/analyze.rs
index eaf7248b..0b41fb68 100644
--- a/crates/typst-ide/src/analyze.rs
+++ b/crates/typst-ide/src/analyze.rs
@@ -1,7 +1,8 @@
use comemo::Track;
use ecow::{eco_vec, EcoString, EcoVec};
use typst::foundations::{Label, Styles, Value};
-use typst::model::{BibliographyElem, Document};
+use typst::layout::PagedDocument;
+use typst::model::BibliographyElem;
use typst::syntax::{ast, LinkedNode, SyntaxKind};
use crate::IdeWorld;
@@ -65,7 +66,9 @@ pub fn analyze_import(world: &dyn IdeWorld, 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(document: &Document) -> (Vec<(Label, Option<EcoString>)>, usize) {
+pub fn analyze_labels(
+ document: &PagedDocument,
+) -> (Vec<(Label, Option<EcoString>)>, usize) {
let mut output = vec![];
// Labels in the document.
diff --git a/crates/typst-ide/src/complete.rs b/crates/typst-ide/src/complete.rs
index 510db54c..5c2b500a 100644
--- a/crates/typst-ide/src/complete.rs
+++ b/crates/typst-ide/src/complete.rs
@@ -9,8 +9,7 @@ use typst::foundations::{
fields_on, repr, AutoValue, CastInfo, Func, Label, NoneValue, ParamInfo, Repr,
StyleChain, Styles, Type, Value,
};
-use typst::layout::{Alignment, Dir};
-use typst::model::Document;
+use typst::layout::{Alignment, Dir, PagedDocument};
use typst::syntax::ast::AstNode;
use typst::syntax::{
ast, is_id_continue, is_id_start, is_ident, FileId, LinkedNode, Side, Source,
@@ -38,7 +37,7 @@ use crate::{analyze_expr, analyze_import, analyze_labels, named_items, IdeWorld}
/// when the document is available.
pub fn autocomplete(
world: &dyn IdeWorld,
- document: Option<&Document>,
+ document: Option<&PagedDocument>,
source: &Source,
cursor: usize,
explicit: bool,
@@ -1063,7 +1062,7 @@ fn code_completions(ctx: &mut CompletionContext, hash: bool) {
/// Context for autocompletion.
struct CompletionContext<'a> {
world: &'a (dyn IdeWorld + 'a),
- document: Option<&'a Document>,
+ document: Option<&'a PagedDocument>,
text: &'a str,
before: &'a str,
after: &'a str,
@@ -1079,7 +1078,7 @@ impl<'a> CompletionContext<'a> {
/// Create a new autocompletion context.
fn new(
world: &'a (dyn IdeWorld + 'a),
- document: Option<&'a Document>,
+ document: Option<&'a PagedDocument>,
source: &'a Source,
leaf: &'a LinkedNode<'a>,
cursor: usize,
@@ -1507,7 +1506,7 @@ impl BracketMode {
mod tests {
use std::collections::BTreeSet;
- use typst::model::Document;
+ use typst::layout::PagedDocument;
use typst::syntax::{FileId, Source, VirtualPath};
use typst::World;
@@ -1607,7 +1606,7 @@ mod tests {
fn test_full(
world: &TestWorld,
source: &Source,
- doc: Option<&Document>,
+ doc: Option<&PagedDocument>,
cursor: isize,
) -> Response {
autocomplete(world, doc, source, source.cursor(cursor), true)
diff --git a/crates/typst-ide/src/definition.rs b/crates/typst-ide/src/definition.rs
index 9303aee4..c789430a 100644
--- a/crates/typst-ide/src/definition.rs
+++ b/crates/typst-ide/src/definition.rs
@@ -1,5 +1,5 @@
use typst::foundations::{Label, Selector, Value};
-use typst::model::Document;
+use typst::layout::PagedDocument;
use typst::syntax::{ast, LinkedNode, Side, Source, Span};
use typst::utils::PicoStr;
@@ -25,7 +25,7 @@ pub enum Definition {
/// when the document is available.
pub fn definition(
world: &dyn IdeWorld,
- document: Option<&Document>,
+ document: Option<&PagedDocument>,
source: &Source,
cursor: usize,
side: Side,
diff --git a/crates/typst-ide/src/jump.rs b/crates/typst-ide/src/jump.rs
index 2dd5cf61..ba62b0ab 100644
--- a/crates/typst-ide/src/jump.rs
+++ b/crates/typst-ide/src/jump.rs
@@ -1,7 +1,7 @@
use std::num::NonZeroUsize;
-use typst::layout::{Frame, FrameItem, Point, Position, Size};
-use typst::model::{Destination, Document, Url};
+use typst::layout::{Frame, FrameItem, PagedDocument, Point, Position, Size};
+use typst::model::{Destination, Url};
use typst::syntax::{FileId, LinkedNode, Side, Source, Span, SyntaxKind};
use typst::visualize::Geometry;
use typst::WorldExt;
@@ -30,7 +30,7 @@ impl Jump {
/// Determine where to jump to based on a click in a frame.
pub fn jump_from_click(
world: &dyn IdeWorld,
- document: &Document,
+ document: &PagedDocument,
frame: &Frame,
click: Point,
) -> Option<Jump> {
@@ -110,7 +110,7 @@ pub fn jump_from_click(
/// Find the output location in the document for a cursor position.
pub fn jump_from_cursor(
- document: &Document,
+ document: &PagedDocument,
source: &Source,
cursor: usize,
) -> Vec<Position> {
diff --git a/crates/typst-ide/src/tooltip.rs b/crates/typst-ide/src/tooltip.rs
index 30aca24f..adfbeda5 100644
--- a/crates/typst-ide/src/tooltip.rs
+++ b/crates/typst-ide/src/tooltip.rs
@@ -4,8 +4,7 @@ use ecow::{eco_format, EcoString};
use if_chain::if_chain;
use typst::engine::Sink;
use typst::foundations::{repr, Capturer, CastInfo, Repr, Value};
-use typst::layout::Length;
-use typst::model::Document;
+use typst::layout::{Length, PagedDocument};
use typst::syntax::ast::AstNode;
use typst::syntax::{ast, LinkedNode, Side, Source, SyntaxKind};
use typst::utils::{round_with_precision, Numeric};
@@ -21,7 +20,7 @@ use crate::{analyze_expr, analyze_import, analyze_labels, IdeWorld};
/// document is available.
pub fn tooltip(
world: &dyn IdeWorld,
- document: Option<&Document>,
+ document: Option<&PagedDocument>,
source: &Source,
cursor: usize,
side: Side,
@@ -173,7 +172,7 @@ fn length_tooltip(length: Length) -> Option<Tooltip> {
}
/// Tooltip for a hovered reference or label.
-fn label_tooltip(document: &Document, leaf: &LinkedNode) -> Option<Tooltip> {
+fn label_tooltip(document: &PagedDocument, 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('>'),