fix: compile warnings (#1774)

This commit is contained in:
Myriad-Dreamin 2025-05-22 11:37:44 +08:00 committed by GitHub
parent 7499dcb8c4
commit 7de64aefe5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 34 additions and 20 deletions

View file

@ -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

View file

@ -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<OneOf<EcoSnippetTextEdit, EcoAnnotatedTextEdit>>,
}
/// 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<HashMap<ChangeAnnotationIdentifier, ChangeAnnotation>>,
}
/// 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<EcoTextDocumentEdit>),
/// Resource operations
Operations(Vec<EcoDocumentChangeOperation>),
}
/// 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),
}

View file

@ -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<Res, Err, QueryContext = ()> {
ctx: Mutex<Option<QueryContext>>,
/// `None` means no value has been computed yet.

View file

@ -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,
}

View file

@ -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;

View file

@ -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),
}
}
}

View file

@ -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,

View file

@ -526,9 +526,9 @@ impl<F: CompilerFeat> CompilerWorld<F> {
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<F::AccessModel> {

View file

@ -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<LspWorld>) -> 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