mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
dev: move package to reflexo_world part (#1177)
* dev: move package to reflexo_world part fix: compile error * dev: update the package.json * fix: compile error * dev: remove dry compile
This commit is contained in:
parent
448ce484d8
commit
5659b0bc6c
17 changed files with 115 additions and 405 deletions
|
@ -2,7 +2,8 @@ use std::sync::{Arc, LazyLock};
|
|||
|
||||
use ecow::{eco_format, EcoString};
|
||||
use parking_lot::Mutex;
|
||||
use tinymist_world::base::{EntryState, ShadowApi, TaskInputs};
|
||||
use tinymist_world::base::{EntryState, ShadowApi};
|
||||
use tinymist_world::TaskInputs;
|
||||
use typlite::scopes::Scopes;
|
||||
use typlite::value::Value;
|
||||
use typlite::TypliteFeat;
|
||||
|
|
|
@ -8,7 +8,7 @@ use parking_lot::Mutex;
|
|||
use reflexo_typst::typst::prelude::*;
|
||||
use reflexo_typst::{package::PackageSpec, TypstFileId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tinymist_world::package::HttpsRegistry;
|
||||
use tinymist_world::package::http::HttpRegistry;
|
||||
use typst::diag::{EcoString, StrResult};
|
||||
use typst::syntax::package::PackageManifest;
|
||||
use typst::syntax::VirtualPath;
|
||||
|
@ -78,7 +78,7 @@ pub fn check_package(ctx: &mut LocalContext, spec: &PackageInfo) -> StrResult<()
|
|||
|
||||
/// Get the packages in namespaces and their descriptions.
|
||||
pub fn list_package_by_namespace(
|
||||
registry: &HttpsRegistry,
|
||||
registry: &HttpRegistry,
|
||||
ns: EcoString,
|
||||
) -> EcoVec<(PathBuf, PackageSpec)> {
|
||||
// search packages locally. We only search in the data
|
||||
|
|
|
@ -11,9 +11,10 @@ use std::{
|
|||
use once_cell::sync::Lazy;
|
||||
use reflexo_typst::package::PackageSpec;
|
||||
use reflexo_typst::world::EntryState;
|
||||
use reflexo_typst::{CompileDriverImpl, EntryManager, EntryReader, ShadowApi, TaskInputs};
|
||||
use reflexo_typst::{Compiler, EntryManager, EntryReader, ShadowApi};
|
||||
use serde_json::{ser::PrettyFormatter, Serializer, Value};
|
||||
use tinymist_world::CompileFontArgs;
|
||||
use tinymist_world::TaskInputs;
|
||||
use typst::foundations::Bytes;
|
||||
use typst::syntax::ast::{self, AstNode};
|
||||
use typst::syntax::{FileId as TypstFileId, LinkedNode, Source, SyntaxKind, VirtualPath};
|
||||
|
@ -31,8 +32,6 @@ use crate::{
|
|||
};
|
||||
use crate::{to_lsp_position, CompletionFeat, LspWorldExt};
|
||||
|
||||
type CompileDriver<C> = CompileDriverImpl<C, tinymist_world::LspCompilerFeat>;
|
||||
|
||||
pub fn snapshot_testing(name: &str, f: &impl Fn(&mut LocalContext, PathBuf)) {
|
||||
let name = if name.is_empty() { "playground" } else { name };
|
||||
|
||||
|
@ -147,7 +146,7 @@ pub fn run_with_sources<T>(source: &str, f: impl FnOnce(&mut LspUniverse, PathBu
|
|||
} else {
|
||||
PathBuf::from("/")
|
||||
};
|
||||
let mut world = LspUniverseBuilder::build(
|
||||
let mut verse = LspUniverseBuilder::build(
|
||||
EntryState::new_rooted(root.as_path().into(), None),
|
||||
Default::default(),
|
||||
Arc::new(
|
||||
|
@ -181,19 +180,18 @@ pub fn run_with_sources<T>(source: &str, f: impl FnOnce(&mut LspUniverse, PathBu
|
|||
let path = path.unwrap_or_else(|| format!("/s{idx}.typ"));
|
||||
|
||||
let pw = root.join(Path::new(&path));
|
||||
world
|
||||
verse
|
||||
.map_shadow(&pw, Bytes::from(source.as_bytes()))
|
||||
.unwrap();
|
||||
last_pw = Some(pw);
|
||||
}
|
||||
|
||||
world.mutate_entry(EntryState::new_detached()).unwrap();
|
||||
let mut driver = CompileDriver::new(std::marker::PhantomData, world);
|
||||
let _ = driver.compile(&mut Default::default());
|
||||
verse.mutate_entry(EntryState::new_detached()).unwrap();
|
||||
let world = verse.snapshot();
|
||||
let _ = std::marker::PhantomData.compile(&world, &mut Default::default());
|
||||
|
||||
let pw = last_pw.unwrap();
|
||||
driver
|
||||
.universe_mut()
|
||||
verse
|
||||
.mutate_entry(EntryState::new_rooted(
|
||||
root.as_path().into(),
|
||||
Some(TypstFileId::new(
|
||||
|
@ -202,7 +200,7 @@ pub fn run_with_sources<T>(source: &str, f: impl FnOnce(&mut LspUniverse, PathBu
|
|||
)),
|
||||
))
|
||||
.unwrap();
|
||||
f(driver.universe_mut(), pw)
|
||||
f(&mut verse, pw)
|
||||
}
|
||||
|
||||
pub fn find_test_range(s: &Source) -> Range<usize> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue