test the wasm side (#6726)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use std::{fmt, path::PathBuf};
|
||||
use std::fmt;
|
||||
|
||||
use anyhow::Result;
|
||||
use schemars::JsonSchema;
|
||||
@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
exec::KclValue,
|
||||
execution::{EnvironmentRef, PreImportedGeometry},
|
||||
execution::{typed_path::TypedPath, EnvironmentRef, PreImportedGeometry},
|
||||
fs::{FileManager, FileSystem},
|
||||
parsing::ast::types::{ImportPath, Node, Program},
|
||||
source_range::SourceRange,
|
||||
@ -46,7 +46,7 @@ impl std::fmt::Display for ModuleId {
|
||||
pub(crate) struct ModuleLoader {
|
||||
/// The stack of import statements for detecting circular module imports.
|
||||
/// If this is empty, we're not currently executing an import statement.
|
||||
pub import_stack: Vec<PathBuf>,
|
||||
pub import_stack: Vec<TypedPath>,
|
||||
}
|
||||
|
||||
impl ModuleLoader {
|
||||
@ -63,7 +63,7 @@ impl ModuleLoader {
|
||||
"circular import of modules is not allowed: {} -> {}",
|
||||
self.import_stack
|
||||
.iter()
|
||||
.map(|p| p.as_path().to_string_lossy())
|
||||
.map(|p| p.to_string_lossy())
|
||||
.collect::<Vec<_>>()
|
||||
.join(" -> "),
|
||||
path,
|
||||
@ -140,12 +140,12 @@ pub enum ModuleRepr {
|
||||
pub enum ModulePath {
|
||||
// The main file of the project.
|
||||
Main,
|
||||
Local { value: PathBuf },
|
||||
Local { value: TypedPath },
|
||||
Std { value: String },
|
||||
}
|
||||
|
||||
impl ModulePath {
|
||||
pub(crate) fn expect_path(&self) -> &PathBuf {
|
||||
pub(crate) fn expect_path(&self) -> &TypedPath {
|
||||
match self {
|
||||
ModulePath::Local { value: p } => p,
|
||||
_ => unreachable!(),
|
||||
@ -180,13 +180,13 @@ impl ModulePath {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn from_import_path(path: &ImportPath, project_directory: &Option<PathBuf>) -> Self {
|
||||
pub(crate) fn from_import_path(path: &ImportPath, project_directory: &Option<TypedPath>) -> Self {
|
||||
match path {
|
||||
ImportPath::Kcl { filename: path } | ImportPath::Foreign { path } => {
|
||||
let resolved_path = if let Some(project_dir) = project_directory {
|
||||
project_dir.join(path)
|
||||
} else {
|
||||
std::path::PathBuf::from(path)
|
||||
TypedPath::from(path)
|
||||
};
|
||||
ModulePath::Local { value: resolved_path }
|
||||
}
|
||||
@ -205,7 +205,7 @@ impl fmt::Display for ModulePath {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ModulePath::Main => write!(f, "main"),
|
||||
ModulePath::Local { value: path } => path.display().fmt(f),
|
||||
ModulePath::Local { value: path } => path.fmt(f),
|
||||
ModulePath::Std { value: s } => write!(f, "std::{s}"),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user