diff --git a/crates/tinymist-query/src/code_action.rs b/crates/tinymist-query/src/code_action.rs index 7abfd093..c433e04f 100644 --- a/crates/tinymist-query/src/code_action.rs +++ b/crates/tinymist-query/src/code_action.rs @@ -3,6 +3,7 @@ use lsp_types::CodeActionContext; use crate::{analysis::CodeActionWorker, prelude::*, SemanticRequest}; pub(crate) mod proto; +pub use proto::*; /// The [`textDocument/codeAction`] request is sent from the client to the /// server to compute commands for a given text document and range. These diff --git a/crates/tinymist-query/src/code_action/proto.rs b/crates/tinymist-query/src/code_action/proto.rs index 06f0929f..f37f5196 100644 --- a/crates/tinymist-query/src/code_action/proto.rs +++ b/crates/tinymist-query/src/code_action/proto.rs @@ -23,6 +23,7 @@ pub struct EcoSnippetTextEdit { } impl EcoSnippetTextEdit { + /// Creates a new plain text edit. pub fn new_plain(range: LspRange, new_text: EcoString) -> EcoSnippetTextEdit { EcoSnippetTextEdit { edit: EcoTextEdit::new(range, new_text), @@ -30,6 +31,7 @@ impl EcoSnippetTextEdit { } } + /// Creates a new snippet text edit. pub fn new(range: LspRange, new_text: EcoString) -> EcoSnippetTextEdit { EcoSnippetTextEdit { edit: EcoTextEdit::new(range, new_text), @@ -44,6 +46,7 @@ impl EcoSnippetTextEdit { #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct EcoAnnotatedTextEdit { + /// The base text edit. #[serde(flatten)] pub text_edit: EcoSnippetTextEdit, @@ -71,6 +74,8 @@ pub struct EcoTextDocumentEdit { pub edits: Vec>, } +/// A code action represents to a single or multiple editor behaviors that can +/// be triggered in a text document. #[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct CodeAction { @@ -176,17 +181,29 @@ pub struct EcoWorkspaceEdit { pub change_annotations: Option>, } +/// The `documentChanges` property of a `WorkspaceEdit` can contain +/// `TextDocumentEdit`s to express changes to n different text documents +/// where each text document edit addresses a specific version of a text +/// document. Or it can contain create, rename and delete file / folder +/// operations. #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] #[serde(untagged)] pub enum EcoDocumentChanges { + /// Text document edits Edits(Vec), + /// Resource operations Operations(Vec), } +/// A resource operation represents changes to existing resources or +/// creation of new resources. The operation can be a create, rename or +/// delete operation. #[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] #[serde(untagged, rename_all = "lowercase")] pub enum EcoDocumentChangeOperation { + /// A resource operation. Op(ResourceOp), + /// A text document edit. Edit(EcoTextDocumentEdit), } diff --git a/crates/tinymist-std/src/concepts/query.rs b/crates/tinymist-std/src/concepts/query.rs index 2576eb38..9fdd733f 100644 --- a/crates/tinymist-std/src/concepts/query.rs +++ b/crates/tinymist-std/src/concepts/query.rs @@ -4,11 +4,12 @@ use std::sync::OnceLock; use parking_lot::Mutex; /// Represents a reference to some lazily executed query. -/// The compute function should be pure enough during call the [`compute`] and [`compute_ref`] so that the query result -/// is consistent through any implementations (the provided `f`). +/// The compute function should be pure enough during call the [`compute`] and +/// [`compute_with_context`] so that the query result is consistent through any +/// implementations (the provided `f`). /// /// [`compute`]: Self::compute -/// [`compute_ref`]: Self::compute_ref +/// [`compute_with_context`]: Self::compute_with_context pub struct QueryRef { ctx: Mutex>, /// `None` means no value has been computed yet. diff --git a/crates/tinymist-vfs/src/lib.rs b/crates/tinymist-vfs/src/lib.rs index ce838024..255a061b 100644 --- a/crates/tinymist-vfs/src/lib.rs +++ b/crates/tinymist-vfs/src/lib.rs @@ -591,7 +591,7 @@ impl EntryMap { } } -/// A display wrapper for [`EntryMap`]. +/// A display wrapper for `EntryMap`. pub struct DisplayEntryMap<'a> { map: &'a EntryMap, } @@ -647,7 +647,7 @@ impl PathMap { } } -/// A display wrapper for [`PathMap`]. +/// A display wrapper for `PathMap`. pub struct DisplayPathMap<'a> { map: &'a PathMap, } diff --git a/crates/tinymist-world/src/font/mod.rs b/crates/tinymist-world/src/font/mod.rs index 5d337e1d..ce51fbae 100644 --- a/crates/tinymist-world/src/font/mod.rs +++ b/crates/tinymist-world/src/font/mod.rs @@ -10,9 +10,9 @@ //! The [`FontResolverImpl`] has a lot of [`FontSlot`] objects and allow to load //! font resources lazily. //! -//! There are also other structs, which help store and load [`FontInfo`] objects -//! in the local file system or the remote machine. See the [`cache`] and -//! [`profile`] crates for more details. +//! There are also other structs, which help store and load +//! [`typst::text::FontInfo`] objects in the local file system or the remote +//! machine. See the [`cache`] and `profile` crates for more details. pub mod cache; pub(crate) mod info; diff --git a/crates/tinymist-world/src/source.rs b/crates/tinymist-world/src/source.rs index 0f58671d..a221dca2 100644 --- a/crates/tinymist-world/src/source.rs +++ b/crates/tinymist-world/src/source.rs @@ -115,12 +115,10 @@ impl SourceDb { }) } - pub(crate) fn take_state(&mut self) -> Self { - let slots = std::mem::take(&mut self.slots); - + pub(crate) fn take(&mut self) -> Self { Self { is_compiling: self.is_compiling, - slots, + slots: std::mem::take(&mut self.slots), } } } diff --git a/crates/tinymist-world/src/system.rs b/crates/tinymist-world/src/system.rs index f30da2eb..d723bde3 100644 --- a/crates/tinymist-world/src/system.rs +++ b/crates/tinymist-world/src/system.rs @@ -68,7 +68,7 @@ pub struct SystemUniverseBuilder; impl SystemUniverseBuilder { /// Create [`TypstSystemUniverse`] with the given options. - /// See [`LspCompilerFeat`] for instantiation details. + /// See [`SystemCompilerFeat`] for instantiation details. pub fn build( entry: EntryState, inputs: ImmutDict, diff --git a/crates/tinymist-world/src/world.rs b/crates/tinymist-world/src/world.rs index 28321a30..06e869cc 100644 --- a/crates/tinymist-world/src/world.rs +++ b/crates/tinymist-world/src/world.rs @@ -526,9 +526,9 @@ impl CompilerWorld { self.vfs.clone_source_cache() } - /// See [`SourceDb::take_state`]. + /// Takes the current state (cache) of the source database. pub fn take_db(&mut self) -> SourceDb { - self.source_db.take_state() + self.source_db.take() } pub fn vfs(&self) -> &Vfs { diff --git a/crates/typlite/src/lib.rs b/crates/typlite/src/lib.rs index 4838c23e..2091ce71 100644 --- a/crates/typlite/src/lib.rs +++ b/crates/typlite/src/lib.rs @@ -164,10 +164,7 @@ pub struct Typlite { } impl Typlite { - /// Create a new Typlite instance from a [`World`]. - /// - /// This is useful when you have a [`Source`] instance and you can avoid - /// reparsing the content. + /// Creates a new Typlite instance from a [`World`]. pub fn new(world: Arc) -> Self { Self { world, @@ -176,7 +173,7 @@ impl Typlite { } } - /// Set conversion feature + /// Sets conversion features pub fn with_feature(mut self, feat: TypliteFeat) -> Self { self.feat = feat; self