mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-20 11:55:34 +00:00
feat: bump edition of most crates to rust 2024 (#2042)
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
Some checks are pending
tinymist::auto_tag / auto-tag (push) Waiting to run
tinymist::ci / announce (push) Blocked by required conditions
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / build (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
This commit is contained in:
parent
d227ad2a53
commit
05280aec4d
128 changed files with 340 additions and 331 deletions
|
|
@ -2,7 +2,7 @@
|
|||
description = "An integrated language service for Typst."
|
||||
authors = ["Myriad-Dreamin <camiyoru@gmail.com>", "Nathan Varner"]
|
||||
version = "0.13.22"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
readme = "README.md"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://github.com/Myriad-Dreamin/tinymist"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use tinymist::{project::LspUniverseBuilder, Config};
|
||||
use tinymist::{Config, project::LspUniverseBuilder};
|
||||
|
||||
fn main() {
|
||||
// initialize global variables
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@
|
|||
use anyhow::Context as ContextTrait;
|
||||
use comemo::Track;
|
||||
use criterion::Criterion;
|
||||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use tinymist_project::LspWorld;
|
||||
use tinymist_std::path::unix_slash;
|
||||
use tinymist_std::typst_shim::eval::eval_compat;
|
||||
use typst::World;
|
||||
use typst::engine::{Engine, Route, Sink, Traced};
|
||||
use typst::foundations::{Context, Func, Value};
|
||||
use typst::introspection::Introspector;
|
||||
use typst::World;
|
||||
|
||||
/// Runs benchmarks on the given world. An entry point must be provided in the
|
||||
/// world.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
pub use dapts::{Event, Request, Response};
|
||||
|
||||
use crate::{invalid_data_fmt, read_msg_text, write_msg_text, LspOrDapResponse};
|
||||
use crate::{LspOrDapResponse, invalid_data_fmt, read_msg_text, write_msg_text};
|
||||
|
||||
/// A message in the Debug Adaptor Protocol.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use serde::de::DeserializeOwned;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
invalid_data_fmt, read_msg_text, write_msg_text, ExtractError, LspOrDapResponse, LspResult,
|
||||
RequestId, ResponseError,
|
||||
ExtractError, LspOrDapResponse, LspResult, RequestId, ResponseError, invalid_data_fmt,
|
||||
read_msg_text, write_msg_text,
|
||||
};
|
||||
|
||||
/// A message in the Language Server Protocol.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use std::sync::{Arc, Weak};
|
|||
use futures::future::MaybeDone;
|
||||
use parking_lot::Mutex;
|
||||
use serde::Serialize;
|
||||
use serde_json::{from_value, Value as JsonValue};
|
||||
use serde_json::{Value as JsonValue, from_value};
|
||||
use tinymist_std::time::Instant;
|
||||
|
||||
use crate::msg::*;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
thread,
|
||||
};
|
||||
|
||||
use crossbeam_channel::{bounded, unbounded, Receiver, Sender};
|
||||
use crossbeam_channel::{Receiver, Sender, bounded, unbounded};
|
||||
|
||||
use crate::{Connection, ConnectionRx, ConnectionTx, GetMessageKind, Message};
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use std::{
|
|||
|
||||
use dashmap::{DashMap, SharedValue};
|
||||
use ecow::{EcoString, EcoVec};
|
||||
use hashbrown::{hash_map::RawEntryMut, HashMap};
|
||||
use hashbrown::{HashMap, hash_map::RawEntryMut};
|
||||
use parking_lot::Mutex;
|
||||
use rustc_hash::FxHasher;
|
||||
use triomphe::Arc;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::tidy::*;
|
||||
|
|
|
|||
|
|
@ -70,9 +70,11 @@ pub fn to_typst_position(
|
|||
|
||||
if should_warning {
|
||||
log::warn!(
|
||||
"LSP position is out of bounds: {:?}, while only {:?} lines and {:?} characters at the end.",
|
||||
lsp_position, typst_source.len_lines(), typst_source.line_to_range(typst_source.len_lines() - 1),
|
||||
);
|
||||
"LSP position is out of bounds: {:?}, while only {:?} lines and {:?} characters at the end.",
|
||||
lsp_position,
|
||||
typst_source.len_lines(),
|
||||
typst_source.line_to_range(typst_source.len_lines() - 1),
|
||||
);
|
||||
}
|
||||
|
||||
return Some(typst_source.len_bytes());
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ pub use std::ops::Range;
|
|||
pub use std::path::Path;
|
||||
|
||||
pub use ecow::EcoVec;
|
||||
pub use typst::World;
|
||||
pub use typst::diag::{EcoString, FileError};
|
||||
pub use typst::syntax::FileId as TypstFileId;
|
||||
pub use typst::syntax::{
|
||||
LinkedNode, Source, SyntaxKind, SyntaxNode, VirtualPath,
|
||||
ast::{self, AstNode},
|
||||
package::{PackageManifest, PackageSpec},
|
||||
LinkedNode, Source, SyntaxKind, SyntaxNode, VirtualPath,
|
||||
};
|
||||
pub use typst::World;
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ use core::fmt;
|
|||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ecow::{eco_format, eco_vec, EcoString, EcoVec};
|
||||
use ecow::{EcoString, EcoVec, eco_format, eco_vec};
|
||||
use typst::foundations::{Closure, Func};
|
||||
use typst::syntax::ast::AstNode;
|
||||
use typst::syntax::{ast, SyntaxKind};
|
||||
use typst::syntax::{SyntaxKind, ast};
|
||||
use typst::utils::LazyHash;
|
||||
|
||||
// use super::{BoundChecker, Definition};
|
||||
|
|
@ -44,16 +44,14 @@ impl Signature {
|
|||
|
||||
/// Returns the all parameters of the signature.
|
||||
pub fn params(&self) -> impl Iterator<Item = (&Interned<ParamTy>, Option<&Ty>)> {
|
||||
let primary = self.primary().params();
|
||||
// todo: with stack
|
||||
primary
|
||||
self.primary().params()
|
||||
}
|
||||
|
||||
/// Returns the type of the signature.
|
||||
pub fn type_sig(&self) -> Interned<SigTy> {
|
||||
let primary = self.primary().sig_ty.clone();
|
||||
// todo: with stack
|
||||
primary
|
||||
self.primary().sig_ty.clone()
|
||||
}
|
||||
|
||||
/// Returns the shift applied to the signature.
|
||||
|
|
|
|||
|
|
@ -174,8 +174,7 @@ impl DocCommentMatcher {
|
|||
let comments = comments.iter().map(|comment| match comment {
|
||||
RawComment::Line(line) => {
|
||||
// strip all slash prefix
|
||||
let text = line.trim_start_matches('/');
|
||||
text
|
||||
line.trim_start_matches('/')
|
||||
}
|
||||
RawComment::Block(block) => {
|
||||
fn remove_comment(text: &str) -> Option<&str> {
|
||||
|
|
|
|||
|
|
@ -590,7 +590,7 @@ impl Decl {
|
|||
impl Ord for Decl {
|
||||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
let base = match (self, other) {
|
||||
(Self::Generated(l), Self::Generated(r)) => l.0 .0.cmp(&r.0 .0),
|
||||
(Self::Generated(l), Self::Generated(r)) => l.0.0.cmp(&r.0.0),
|
||||
(Self::Module(l), Self::Module(r)) => l.fid.cmp(&r.fid),
|
||||
(Self::Docs(l), Self::Docs(r)) => l.var.cmp(&r.var).then_with(|| l.base.cmp(&r.base)),
|
||||
_ => self.span().into_raw().cmp(&other.span().into_raw()),
|
||||
|
|
@ -609,7 +609,7 @@ trait StrictCmp {
|
|||
impl Decl {
|
||||
pub fn strict_cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
let base = match (self, other) {
|
||||
(Self::Generated(l), Self::Generated(r)) => l.0 .0.cmp(&r.0 .0),
|
||||
(Self::Generated(l), Self::Generated(r)) => l.0.0.cmp(&r.0.0),
|
||||
(Self::Module(l), Self::Module(r)) => l.fid.strict_cmp(&r.fid),
|
||||
(Self::Docs(l), Self::Docs(r)) => l
|
||||
.var
|
||||
|
|
|
|||
|
|
@ -1349,7 +1349,7 @@ fn callee_context<'a>(callee: LinkedNode<'a>, node: LinkedNode<'a>) -> Option<Sy
|
|||
use SyntaxKind::*;
|
||||
match parent.kind() {
|
||||
ContentBlock | CodeBlock | Str | Raw | LineComment | BlockComment => {
|
||||
return Option::None
|
||||
return Option::None;
|
||||
}
|
||||
Args if parent.range() == args.range() => {
|
||||
break;
|
||||
|
|
@ -1490,7 +1490,7 @@ pub fn bad_completion_cursor(
|
|||
mod tests {
|
||||
use super::*;
|
||||
use insta::assert_snapshot;
|
||||
use typst::syntax::{is_newline, Side, Source};
|
||||
use typst::syntax::{Side, Source, is_newline};
|
||||
|
||||
fn map_node(source: &str, mapper: impl Fn(&LinkedNode, usize) -> char) -> String {
|
||||
let source = Source::detached(source.to_owned());
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
use comemo::Track;
|
||||
use ecow::*;
|
||||
use tinymist_std::typst::{TypstDocument, TypstPagedDocument};
|
||||
use typst::World;
|
||||
use typst::engine::{Engine, Route, Sink, Traced};
|
||||
use typst::foundations::{Context, Label, Scopes, Styles, Value};
|
||||
use typst::introspection::Introspector;
|
||||
use typst::model::BibliographyElem;
|
||||
use typst::syntax::{ast, LinkedNode, Span, SyntaxKind, SyntaxNode};
|
||||
use typst::World;
|
||||
use typst::syntax::{LinkedNode, Span, SyntaxKind, SyntaxNode, ast};
|
||||
use typst_shim::eval::Vm;
|
||||
|
||||
/// Try to determine a set of possible values for an expression.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use core::fmt;
|
|||
use std::path::Path;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use regex::RegexSet;
|
||||
use strum::{EnumIter, IntoEnumIterator};
|
||||
use typst::foundations::{CastInfo, Regex};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use typst::{
|
||||
foundations::{Content, Element, ParamInfo, Type, Value},
|
||||
syntax::{ast, FileId, Span, SyntaxKind, SyntaxNode},
|
||||
syntax::{FileId, Span, SyntaxKind, SyntaxNode, ast},
|
||||
};
|
||||
|
||||
use super::{BoundPred, BuiltinTy, PackageId};
|
||||
|
|
@ -381,25 +381,27 @@ impl NameBone {
|
|||
let mut lhs = lhs_iter.next();
|
||||
let mut rhs = rhs_iter.next();
|
||||
|
||||
std::iter::from_fn(move || 'name_scanning: loop {
|
||||
if let (Some((idx, lhs_key)), Some((j, rhs_key))) = (lhs, rhs) {
|
||||
match lhs_key.cmp(rhs_key) {
|
||||
std::cmp::Ordering::Less => {
|
||||
lhs = lhs_iter.next();
|
||||
continue 'name_scanning;
|
||||
}
|
||||
std::cmp::Ordering::Greater => {
|
||||
rhs = rhs_iter.next();
|
||||
continue 'name_scanning;
|
||||
}
|
||||
std::cmp::Ordering::Equal => {
|
||||
lhs = lhs_iter.next();
|
||||
rhs = rhs_iter.next();
|
||||
return Some((idx, j));
|
||||
std::iter::from_fn(move || {
|
||||
'name_scanning: loop {
|
||||
if let (Some((idx, lhs_key)), Some((j, rhs_key))) = (lhs, rhs) {
|
||||
match lhs_key.cmp(rhs_key) {
|
||||
std::cmp::Ordering::Less => {
|
||||
lhs = lhs_iter.next();
|
||||
continue 'name_scanning;
|
||||
}
|
||||
std::cmp::Ordering::Greater => {
|
||||
rhs = rhs_iter.next();
|
||||
continue 'name_scanning;
|
||||
}
|
||||
std::cmp::Ordering::Equal => {
|
||||
lhs = lhs_iter.next();
|
||||
rhs = rhs_iter.next();
|
||||
return Some((idx, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
return None;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use tinymist_std::hash::hash128;
|
||||
use tinymist_world::vfs::WorkspaceResolver;
|
||||
use typst::foundations::Repr;
|
||||
|
|
|
|||
|
|
@ -39,11 +39,7 @@ pub trait TyMutator {
|
|||
}
|
||||
}
|
||||
|
||||
if mutated {
|
||||
Some(types.into())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if mutated { Some(types.into()) } else { None }
|
||||
}
|
||||
|
||||
fn mutate_option(&mut self, ty: Option<&Ty>, pol: bool) -> Option<Option<Ty>> {
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ mod tests {
|
|||
use tinymist_derive::BindTyCtx;
|
||||
|
||||
use super::{DynTypeBounds, Interned, Ty, TyCtx, TypeInfo, TypeVar};
|
||||
use crate::ty::tests::*;
|
||||
use crate::ty::ApplyChecker;
|
||||
use crate::ty::tests::*;
|
||||
#[test]
|
||||
fn test_ty() {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
use std::{collections::HashMap, fmt::Write, sync::LazyLock};
|
||||
|
||||
use comemo::Tracked;
|
||||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use serde::Deserialize;
|
||||
use serde_yaml as yaml;
|
||||
use typst::{
|
||||
diag::{bail, StrResult},
|
||||
Category, Library, World,
|
||||
diag::{StrResult, bail},
|
||||
foundations::{Binding, Content, Func, Module, Type, Value},
|
||||
introspection::MetadataElem,
|
||||
syntax::Span,
|
||||
text::{FontInfo, FontStyle},
|
||||
Category, Library, World,
|
||||
};
|
||||
|
||||
mod tooltip;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use std::fmt::Write;
|
||||
|
||||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use if_chain::if_chain;
|
||||
use typst::engine::Sink;
|
||||
use typst::foundations::{repr, Capturer, Value};
|
||||
use typst::layout::Length;
|
||||
use typst::syntax::{ast, LinkedNode, Source, SyntaxKind};
|
||||
use typst::World;
|
||||
use typst::engine::Sink;
|
||||
use typst::foundations::{Capturer, Value, repr};
|
||||
use typst::layout::Length;
|
||||
use typst::syntax::{LinkedNode, Source, SyntaxKind, ast};
|
||||
use typst_shim::eval::CapturesVisitor;
|
||||
use typst_shim::syntax::LinkedNodeExt;
|
||||
use typst_shim::utils::{round_2, Numeric};
|
||||
use typst_shim::utils::{Numeric, round_2};
|
||||
|
||||
use super::{summarize_font_family, truncated_repr};
|
||||
use crate::analyze_expr;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use std::path::Path;
|
||||
|
||||
use sync_ls::transport::MirrorArgs;
|
||||
use tinymist::project::DocCommands;
|
||||
use tinymist::LONG_VERSION;
|
||||
use tinymist::project::DocCommands;
|
||||
use tinymist::{CompileFontArgs, CompileOnceArgs};
|
||||
|
||||
#[cfg(feature = "preview")]
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ use reflexo::ImmutPath;
|
|||
use reflexo_typst::WorldComputeGraph;
|
||||
use tinymist_std::error::prelude::*;
|
||||
|
||||
use tinymist::ExportTask;
|
||||
use tinymist::project::*;
|
||||
use tinymist::world::system::print_diagnostics;
|
||||
use tinymist::ExportTask;
|
||||
|
||||
/// Arguments for project compilation.
|
||||
#[derive(Debug, Clone, clap::Parser)]
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ use futures::future::MaybeDone;
|
|||
use parking_lot::Mutex;
|
||||
use reflexo::ImmutPath;
|
||||
use reflexo_typst::package::PackageSpec;
|
||||
use sync_ls::transport::{with_stdio_transport, MirrorArgs};
|
||||
use sync_ls::transport::{MirrorArgs, with_stdio_transport};
|
||||
use sync_ls::{
|
||||
internal_error, DapBuilder, DapMessage, GetMessageKind, LsHook, LspBuilder, LspClientRoot,
|
||||
LspMessage, LspResult, Message, RequestId, TConnectionTx,
|
||||
DapBuilder, DapMessage, GetMessageKind, LsHook, LspBuilder, LspClientRoot, LspMessage,
|
||||
LspResult, Message, RequestId, TConnectionTx, internal_error,
|
||||
};
|
||||
use tinymist::world::TaskInputs;
|
||||
use tinymist::LONG_VERSION;
|
||||
use tinymist::world::TaskInputs;
|
||||
use tinymist::{Config, RegularInit, ServerState, SuperInit, UserActionTask};
|
||||
use tinymist_project::EntryResolver;
|
||||
use tinymist_query::package::PackageInfo;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ use hyper_tungstenite::tungstenite::Message;
|
|||
use tinymist::{
|
||||
project::ProjectPreviewState,
|
||||
tool::{
|
||||
preview::{bind_streams, make_http_server, PreviewCliArgs, ProjectPreviewHandler},
|
||||
project::{start_project, ProjectOpts, StartProjectResult},
|
||||
preview::{PreviewCliArgs, ProjectPreviewHandler, bind_streams, make_http_server},
|
||||
project::{ProjectOpts, StartProjectResult, start_project},
|
||||
},
|
||||
};
|
||||
use tinymist_assets::TYPST_PREVIEW_HTML;
|
||||
use tinymist_preview::{
|
||||
frontend_html, ControlPlaneMessage, ControlPlaneTx, PreviewBuilder, PreviewConfig,
|
||||
ControlPlaneMessage, ControlPlaneTx, PreviewBuilder, PreviewConfig, frontend_html,
|
||||
};
|
||||
use tinymist_project::WorldProvider;
|
||||
use tinymist_std::error::prelude::*;
|
||||
|
|
@ -143,7 +143,9 @@ pub async fn preview_main(args: PreviewCliArgs) -> Result<()> {
|
|||
let frontend_html = frontend_html(TYPST_PREVIEW_HTML, args.preview.preview_mode, "/");
|
||||
|
||||
let static_server = if let Some(static_file_host) = static_file_host {
|
||||
log::warn!("--static-file-host is deprecated, which will be removed in the future. Use --data-plane-host instead.");
|
||||
log::warn!(
|
||||
"--static-file-host is deprecated, which will be removed in the future. Use --data-plane-host instead."
|
||||
);
|
||||
let html = frontend_html.clone();
|
||||
Some(make_http_server(html, static_file_host, websocket_tx.clone()).await)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ use core::fmt;
|
|||
use std::collections::HashSet;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::sync::{atomic::AtomicBool, Arc};
|
||||
use std::sync::{Arc, atomic::AtomicBool};
|
||||
|
||||
use itertools::Either;
|
||||
use parking_lot::Mutex;
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
use reflexo::ImmutPath;
|
||||
use reflexo_typst::{vfs::FileId, TypstDocument, TypstHtmlDocument};
|
||||
use reflexo_typst::{TypstDocument, TypstHtmlDocument, vfs::FileId};
|
||||
use tinymist_debug::CoverageResult;
|
||||
use tinymist_project::world::{system::print_diagnostics, DiagnosticFormat};
|
||||
use tinymist_project::world::{DiagnosticFormat, system::print_diagnostics};
|
||||
use tinymist_query::analysis::Analysis;
|
||||
use tinymist_query::syntax::{cast_include_expr, find_source_by_expr, node_ancestors};
|
||||
use tinymist_query::testing::{TestCaseKind, TestSuites};
|
||||
|
|
@ -20,13 +20,13 @@ use tinymist_std::{bail, error::prelude::*, fs::paths::write_atomic, typst::Typs
|
|||
use typst::diag::{Severity, SourceDiagnostic};
|
||||
use typst::ecow::EcoVec;
|
||||
use typst::foundations::{Context, Label};
|
||||
use typst::syntax::{ast, LinkedNode, Source, Span};
|
||||
use typst::{utils::PicoStr, World};
|
||||
use typst::syntax::{LinkedNode, Source, Span, ast};
|
||||
use typst::{World, utils::PicoStr};
|
||||
use typst_shim::eval::TypstEngine;
|
||||
|
||||
use tinymist::project::*;
|
||||
use tinymist::tool::project::{start_project, StartProjectResult};
|
||||
use tinymist::world::{with_main, SourceWorld};
|
||||
use tinymist::tool::project::{StartProjectResult, start_project};
|
||||
use tinymist::world::{SourceWorld, with_main};
|
||||
|
||||
use crate::utils::exit_on_ctrl_c;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,22 +16,22 @@
|
|||
|
||||
pub use tinymist_debug::BreakpointKind;
|
||||
|
||||
use std::sync::{mpsc, Arc};
|
||||
use std::sync::{Arc, mpsc};
|
||||
|
||||
use comemo::Track;
|
||||
use comemo::Tracked;
|
||||
use parking_lot::Mutex;
|
||||
use tinymist_debug::{set_debug_session, DebugSession, DebugSessionHandler};
|
||||
use tinymist_debug::{DebugSession, DebugSessionHandler, set_debug_session};
|
||||
use tinymist_std::typst_shim::eval::{Eval, Vm};
|
||||
use tinymist_world::{CompilerFeat, CompilerWorld};
|
||||
use typst::{
|
||||
__bail as bail, World,
|
||||
diag::{SourceResult, Warned},
|
||||
engine::{Engine, Route, Sink, Traced},
|
||||
foundations::{Context, Scopes, Value},
|
||||
introspection::Introspector,
|
||||
layout::PagedDocument,
|
||||
syntax::{ast, parse_code, Span},
|
||||
World, __bail as bail,
|
||||
syntax::{Span, ast, parse_code},
|
||||
};
|
||||
|
||||
type RequestId = i64;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use tinymist_world::{CompilerFeat, CompilerWorld};
|
|||
use typst::diag::FileResult;
|
||||
use typst::foundations::func;
|
||||
use typst::syntax::ast::AstNode;
|
||||
use typst::syntax::{ast, Source, Span, SyntaxNode};
|
||||
use typst::syntax::{Source, Span, SyntaxNode, ast};
|
||||
use typst::{World, WorldExt};
|
||||
|
||||
use crate::instrument::Instrumenter;
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ use comemo::Tracked;
|
|||
use parking_lot::RwLock;
|
||||
use tinymist_std::hash::{FxHashMap, FxHashSet};
|
||||
use tinymist_world::vfs::FileId;
|
||||
use typst::World;
|
||||
use typst::diag::FileResult;
|
||||
use typst::engine::Engine;
|
||||
use typst::foundations::{func, Binding, Context, Dict, Scopes};
|
||||
use typst::foundations::{Binding, Context, Dict, Scopes, func};
|
||||
use typst::syntax::{Source, Span};
|
||||
use typst::World;
|
||||
|
||||
use crate::instrument::Instrumenter;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use typst::diag::FileError;
|
||||
use typst::syntax::ast::{self, AstNode};
|
||||
use typst::syntax::SyntaxNode;
|
||||
use typst::syntax::ast::{self, AstNode};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ use std::sync::Arc;
|
|||
|
||||
use parking_lot::Mutex;
|
||||
use tinymist_std::hash::FxHashMap;
|
||||
use tinymist_world::vfs::PathResolution;
|
||||
use tinymist_world::SourceWorld;
|
||||
use tinymist_world::{vfs::FileId, CompilerFeat, CompilerWorld};
|
||||
use tinymist_world::vfs::PathResolution;
|
||||
use tinymist_world::{CompilerFeat, CompilerWorld, vfs::FileId};
|
||||
use typst::Library;
|
||||
use typst::diag::FileResult;
|
||||
use typst::foundations::{Bytes, Datetime};
|
||||
use typst::syntax::Source;
|
||||
use typst::text::{Font, FontBook};
|
||||
use typst::utils::LazyHash;
|
||||
use typst::Library;
|
||||
|
||||
pub trait Instrumenter: Send + Sync {
|
||||
fn instrument(&self, source: Source) -> FileResult<Source>;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
pub use cov::CoverageResult;
|
||||
pub use debugger::{
|
||||
set_debug_session, with_debug_session, BreakpointKind, DebugSession, DebugSessionHandler,
|
||||
BreakpointKind, DebugSession, DebugSessionHandler, set_debug_session, with_debug_session,
|
||||
};
|
||||
|
||||
mod cov;
|
||||
|
|
@ -16,11 +16,11 @@ use debugger::BreakpointInstr;
|
|||
use parking_lot::Mutex;
|
||||
use tinymist_std::{error::prelude::*, hash::FxHashMap};
|
||||
use tinymist_world::package::PackageSpec;
|
||||
use tinymist_world::{print_diagnostics, CompilerFeat, CompilerWorld};
|
||||
use tinymist_world::{CompilerFeat, CompilerWorld, print_diagnostics};
|
||||
use typst::Library;
|
||||
use typst::diag::EcoString;
|
||||
use typst::syntax::package::PackageVersion;
|
||||
use typst::utils::LazyHash;
|
||||
use typst::Library;
|
||||
|
||||
use cov::*;
|
||||
use instrument::InstrumentWorld;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ keywords = ["typst"]
|
|||
version = "0.13.16"
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
edition = "2024"
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ keywords = ["language", "typst"]
|
|||
version = "0.13.16"
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
edition = "2024"
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ use tinymist_analysis::{
|
|||
};
|
||||
use tinymist_project::LspWorld;
|
||||
use typst::{
|
||||
diag::{eco_format, EcoString, SourceDiagnostic, Tracepoint},
|
||||
diag::{EcoString, SourceDiagnostic, Tracepoint, eco_format},
|
||||
ecow::EcoVec,
|
||||
syntax::{
|
||||
ast::{self, AstNode},
|
||||
FileId, Span, Spanned, SyntaxNode,
|
||||
ast::{self, AstNode},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ keywords = ["api", "language", "typst"]
|
|||
version = "0.13.16"
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
edition = "2024"
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ use tinymist_std::{bail, error::prelude::Result};
|
|||
|
||||
pub use tinymist_world::args::{CompileFontArgs, CompilePackageArgs};
|
||||
|
||||
use crate::model::*;
|
||||
use crate::PROJECT_ROUTE_USER_ACTION_PRIORITY;
|
||||
use crate::model::*;
|
||||
|
||||
/// Project document commands.
|
||||
#[derive(Debug, Clone, clap::Subcommand)]
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ use std::collections::HashSet;
|
|||
use std::path::Path;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
use ecow::{eco_vec, EcoVec};
|
||||
use ecow::{EcoVec, eco_vec};
|
||||
use tinymist_std::error::prelude::Result;
|
||||
use tinymist_std::{typst::TypstDocument, ImmutPath};
|
||||
use tinymist_std::{ImmutPath, typst::TypstDocument};
|
||||
use tinymist_task::ExportTarget;
|
||||
use tinymist_world::vfs::notify::{
|
||||
FilesystemEvent, MemoryEvent, NotifyDeps, NotifyMessage, UpstreamUpdateEvent,
|
||||
|
|
@ -190,7 +190,7 @@ impl fmt::Display for CompileReportMsg<'_> {
|
|||
Suspend => return f.write_str("suspended"),
|
||||
Compiling => return f.write_str("compiling"),
|
||||
CompileSuccess(Res { diag: 0, elapsed }) => {
|
||||
return write!(f, "{input:?}: compilation succeeded in {elapsed:?}")
|
||||
return write!(f, "{input:?}: compilation succeeded in {elapsed:?}");
|
||||
}
|
||||
CompileSuccess(res) => ("compilation succeeded", res),
|
||||
CompileError(res) => ("compilation failed", res),
|
||||
|
|
@ -808,7 +808,7 @@ impl<F: CompilerFeat, Ext: 'static> ProjectInsState<F, Ext> {
|
|||
pub fn may_compile(
|
||||
&mut self,
|
||||
handler: &Arc<dyn CompileHandler<F, Ext>>,
|
||||
) -> Option<impl FnOnce() -> CompiledArtifact<F>> {
|
||||
) -> Option<impl FnOnce() -> CompiledArtifact<F> + 'static> {
|
||||
if !self.reason.any() || self.verse.entry_state().is_inactive() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ use std::sync::Arc;
|
|||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tinymist_l10n::DebugL10n;
|
||||
use tinymist_std::ImmutPath;
|
||||
use tinymist_std::error::prelude::*;
|
||||
use tinymist_std::hash::FxDashMap;
|
||||
use tinymist_std::ImmutPath;
|
||||
use tinymist_world::EntryState;
|
||||
use typst::syntax::VirtualPath;
|
||||
|
||||
|
|
@ -131,7 +131,9 @@ impl EntryResolver {
|
|||
Some(VirtualPath::new(stripped)),
|
||||
)),
|
||||
Err(err) => {
|
||||
log::info!("Entry is not in root directory: err {err:?}: entry: {entry:?}, root: {root:?}");
|
||||
log::info!(
|
||||
"Entry is not in root directory: err {err:?}: entry: {entry:?}, root: {root:?}"
|
||||
);
|
||||
EntryState::new_rooted_by_parent(entry)
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ use std::cmp::Ordering;
|
|||
use std::io::{Read, Seek, SeekFrom, Write};
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
use ecow::{eco_vec, EcoVec};
|
||||
use ecow::{EcoVec, eco_vec};
|
||||
use tinymist_std::error::prelude::*;
|
||||
use tinymist_std::path::unix_slash;
|
||||
use tinymist_std::{bail, ImmutPath};
|
||||
use tinymist_std::{ImmutPath, bail};
|
||||
use tinymist_task::CtxPath;
|
||||
use typst::diag::EcoString;
|
||||
use typst::World;
|
||||
use typst::diag::EcoString;
|
||||
|
||||
use crate::model::{ApplyProjectTask, Id, ProjectInput, ProjectRoute, ResourcePath};
|
||||
use crate::{LockFile, LockFileCompat, LspWorld, ProjectPathMaterial, LOCK_FILENAME, LOCK_VERSION};
|
||||
use crate::{LOCK_FILENAME, LOCK_VERSION, LockFile, LockFileCompat, LspWorld, ProjectPathMaterial};
|
||||
|
||||
impl LockFile {
|
||||
pub fn get_document(&self, id: &Id) -> Option<&ProjectInput> {
|
||||
|
|
@ -169,13 +169,13 @@ impl LockFile {
|
|||
Some(Ordering::Equal | Ordering::Less) => {}
|
||||
Some(Ordering::Greater) => {
|
||||
bail!(
|
||||
"trying to update lock file having a future version, current tinymist-cli supports {LOCK_VERSION}, the lock file is {version}",
|
||||
);
|
||||
"trying to update lock file having a future version, current tinymist-cli supports {LOCK_VERSION}, the lock file is {version}",
|
||||
);
|
||||
}
|
||||
None => {
|
||||
bail!(
|
||||
"cannot compare version, are version strings in right format? current tinymist-cli supports {LOCK_VERSION}, the lock file is {version}",
|
||||
);
|
||||
"cannot compare version, are version strings in right format? current tinymist-cli supports {LOCK_VERSION}, the lock file is {version}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use tinymist_std::error::prelude::*;
|
||||
use tinymist_std::ImmutPath;
|
||||
use tinymist_std::error::prelude::*;
|
||||
use tinymist_task::ExportTarget;
|
||||
use tinymist_world::package::RegistryPathMapper;
|
||||
use tinymist_world::vfs::Vfs;
|
||||
use tinymist_world::{args::*, WorldComputeGraph};
|
||||
use tinymist_world::{
|
||||
CompileSnapshot, CompilerFeat, CompilerUniverse, CompilerWorld, EntryOpts, EntryState,
|
||||
};
|
||||
use tinymist_world::{WorldComputeGraph, args::*};
|
||||
use typst::Features;
|
||||
use typst::diag::FileResult;
|
||||
use typst::foundations::{Bytes, Dict};
|
||||
use typst::utils::LazyHash;
|
||||
use typst::Features;
|
||||
|
||||
use crate::world::font::FontResolverImpl;
|
||||
use crate::{CompiledArtifact, Interrupt};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
use ecow::EcoVec;
|
||||
use tinymist_std::error::prelude::*;
|
||||
use tinymist_std::{bail, ImmutPath};
|
||||
use tinymist_std::{ImmutPath, bail};
|
||||
use typst::diag::EcoString;
|
||||
|
||||
pub use task::*;
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
|
||||
use tinymist_std::{error::IgnoreLogging, ImmutPath};
|
||||
use tinymist_std::{ImmutPath, error::IgnoreLogging};
|
||||
use tinymist_world::vfs::notify::NotifyDeps;
|
||||
use tokio::sync::mpsc;
|
||||
use typst::diag::FileError;
|
||||
|
||||
use tinymist_world::vfs::{
|
||||
FileChangeSet, FileSnapshot, PathAccessModel,
|
||||
notify::{FilesystemEvent, NotifyMessage, UpstreamUpdateEvent},
|
||||
system::SystemAccessModel,
|
||||
FileChangeSet, FileSnapshot, PathAccessModel,
|
||||
};
|
||||
|
||||
type WatcherPair = (RecommendedWatcher, mpsc::UnboundedReceiver<NotifyEvent>);
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ pub use tinymist_world as base;
|
|||
pub use tinymist_world::args::*;
|
||||
pub use tinymist_world::config::CompileFontOpts;
|
||||
pub use tinymist_world::entry::*;
|
||||
pub use tinymist_world::{diag, font, package, vfs};
|
||||
pub use tinymist_world::{
|
||||
with_main, CompilerUniverse, CompilerWorld, DiagnosticFormat, EntryOpts, EntryState,
|
||||
RevisingUniverse, SourceWorld, TaskInputs,
|
||||
CompilerUniverse, CompilerWorld, DiagnosticFormat, EntryOpts, EntryState, RevisingUniverse,
|
||||
SourceWorld, TaskInputs, with_main,
|
||||
};
|
||||
pub use tinymist_world::{diag, font, package, vfs};
|
||||
|
||||
#[cfg(feature = "system")]
|
||||
pub use tinymist_world::system;
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ use std::sync::Arc;
|
|||
use ecow::eco_format;
|
||||
use lsp_types::Url;
|
||||
use tinymist_project::LspComputeGraph;
|
||||
use tinymist_std::{bail, Result};
|
||||
use tinymist_std::{Result, bail};
|
||||
use tinymist_world::{EntryReader, TaskInputs};
|
||||
use typst::diag::{FileError, FileResult};
|
||||
use typst::foundations::{Func, Value};
|
||||
use typst::syntax::FileId;
|
||||
|
||||
use crate::{path_res_to_url, CompilerQueryResponse, SemanticRequest, StatefulRequest};
|
||||
use crate::{CompilerQueryResponse, SemanticRequest, StatefulRequest, path_res_to_url};
|
||||
|
||||
pub(crate) trait ToFunc {
|
||||
fn to_func(&self) -> Option<Func>;
|
||||
|
|
@ -472,7 +472,7 @@ mod signature_tests {
|
|||
use typst::syntax::LinkedNode;
|
||||
use typst_shim::syntax::LinkedNodeExt;
|
||||
|
||||
use crate::analysis::{analyze_signature, Signature, SignatureTarget};
|
||||
use crate::analysis::{Signature, SignatureTarget, analyze_signature};
|
||||
use crate::syntax::classify_syntax;
|
||||
use crate::tests::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//! Hybrid analysis for function calls.
|
||||
|
||||
use super::prelude::*;
|
||||
use super::Signature;
|
||||
use crate::analysis::{analyze_signature, PrimarySignature, SignatureTarget};
|
||||
use super::prelude::*;
|
||||
use crate::analysis::{PrimarySignature, SignatureTarget, analyze_signature};
|
||||
|
||||
/// Describes kind of a parameter.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use ecow::eco_format;
|
|||
use lsp_types::{ChangeAnnotation, CreateFile, CreateFileOptions};
|
||||
use regex::Regex;
|
||||
use tinymist_analysis::syntax::{
|
||||
adjust_expr, node_ancestors, previous_items, PreviousItem, SyntaxClass,
|
||||
PreviousItem, SyntaxClass, adjust_expr, node_ancestors, previous_items,
|
||||
};
|
||||
use tinymist_std::path::{diff, unix_slash};
|
||||
use typst::syntax::Side;
|
||||
|
|
@ -12,7 +12,7 @@ use typst::syntax::Side;
|
|||
use super::get_link_exprs_in;
|
||||
use crate::analysis::LinkTarget;
|
||||
use crate::prelude::*;
|
||||
use crate::syntax::{interpret_mode_at, InterpretMode};
|
||||
use crate::syntax::{InterpretMode, interpret_mode_at};
|
||||
|
||||
/// Analyzes the document and provides code actions.
|
||||
pub struct CodeActionWorker<'a> {
|
||||
|
|
|
|||
|
|
@ -4,26 +4,26 @@ use std::cmp::Reverse;
|
|||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::ops::Range;
|
||||
|
||||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use if_chain::if_chain;
|
||||
use lsp_types::InsertTextFormat;
|
||||
use regex::{Captures, Regex};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tinymist_analysis::syntax::{bad_completion_cursor, BadCompletionCursor};
|
||||
use tinymist_analysis::{analyze_labels, func_signature, DynLabel};
|
||||
use tinymist_analysis::syntax::{BadCompletionCursor, bad_completion_cursor};
|
||||
use tinymist_analysis::{DynLabel, analyze_labels, func_signature};
|
||||
use tinymist_derive::BindTyCtx;
|
||||
use tinymist_project::LspWorld;
|
||||
use tinymist_std::path::unix_slash;
|
||||
use tinymist_std::typst::TypstDocument;
|
||||
use typst::World;
|
||||
use typst::foundations::{
|
||||
fields_on, format_str, repr, AutoValue, Func, Label, NoneValue, Repr, Scope, StyleChain, Type,
|
||||
Value,
|
||||
AutoValue, Func, Label, NoneValue, Repr, Scope, StyleChain, Type, Value, fields_on, format_str,
|
||||
repr,
|
||||
};
|
||||
use typst::syntax::ast::{self, AstNode, Param};
|
||||
use typst::syntax::{is_id_continue, is_id_start, is_ident};
|
||||
use typst::text::RawElem;
|
||||
use typst::visualize::Color;
|
||||
use typst::World;
|
||||
use typst_shim::{syntax::LinkedNodeExt, utils::hash128};
|
||||
use unscanny::Scanner;
|
||||
|
||||
|
|
@ -31,14 +31,14 @@ use crate::adt::interner::Interned;
|
|||
use crate::analysis::{BuiltinTy, LocalContext, PathPreference, Ty};
|
||||
use crate::completion::{
|
||||
Completion, CompletionCommand, CompletionContextKey, CompletionItem, CompletionKind,
|
||||
EcoTextEdit, ParsedSnippet, PostfixSnippet, PostfixSnippetScope, PrefixSnippet,
|
||||
DEFAULT_POSTFIX_SNIPPET, DEFAULT_PREFIX_SNIPPET,
|
||||
DEFAULT_POSTFIX_SNIPPET, DEFAULT_PREFIX_SNIPPET, EcoTextEdit, ParsedSnippet, PostfixSnippet,
|
||||
PostfixSnippetScope, PrefixSnippet,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
use crate::syntax::{
|
||||
InterpretMode, PreviousDecl, SurroundingSyntax, SyntaxClass, SyntaxContext, VarClass,
|
||||
classify_context, interpret_mode_at, is_ident_like, node_ancestors, previous_decls,
|
||||
surrounding_syntax, InterpretMode, PreviousDecl, SurroundingSyntax, SyntaxClass, SyntaxContext,
|
||||
VarClass,
|
||||
surrounding_syntax,
|
||||
};
|
||||
use crate::ty::{
|
||||
DynTypeBounds, Iface, IfaceChecker, InsTy, SigTy, TyCtx, TypeInfo, TypeInterface, TypeVar,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use tinymist_std::typst::TypstDocument;
|
|||
use typst::foundations::{Label, Selector, Type};
|
||||
use typst::introspection::Introspector;
|
||||
|
||||
use super::{prelude::*, InsTy, SharedContext};
|
||||
use super::{InsTy, SharedContext, prelude::*};
|
||||
use crate::syntax::{Decl, DeclExpr, Expr, ExprInfo, SyntaxClass, VarClass};
|
||||
use crate::ty::DocSource;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::num::NonZeroUsize;
|
||||
use std::ops::DerefMut;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::{collections::HashSet, ops::Deref};
|
||||
|
||||
use comemo::{Track, Tracked};
|
||||
|
|
@ -15,11 +15,11 @@ use tinymist_analysis::ty::term_value;
|
|||
use tinymist_analysis::{analyze_expr_, analyze_import_};
|
||||
use tinymist_lint::LintInfo;
|
||||
use tinymist_project::{LspComputeGraph, LspWorld, TaskWhen};
|
||||
use tinymist_std::hash::{hash128, FxDashMap};
|
||||
use tinymist_std::hash::{FxDashMap, hash128};
|
||||
use tinymist_std::typst::TypstDocument;
|
||||
use tinymist_world::debug_loc::DataSource;
|
||||
use tinymist_world::vfs::{PathResolution, WorkspaceResolver};
|
||||
use tinymist_world::{EntryReader, DETACHED_ENTRY};
|
||||
use tinymist_world::{DETACHED_ENTRY, EntryReader};
|
||||
use typst::diag::{At, FileError, FileResult, SourceDiagnostic, SourceResult, StrResult};
|
||||
use typst::foundations::{Bytes, IntoValue, Module, StyleChain, Styles};
|
||||
use typst::introspection::Introspector;
|
||||
|
|
@ -27,23 +27,23 @@ use typst::layout::Position;
|
|||
use typst::model::BibliographyElem;
|
||||
use typst::syntax::package::{PackageManifest, PackageSpec};
|
||||
use typst::syntax::{Span, VirtualPath};
|
||||
use typst_shim::eval::{eval_compat, Eval};
|
||||
use typst_shim::eval::{Eval, eval_compat};
|
||||
|
||||
use super::{LspQuerySnapshot, TypeEnv};
|
||||
use crate::adt::revision::{RevisionLock, RevisionManager, RevisionManagerLike, RevisionSlot};
|
||||
use crate::analysis::prelude::*;
|
||||
use crate::analysis::{
|
||||
analyze_signature, bib_info, definition, post_type_check, AnalysisStats, BibInfo,
|
||||
CompletionFeat, Definition, PathPreference, QueryStatGuard, SemanticTokenCache,
|
||||
SemanticTokenContext, SemanticTokens, Signature, SignatureTarget, Ty, TypeInfo,
|
||||
AnalysisStats, BibInfo, CompletionFeat, Definition, PathPreference, QueryStatGuard,
|
||||
SemanticTokenCache, SemanticTokenContext, SemanticTokens, Signature, SignatureTarget, Ty,
|
||||
TypeInfo, analyze_signature, bib_info, definition, post_type_check,
|
||||
};
|
||||
use crate::docs::{DefDocs, TidyModuleDocs};
|
||||
use crate::syntax::{
|
||||
Decl, DefKind, ExprInfo, ExprRoute, LexicalScope, ModuleDependency, SyntaxClass,
|
||||
classify_syntax, construct_module_dependencies, is_mark, resolve_id_by_path,
|
||||
scan_workspace_files, Decl, DefKind, ExprInfo, ExprRoute, LexicalScope, ModuleDependency,
|
||||
SyntaxClass,
|
||||
scan_workspace_files,
|
||||
};
|
||||
use crate::upstream::{tooltip_, Tooltip};
|
||||
use crate::upstream::{Tooltip, tooltip_};
|
||||
use crate::{
|
||||
ColorTheme, CompilerQueryRequest, LspPosition, LspRange, LspWorldExt, PositionEncoding,
|
||||
};
|
||||
|
|
@ -823,7 +823,7 @@ impl SharedContext {
|
|||
.terms
|
||||
.m
|
||||
.get(&hash128(&cache_key))
|
||||
.and_then(|slot| (cache_key == &slot.1 .0).then_some(slot.1 .1.clone()));
|
||||
.and_then(|slot| (cache_key == &slot.1.0).then_some(slot.1.1.clone()));
|
||||
if let Some(cached) = cached {
|
||||
return cached;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
use std::collections::HashSet;
|
||||
use tinymist_derive::BindTyCtx;
|
||||
|
||||
use super::{prelude::*, DynTypeBounds, ParamAttrs, ParamTy, SharedContext};
|
||||
use super::{
|
||||
ArgsTy, Sig, SigChecker, SigShape, SigSurfaceKind, SigTy, Ty, TyCtx, TyCtxMut, TypeBounds,
|
||||
TypeInfo, TypeVar,
|
||||
};
|
||||
use crate::syntax::{classify_context, classify_context_outer, ArgClass, SyntaxContext, VarClass};
|
||||
use super::{DynTypeBounds, ParamAttrs, ParamTy, SharedContext, prelude::*};
|
||||
use crate::syntax::{ArgClass, SyntaxContext, VarClass, classify_context, classify_context_outer};
|
||||
use crate::ty::BuiltinTy;
|
||||
|
||||
/// With given type information, check the type of a literal expression again by
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ pub use std::path::Path;
|
|||
pub use std::sync::{Arc, LazyLock};
|
||||
|
||||
pub use ecow::*;
|
||||
pub use typst::World;
|
||||
pub use typst::foundations::{Func, Value};
|
||||
pub use typst::syntax::ast::{self, AstNode};
|
||||
pub use typst::syntax::{FileId as TypstFileId, LinkedNode, Source, Span, SyntaxKind, SyntaxNode};
|
||||
pub use typst::World;
|
||||
pub use typst_shim::syntax::LinkedNodeExt;
|
||||
pub use typst_shim::utils::LazyHash;
|
||||
|
||||
pub(crate) use super::{LocalContext, ToFunc};
|
||||
pub(crate) use crate::StrRef;
|
||||
pub(crate) use crate::adt::interner::Interned;
|
||||
pub use crate::ty::Ty;
|
||||
pub(crate) use crate::StrRef;
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ use lsp_types::{SemanticTokenModifier, SemanticTokenType};
|
|||
use parking_lot::Mutex;
|
||||
use strum::EnumIter;
|
||||
use tinymist_std::ImmutPath;
|
||||
use typst::syntax::{ast, LinkedNode, Source, SyntaxKind};
|
||||
use typst::syntax::{LinkedNode, Source, SyntaxKind, ast};
|
||||
|
||||
use crate::{
|
||||
LocalContext, LspPosition, PositionEncoding,
|
||||
adt::revision::{RevisionLock, RevisionManager, RevisionManagerLike, RevisionSlot},
|
||||
syntax::{Expr, ExprInfo},
|
||||
ty::Ty,
|
||||
LocalContext, LspPosition, PositionEncoding,
|
||||
};
|
||||
|
||||
/// A shared semantic tokens object.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
//! Analysis of function signatures.
|
||||
|
||||
use itertools::Either;
|
||||
use tinymist_analysis::{func_signature, ArgInfo, ArgsInfo, PartialSignature};
|
||||
use tinymist_analysis::{ArgInfo, ArgsInfo, PartialSignature, func_signature};
|
||||
use tinymist_derive::BindTyCtx;
|
||||
|
||||
use super::{prelude::*, Definition, SharedContext};
|
||||
use super::{Definition, SharedContext, prelude::*};
|
||||
use crate::analysis::PostTypeChecker;
|
||||
use crate::docs::{UntypedDefDocs, UntypedSignatureDocs, UntypedVarDocs};
|
||||
use crate::syntax::classify_def_loosely;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
|||
use tinymist_derive::BindTyCtx;
|
||||
|
||||
use super::{
|
||||
prelude::*, BuiltinTy, DynTypeBounds, FlowVarKind, SharedContext, TyCtxMut, TypeInfo, TypeVar,
|
||||
TypeVarBounds,
|
||||
BuiltinTy, DynTypeBounds, FlowVarKind, SharedContext, TyCtxMut, TypeInfo, TypeVar,
|
||||
TypeVarBounds, prelude::*,
|
||||
};
|
||||
use crate::{
|
||||
syntax::{Decl, DeclExpr, Expr, ExprInfo, UnaryOp},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use tinymist_project::LspCompiledArtifact;
|
||||
|
||||
use crate::{prelude::*, DiagWorker, DiagnosticsMap, SemanticRequest};
|
||||
use crate::{DiagWorker, DiagnosticsMap, SemanticRequest, prelude::*};
|
||||
|
||||
/// A request to check the document for errors and lints.
|
||||
#[derive(Clone)]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use lsp_types::CodeActionContext;
|
||||
|
||||
use crate::{analysis::CodeActionWorker, prelude::*, SemanticRequest};
|
||||
use crate::{SemanticRequest, analysis::CodeActionWorker, prelude::*};
|
||||
|
||||
pub(crate) mod proto;
|
||||
pub use proto::*;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use typst_shim::syntax::LinkedNodeExt;
|
|||
|
||||
use crate::{
|
||||
prelude::*,
|
||||
syntax::{interpret_mode_at, InterpretMode},
|
||||
syntax::{InterpretMode, interpret_mode_at},
|
||||
};
|
||||
|
||||
/// A query to get the mode at a specific position in a text document.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use lsp_types::Command;
|
||||
|
||||
use crate::{prelude::*, SemanticRequest};
|
||||
use crate::{SemanticRequest, prelude::*};
|
||||
|
||||
/// The [`textDocument/codeLens`] request is sent from the client to the server
|
||||
/// to compute code lenses for a given text document.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashSet;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use strum::IntoEnumIterator;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ecow::{eco_format, EcoString};
|
||||
use ecow::{EcoString, eco_format};
|
||||
use tinymist_std::path::unix_slash;
|
||||
use tinymist_world::diag::print_diagnostics_to_string;
|
||||
use tinymist_world::vfs::WorkspaceResolver;
|
||||
|
|
@ -9,10 +9,10 @@ use tinymist_world::{
|
|||
DiagnosticFormat, EntryReader, EntryState, ShadowApi, SourceWorld, TaskInputs,
|
||||
};
|
||||
use typlite::{Format, TypliteFeat};
|
||||
use typst::World;
|
||||
use typst::diag::StrResult;
|
||||
use typst::foundations::Bytes;
|
||||
use typst::syntax::FileId;
|
||||
use typst::World;
|
||||
|
||||
use crate::analysis::SharedContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use std::sync::OnceLock;
|
||||
|
||||
use tinymist_analysis::docs::{format_ty, ParamDocs, SignatureDocs, VarDocs};
|
||||
use tinymist_analysis::ty::DocSource;
|
||||
use tinymist_analysis::Signature;
|
||||
use tinymist_analysis::docs::{ParamDocs, SignatureDocs, VarDocs, format_ty};
|
||||
use tinymist_analysis::ty::DocSource;
|
||||
use typst::syntax::Span;
|
||||
|
||||
use crate::LocalContext;
|
||||
|
|
|
|||
|
|
@ -2,18 +2,18 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use ecow::{eco_vec, EcoString, EcoVec};
|
||||
use ecow::{EcoString, EcoVec, eco_vec};
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typst::diag::StrResult;
|
||||
use typst::syntax::package::PackageSpec;
|
||||
use typst::syntax::FileId;
|
||||
use typst::syntax::package::PackageSpec;
|
||||
|
||||
use crate::LocalContext;
|
||||
use crate::adt::interner::Interned;
|
||||
use crate::docs::file_id_repr;
|
||||
use crate::package::{get_manifest_id, PackageInfo};
|
||||
use crate::package::{PackageInfo, get_manifest_id};
|
||||
use crate::syntax::{Decl, DefKind, Expr, ExprInfo};
|
||||
use crate::LocalContext;
|
||||
|
||||
use super::DefDocs;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ use indexmap::IndexSet;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use tinymist_analysis::docs::tidy::remove_list_annotations;
|
||||
use tinymist_world::package::PackageSpec;
|
||||
use typst::diag::{eco_format, StrResult};
|
||||
use typst::diag::{StrResult, eco_format};
|
||||
use typst::syntax::package::PackageManifest;
|
||||
use typst::syntax::{FileId, Span};
|
||||
|
||||
use crate::docs::{file_id_repr, module_docs, DefDocs, PackageDefInfo};
|
||||
use crate::package::{get_manifest_id, PackageInfo};
|
||||
use crate::LocalContext;
|
||||
use crate::docs::{DefDocs, PackageDefInfo, file_id_repr, module_docs};
|
||||
use crate::package::{PackageInfo, get_manifest_id};
|
||||
|
||||
/// Documentation Information about a package.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
@ -318,10 +318,10 @@ pub fn package_docs_md(doc: &PackageDoc) -> StrResult<String> {
|
|||
None => "unknown",
|
||||
};
|
||||
let _ = writeln!(
|
||||
out,
|
||||
"#### {} ({ty:?})\n<!-- begin:param-doc {} -->\n{}\n<!-- end:param-doc {} -->",
|
||||
param.name, param.name, param.docs, param.name
|
||||
);
|
||||
out,
|
||||
"#### {} ({ty:?})\n<!-- begin:param-doc {} -->\n{}\n<!-- end:param-doc {} -->",
|
||||
param.name, param.name, param.docs, param.name
|
||||
);
|
||||
let _ = writeln!(out, "<!-- end:param -->");
|
||||
}
|
||||
}
|
||||
|
|
@ -434,7 +434,7 @@ struct ConvertResult {
|
|||
mod tests {
|
||||
use tinymist_world::package::{PackageRegistry, PackageSpec};
|
||||
|
||||
use super::{package_docs, package_docs_md, package_docs_typ, PackageInfo};
|
||||
use super::{PackageInfo, package_docs, package_docs_md, package_docs_typ};
|
||||
use crate::tests::*;
|
||||
|
||||
fn test(pkg: PackageSpec) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{analysis::ColorExprWorker, prelude::*, SemanticRequest};
|
||||
use crate::{SemanticRequest, analysis::ColorExprWorker, prelude::*};
|
||||
|
||||
/// The [`textDocument/documentColor`] request is sent from the client to the
|
||||
/// server to list all color references found in a given text document. Along
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use typst_shim::syntax::LinkedNodeExt;
|
||||
|
||||
use crate::{analysis::doc_highlight::DocumentHighlightWorker, prelude::*, SemanticRequest};
|
||||
use crate::{SemanticRequest, analysis::doc_highlight::DocumentHighlightWorker, prelude::*};
|
||||
|
||||
/// The [`textDocument/documentHighlight`] request
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{analysis::get_link_exprs, prelude::*, SemanticRequest};
|
||||
use crate::{SemanticRequest, analysis::get_link_exprs, prelude::*};
|
||||
|
||||
/// The [`textDocument/documentLink`] request is sent from the client to the
|
||||
/// server to request the location of links in a document.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
prelude::*,
|
||||
syntax::{get_lexical_hierarchy, LexicalHierarchy, LexicalScopeKind},
|
||||
SyntaxRequest,
|
||||
prelude::*,
|
||||
syntax::{LexicalHierarchy, LexicalScopeKind, get_lexical_hierarchy},
|
||||
};
|
||||
|
||||
/// The [`textDocument/documentSymbol`] request is sent from the client to the
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
use crate::{
|
||||
prelude::*,
|
||||
syntax::{get_lexical_hierarchy, LexicalHierarchy, LexicalKind, LexicalScopeKind},
|
||||
SyntaxRequest,
|
||||
prelude::*,
|
||||
syntax::{LexicalHierarchy, LexicalKind, LexicalScopeKind, get_lexical_hierarchy},
|
||||
};
|
||||
|
||||
/// The [`textDocument/foldingRange`] request is sent from the client to the
|
||||
|
|
@ -83,7 +83,9 @@ impl SyntaxRequest for FoldingRangeRequest {
|
|||
results.reverse();
|
||||
}
|
||||
|
||||
crate::log_debug_ct!("FoldingRangeRequest(line_folding_only={line_folding_only}) symbols: {hierarchy:#?} results: {results:#?}");
|
||||
crate::log_debug_ct!(
|
||||
"FoldingRangeRequest(line_folding_only={line_folding_only}) symbols: {hierarchy:#?} results: {results:#?}"
|
||||
);
|
||||
|
||||
Some(results)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use crate::{prelude::*, syntax::SyntaxClass, SemanticRequest};
|
||||
use crate::{SemanticRequest, prelude::*, syntax::SyntaxClass};
|
||||
|
||||
/// The [`textDocument/declaration`] request asks the server for the declaration
|
||||
/// location of a symbol at a given text document position.
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ use typst::foundations::repr::separated_list;
|
|||
use typst_shim::syntax::LinkedNodeExt;
|
||||
|
||||
use crate::analysis::get_link_exprs_in;
|
||||
use crate::bib::{render_citation_string, RenderedBibCitation};
|
||||
use crate::bib::{RenderedBibCitation, render_citation_string};
|
||||
use crate::jump_from_cursor;
|
||||
use crate::prelude::*;
|
||||
use crate::upstream::{route_of_value, truncated_repr, Tooltip};
|
||||
use crate::upstream::{Tooltip, route_of_value, truncated_repr};
|
||||
|
||||
/// The [`textDocument/hover`] request asks the server for hover information at
|
||||
/// a given text document position.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use lsp_types::{InlayHintKind, InlayHintLabel};
|
||||
|
||||
use crate::{
|
||||
analysis::{analyze_call, ParamKind},
|
||||
analysis::{ParamKind, analyze_call},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ impl InlayHintWorker<'_> {
|
|||
ParamKind::Positional
|
||||
if call_info.signature.primary().has_fill_or_size_or_stroke =>
|
||||
{
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
ParamKind::Positional
|
||||
if !SMART.on_pos_args
|
||||
|
|
@ -224,7 +224,7 @@ impl InlayHintWorker<'_> {
|
|||
|| disable_by_single_line_content_block))
|
||||
|| (!info.is_content_block && disable_by_single_pos_arg) =>
|
||||
{
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
ParamKind::Rest
|
||||
if (!SMART.on_variadic_args
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ use tinymist_project::LspWorld;
|
|||
use tinymist_std::typst::TypstDocument;
|
||||
use tinymist_world::debug_loc::SourceSpanOffset;
|
||||
use typst::{
|
||||
World,
|
||||
layout::{Frame, FrameItem, Point, Position, Size},
|
||||
syntax::{LinkedNode, Source, Span, SyntaxKind},
|
||||
visualize::Geometry,
|
||||
World,
|
||||
};
|
||||
use typst_shim::syntax::LinkedNodeExt;
|
||||
|
||||
|
|
@ -31,7 +31,8 @@ pub fn jump_from_click(
|
|||
}
|
||||
|
||||
// If there's no link, search for a jump target.
|
||||
for (mut pos, item) in frame.items().rev() {
|
||||
for (pos, item) in frame.items().rev() {
|
||||
let mut pos = *pos;
|
||||
match item {
|
||||
FrameItem::Group(group) => {
|
||||
// TODO: Handle transformation.
|
||||
|
|
@ -168,7 +169,8 @@ fn jump_from_cursor_(
|
|||
|
||||
/// Finds the position of a span in a frame.
|
||||
fn find_in_frame(frame: &Frame, span: Span, min_dis: &mut u64, res: &mut Point) -> Option<Point> {
|
||||
for (mut pos, item) in frame.items() {
|
||||
for (pos, item) in frame.items() {
|
||||
let mut pos = *pos;
|
||||
if let FrameItem::Group(group) = item {
|
||||
// TODO: Handle transformation.
|
||||
if let Some(point) = find_in_frame(&group.frame, span, min_dis, res) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use typst_shim::syntax::LinkedNodeExt;
|
||||
|
||||
use crate::{prelude::*, syntax::node_ancestors, SyntaxRequest};
|
||||
use crate::{SyntaxRequest, prelude::*, syntax::node_ancestors};
|
||||
|
||||
/// The [`experimental/onEnter`] request is sent from client to server to handle
|
||||
/// the <kbd>Enter</kbd> key press.
|
||||
|
|
@ -69,7 +69,7 @@ impl SyntaxRequest for OnEnterRequest {
|
|||
|
||||
match prev_leaf.kind() {
|
||||
SyntaxKind::ListItem | SyntaxKind::EnumItem => {
|
||||
return Some(Cases::ListOrEnum(prev_leaf))
|
||||
return Some(Cases::ListOrEnum(prev_leaf));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ use ecow::eco_format;
|
|||
// use reflexo_typst::typst::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tinymist_world::package::PackageSpec;
|
||||
use typst::World;
|
||||
use typst::diag::{EcoString, StrResult};
|
||||
use typst::syntax::package::PackageManifest;
|
||||
use typst::syntax::{FileId, VirtualPath};
|
||||
use typst::World;
|
||||
|
||||
use crate::LocalContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,37 +4,37 @@ pub use std::ops::Range;
|
|||
pub use std::path::{Path, PathBuf};
|
||||
pub use std::sync::{Arc, LazyLock, OnceLock};
|
||||
|
||||
pub use ecow::{eco_vec, EcoVec};
|
||||
pub use ecow::{EcoVec, eco_vec};
|
||||
pub use itertools::Itertools;
|
||||
pub use lsp_types::{
|
||||
request::GotoDeclarationResponse, CodeActionKind, CodeLens, ColorInformation,
|
||||
ColorPresentation, Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity,
|
||||
DocumentHighlight, DocumentLink, DocumentSymbol, DocumentSymbolResponse, Documentation,
|
||||
FoldingRange, GotoDefinitionResponse, Hover, HoverContents, InlayHint, Location as LspLocation,
|
||||
LocationLink, MarkedString, MarkupContent, MarkupKind, ParameterInformation,
|
||||
Position as LspPosition, PrepareRenameResponse, SelectionRange, SemanticTokens,
|
||||
SemanticTokensDelta, SemanticTokensFullDeltaResult, SemanticTokensResult, SignatureHelp,
|
||||
SignatureInformation, SymbolInformation, TextEdit, Url, WorkspaceEdit,
|
||||
CodeActionKind, CodeLens, ColorInformation, ColorPresentation, Diagnostic,
|
||||
DiagnosticRelatedInformation, DiagnosticSeverity, DocumentHighlight, DocumentLink,
|
||||
DocumentSymbol, DocumentSymbolResponse, Documentation, FoldingRange, GotoDefinitionResponse,
|
||||
Hover, HoverContents, InlayHint, Location as LspLocation, LocationLink, MarkedString,
|
||||
MarkupContent, MarkupKind, ParameterInformation, Position as LspPosition,
|
||||
PrepareRenameResponse, SelectionRange, SemanticTokens, SemanticTokensDelta,
|
||||
SemanticTokensFullDeltaResult, SemanticTokensResult, SignatureHelp, SignatureInformation,
|
||||
SymbolInformation, TextEdit, Url, WorkspaceEdit, request::GotoDeclarationResponse,
|
||||
};
|
||||
pub use serde_json::Value as JsonValue;
|
||||
pub use tinymist_project::LspComputeGraph;
|
||||
pub use tinymist_std::DefId;
|
||||
pub use typst::World;
|
||||
pub use typst::diag::{EcoString, Tracepoint};
|
||||
pub use typst::foundations::Value;
|
||||
pub use typst::syntax::ast::{self, AstNode};
|
||||
pub use typst::syntax::{
|
||||
FileId as TypstFileId, LinkedNode, Source, Spanned, SyntaxKind, SyntaxNode,
|
||||
};
|
||||
pub use typst::World;
|
||||
pub use typst_shim::syntax::LinkedNodeExt;
|
||||
|
||||
pub use crate::analysis::{Definition, LocalContext};
|
||||
pub use crate::code_action::proto::*;
|
||||
pub use crate::docs::DefDocs;
|
||||
pub use crate::lsp_typst_boundary::{
|
||||
path_to_url, to_lsp_position, to_lsp_range, to_typst_position, to_typst_range, LspRange,
|
||||
PositionEncoding,
|
||||
LspRange, PositionEncoding, path_to_url, to_lsp_position, to_lsp_range, to_typst_position,
|
||||
to_typst_range,
|
||||
};
|
||||
pub use crate::syntax::{classify_syntax, Decl, DefKind};
|
||||
pub use crate::syntax::{Decl, DefKind, classify_syntax};
|
||||
pub(crate) use crate::ty::PathPreference;
|
||||
pub use crate::{SemanticRequest, StatefulRequest};
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ use tinymist_std::typst::TypstDocument;
|
|||
use typst::syntax::Span;
|
||||
|
||||
use crate::{
|
||||
StrRef,
|
||||
analysis::{Definition, SearchCtx},
|
||||
prelude::*,
|
||||
syntax::{get_index_info, RefExpr, SyntaxClass},
|
||||
StrRef,
|
||||
syntax::{RefExpr, SyntaxClass, get_index_info},
|
||||
};
|
||||
|
||||
/// The [`textDocument/references`] request is sent from the client to the
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use lsp_types::{
|
|||
OptionalVersionedTextDocumentIdentifier, RenameFile, TextDocumentEdit,
|
||||
};
|
||||
use rustc_hash::FxHashSet;
|
||||
use tinymist_std::path::{unix_slash, PathClean};
|
||||
use tinymist_std::path::{PathClean, unix_slash};
|
||||
use typst::{
|
||||
foundations::{Repr, Str},
|
||||
syntax::Span,
|
||||
|
|
@ -11,11 +11,11 @@ use typst::{
|
|||
|
||||
use crate::adt::interner::Interned;
|
||||
use crate::{
|
||||
analysis::{get_link_exprs, LinkObject, LinkTarget},
|
||||
analysis::{LinkObject, LinkTarget, get_link_exprs},
|
||||
find_references,
|
||||
prelude::*,
|
||||
prepare_renaming,
|
||||
syntax::{first_ancestor_expr, get_index_info, node_ancestors, Decl, RefExpr, SyntaxClass},
|
||||
syntax::{Decl, RefExpr, SyntaxClass, first_ancestor_expr, get_index_info, node_ancestors},
|
||||
};
|
||||
|
||||
/// The [`textDocument/rename`] request is sent from the client to the server to
|
||||
|
|
@ -64,7 +64,9 @@ impl StatefulRequest for RenameRequest {
|
|||
let rename_loc = Path::new(ref_path_str.as_str());
|
||||
let diff = tinymist_std::path::diff(new_path, rename_loc)?;
|
||||
if diff.is_absolute() {
|
||||
log::info!("bad rename: absolute path, base: {rename_loc:?}, new: {new_path:?}, diff: {diff:?}");
|
||||
log::info!(
|
||||
"bad rename: absolute path, base: {rename_loc:?}, new: {new_path:?}, diff: {diff:?}"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use typst_shim::syntax::LinkedNodeExt;
|
||||
|
||||
use crate::{prelude::*, SyntaxRequest};
|
||||
use crate::{SyntaxRequest, prelude::*};
|
||||
|
||||
/// The [`textDocument/selectionRange`] request is sent from the client to the
|
||||
/// server to return suggested selection ranges at an array of given positions.
|
||||
|
|
|
|||
|
|
@ -111,7 +111,9 @@ mod tests {
|
|||
);
|
||||
} else if prev_line_number == line_number && prev_end_character > start_character {
|
||||
// this token overlaps with the previous token
|
||||
panic!("Overlapping semantic tokens at line {line_number}, character {start_character}, previous line {prev_line_number}, previous end {prev_end_character}");
|
||||
panic!(
|
||||
"Overlapping semantic tokens at line {line_number}, character {start_character}, previous line {prev_line_number}, previous end {prev_end_character}"
|
||||
);
|
||||
} else {
|
||||
prev_line_number = line_number;
|
||||
prev_end_character = end_character;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use typst_shim::syntax::LinkedNodeExt;
|
||||
|
||||
use crate::{
|
||||
SemanticRequest,
|
||||
adt::interner::Interned,
|
||||
prelude::*,
|
||||
syntax::{classify_context, classify_syntax, ArgClass, SyntaxContext},
|
||||
SemanticRequest,
|
||||
syntax::{ArgClass, SyntaxContext, classify_context, classify_syntax},
|
||||
};
|
||||
|
||||
/// The [`textDocument/signatureHelp`] request is sent from the client to the
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
prelude::*,
|
||||
syntax::{get_lexical_hierarchy, LexicalHierarchy, LexicalScopeKind},
|
||||
SemanticRequest,
|
||||
prelude::*,
|
||||
syntax::{LexicalHierarchy, LexicalScopeKind, get_lexical_hierarchy},
|
||||
};
|
||||
|
||||
/// The [`workspace/symbol`] request is sent from the client to the server to
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use std::{collections::BTreeMap, ops::Deref, sync::LazyLock};
|
|||
use ecow::eco_format;
|
||||
use typst::foundations::{IntoValue, Module, Str, Type};
|
||||
|
||||
use crate::{adt::interner::Interned, StrRef};
|
||||
use crate::{StrRef, adt::interner::Interned};
|
||||
use crate::{adt::snapshot_map::SnapshotMap, analysis::SharedContext};
|
||||
use crate::{
|
||||
docs::{convert_docs, identify_pat_docs, identify_tidy_module_docs, DocString, VarDoc},
|
||||
docs::{DocString, VarDoc, convert_docs, identify_pat_docs, identify_tidy_module_docs},
|
||||
prelude::*,
|
||||
syntax::{Decl, DefKind},
|
||||
ty::{BuiltinTy, DynTypeBounds, InsTy, PackageId, SigTy, Ty, TypeVar, TypeVarBounds},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use tinymist_std::hash::hash128;
|
|||
use typst::{
|
||||
foundations::{Element, NativeElement, Type, Value},
|
||||
model::{EmphElem, EnumElem, HeadingElem, ListElem, ParbreakElem, StrongElem, TermsElem},
|
||||
syntax::{ast::MathTextKind, Span, SyntaxNode},
|
||||
syntax::{Span, SyntaxNode, ast::MathTextKind},
|
||||
text::LinebreakElem,
|
||||
utils::LazyHash,
|
||||
};
|
||||
|
|
@ -20,11 +20,11 @@ use crate::{
|
|||
analysis::{QueryStatGuard, SharedContext},
|
||||
docs::DocString,
|
||||
prelude::*,
|
||||
syntax::{find_module_level_docs, resolve_id_by_path, DefKind},
|
||||
syntax::{DefKind, find_module_level_docs, resolve_id_by_path},
|
||||
ty::{BuiltinTy, InsTy, Ty},
|
||||
};
|
||||
|
||||
use super::{def::*, DocCommentMatcher, InterpretMode};
|
||||
use super::{DocCommentMatcher, InterpretMode, def::*};
|
||||
|
||||
pub type ExprRoute = FxHashMap<TypstFileId, Option<Arc<LazyHash<LexicalScope>>>>;
|
||||
|
||||
|
|
@ -672,7 +672,7 @@ impl ExprWorker<'_> {
|
|||
self.check_import_source_val(source, &val.val, Some(&src_expr), is_import)
|
||||
}
|
||||
Expr::Decl(decl) if matches!(decl.as_ref(), Decl::Module { .. }) => {
|
||||
return Some(src_expr.clone())
|
||||
return Some(src_expr.clone());
|
||||
}
|
||||
|
||||
_ => None,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use std::ops::{Deref, Range};
|
||||
|
||||
use ecow::{eco_vec, EcoString, EcoVec};
|
||||
use ecow::{EcoString, EcoVec, eco_vec};
|
||||
use lsp_types::SymbolKind;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typst::syntax::{
|
||||
ast::{self},
|
||||
LinkedNode, Source, SyntaxKind,
|
||||
ast::{self},
|
||||
};
|
||||
use typst_shim::utils::LazyHash;
|
||||
|
||||
use super::{is_mark, CommentGroupMatcher};
|
||||
use super::{CommentGroupMatcher, is_mark};
|
||||
|
||||
#[typst_macros::time(span = source.root().span())]
|
||||
pub(crate) fn get_lexical_hierarchy(
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ use tinymist_std::error::prelude::*;
|
|||
use tinymist_std::typst::TypstDocument;
|
||||
use tinymist_world::vfs::FileId;
|
||||
use typst::{
|
||||
World,
|
||||
foundations::{Func, Label, Module, Selector, Value},
|
||||
introspection::MetadataElem,
|
||||
syntax::Source,
|
||||
utils::PicoStr,
|
||||
World,
|
||||
};
|
||||
|
||||
use crate::LocalContext;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::{
|
|||
};
|
||||
|
||||
use regex::{Regex, Replacer};
|
||||
use serde_json::{ser::PrettyFormatter, Serializer, Value};
|
||||
use serde_json::{Serializer, Value, ser::PrettyFormatter};
|
||||
use tinymist_project::{LspCompileSnapshot, LspComputeGraph};
|
||||
use tinymist_std::path::unix_slash;
|
||||
use tinymist_std::typst::TypstDocument;
|
||||
|
|
@ -28,8 +28,8 @@ pub use tinymist_tests::{assert_snapshot, run_with_sources, with_settings};
|
|||
pub use tinymist_world::WorldComputeGraph;
|
||||
|
||||
pub use crate::syntax::find_module_level_docs;
|
||||
use crate::{analysis::Analysis, prelude::LocalContext, LspPosition, PositionEncoding};
|
||||
use crate::{to_lsp_position, to_typst_position, CompletionFeat};
|
||||
use crate::{CompletionFeat, to_lsp_position, to_typst_position};
|
||||
use crate::{LspPosition, PositionEncoding, analysis::Analysis, prelude::LocalContext};
|
||||
|
||||
pub fn snapshot_testing(name: &str, f: &impl Fn(&mut LocalContext, PathBuf)) {
|
||||
tinymist_tests::snapshot_testing!(name, |verse, path| {
|
||||
|
|
@ -338,9 +338,10 @@ impl JsonRepr {
|
|||
LazyLock::new(|| Regex::new(r#"data:image/svg\+xml;base64,([^"]+)"#).unwrap());
|
||||
static REG2: LazyLock<Regex> =
|
||||
LazyLock::new(|| Regex::new(r#"C:\\?\\dummy-root\\?\\"#).unwrap());
|
||||
let v = REG.replace_all(v, |_captures: ®ex::Captures| {
|
||||
"data:image-hash/svg+xml;base64,redacted"
|
||||
});
|
||||
let v = REG.replace_all(
|
||||
v,
|
||||
|_captures: ®ex::Captures| "data:image-hash/svg+xml;base64,redacted",
|
||||
);
|
||||
REG2.replace_all_cow(v, "/dummy-root/")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use crate::{
|
||||
SemanticRequest,
|
||||
prelude::*,
|
||||
syntax::{
|
||||
get_lexical_hierarchy, LexicalHierarchy, LexicalKind, LexicalScopeKind, LexicalVarKind,
|
||||
LexicalHierarchy, LexicalKind, LexicalScopeKind, LexicalVarKind, get_lexical_hierarchy,
|
||||
},
|
||||
SemanticRequest,
|
||||
};
|
||||
|
||||
/// The `workspace/label` request resembles [`workspace/symbol`] request but is
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ description = "Additional functions wrapping Rust's standard library."
|
|||
version = "0.13.16"
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
edition = "2024"
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ use ecow::EcoString;
|
|||
use tinymist_std::error::prelude::*;
|
||||
use tinymist_std::typst::{TypstDocument, TypstHtmlDocument, TypstPagedDocument};
|
||||
use tinymist_world::{CompileSnapshot, CompilerFeat, ExportComputation, WorldComputeGraph};
|
||||
use typst::World;
|
||||
use typst::diag::{SourceResult, StrResult};
|
||||
use typst::foundations::{Bytes, Content, IntoValue, LocatableSelector, Scope, Value};
|
||||
use typst::layout::Abs;
|
||||
use typst::routines::EvalMode;
|
||||
use typst::syntax::{ast, Span, SyntaxNode};
|
||||
use typst::syntax::{Span, SyntaxNode, ast};
|
||||
use typst::visualize::Color;
|
||||
use typst::World;
|
||||
use typst_eval::eval_string;
|
||||
|
||||
use crate::model::{ExportHtmlTask, ExportPngTask, ExportSvgTask};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use tinymist_std::time::ToUtcDateTime;
|
||||
pub use typst_pdf::pdf;
|
||||
pub use typst_pdf::PdfStandard as TypstPdfStandard;
|
||||
pub use typst_pdf::pdf;
|
||||
|
||||
use typst_pdf::{PdfOptions, PdfStandards, Timestamp};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use core::fmt;
|
||||
use std::sync::Arc;
|
||||
use typst::html::{tag, HtmlNode::*};
|
||||
use typst::html::{HtmlNode::*, tag};
|
||||
|
||||
use crate::ExportTextTask;
|
||||
use tinymist_std::error::prelude::*;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ use std::path::PathBuf;
|
|||
use std::{path::Path, str::FromStr};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tinymist_std::error::prelude::*;
|
||||
use tinymist_std::path::{unix_slash, PathClean};
|
||||
use tinymist_std::ImmutPath;
|
||||
use tinymist_std::error::prelude::*;
|
||||
use tinymist_std::path::{PathClean, unix_slash};
|
||||
use tinymist_world::vfs::WorkspaceResolver;
|
||||
use tinymist_world::{CompilerFeat, CompilerWorld, EntryReader, EntryState};
|
||||
use typst::diag::EcoString;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ use std::{
|
|||
};
|
||||
|
||||
use tinymist_project::{
|
||||
base::ShadowApi, font::FontResolverImpl, vfs::system::SystemAccessModel, CompileFontArgs,
|
||||
DynAccessModel, EntryManager, EntryState, ExportTarget, LspUniverse, LspUniverseBuilder,
|
||||
CompileFontArgs, DynAccessModel, EntryManager, EntryState, ExportTarget, LspUniverse,
|
||||
LspUniverseBuilder, base::ShadowApi, font::FontResolverImpl, vfs::system::SystemAccessModel,
|
||||
};
|
||||
use typst::{foundations::Bytes, syntax::VirtualPath};
|
||||
|
||||
pub use insta::{assert_debug_snapshot, assert_snapshot, glob, with_settings, Settings};
|
||||
pub use insta::{Settings, assert_debug_snapshot, assert_snapshot, glob, with_settings};
|
||||
|
||||
/// Runs snapshot tests.
|
||||
#[macro_export]
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ use crate::notify::NotifyAccessModel;
|
|||
use crate::overlay::OverlayAccessModel;
|
||||
use crate::resolve::ResolveAccessModel;
|
||||
|
||||
pub use tinymist_std::time::Time;
|
||||
pub use tinymist_std::ImmutPath;
|
||||
pub use tinymist_std::time::Time;
|
||||
pub use typst::foundations::Bytes;
|
||||
pub use typst::syntax::FileId;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ use std::path::{Path, PathBuf};
|
|||
use std::sync::LazyLock;
|
||||
|
||||
use parking_lot::RwLock;
|
||||
use tinymist_std::path::PathClean;
|
||||
use tinymist_std::ImmutPath;
|
||||
use typst::diag::{eco_format, EcoString, FileError, FileResult};
|
||||
use typst::syntax::package::{PackageSpec, PackageVersion};
|
||||
use tinymist_std::path::PathClean;
|
||||
use typst::diag::{EcoString, FileError, FileResult, eco_format};
|
||||
use typst::syntax::VirtualPath;
|
||||
use typst::syntax::package::{PackageSpec, PackageVersion};
|
||||
|
||||
use super::FileId;
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ pub trait RootResolver {
|
|||
self.resolve_package_root(file_id.package().expect("not a file in package"))?
|
||||
}
|
||||
UntitledRooted(..) | Rootless => {
|
||||
return Ok(PathResolution::Rootless(Cow::Borrowed(file_id.vpath())))
|
||||
return Ok(PathResolution::Rootless(Cow::Borrowed(file_id.vpath())));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::{fmt::Debug, sync::Arc};
|
|||
use tinymist_std::ImmutPath;
|
||||
use typst::diag::FileResult;
|
||||
|
||||
use crate::{path_mapper::RootResolver, AccessModel, Bytes, FileId, PathAccessModel};
|
||||
use crate::{AccessModel, Bytes, FileId, PathAccessModel, path_mapper::RootResolver};
|
||||
|
||||
/// Provides resolve access model.
|
||||
#[derive(Clone)]
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ impl LazyFile {
|
|||
|
||||
impl ReadAllOnce for LazyFile {
|
||||
fn read_all(mut self, buf: &mut Vec<u8>) -> std::io::Result<usize> {
|
||||
let file = self.file.get_or_insert_with(|| File::open(&self.path));
|
||||
let Ok(ref mut file) = file else {
|
||||
let mut file = self.file.get_or_insert_with(|| File::open(&self.path));
|
||||
let Ok(file) = &mut file else {
|
||||
let err = file.as_ref().unwrap_err();
|
||||
// todo: clone error or hide error
|
||||
return Err(std::io::Error::new(err.kind(), err.to_string()));
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue