Skip to content

Commit f28fd37

Browse files
author
Grant Wuerker
committed
fe check WIP
1 parent 21e43b8 commit f28fd37

File tree

10 files changed

+3375
-194
lines changed

10 files changed

+3375
-194
lines changed

Cargo.lock

Lines changed: 3140 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ tracing = "0.1.41"
3434
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
3535
tracing-tree = "0.4.0"
3636
wasm-bindgen-test = "0.3"
37+
semver = "1.0.26"
3738

3839
[profile.dev]
3940
# Set to 0 to make the build faster and debugging more difficult.

crates/common/src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ use camino::Utf8PathBuf;
22
use smol_str::SmolStr;
33
use toml::Value;
44

5-
use crate::input::Version;
5+
use crate::ingot::Version;
66

77
#[derive(Debug, Clone)]
88
pub struct Config {
9-
pub ingot: Ingot,
9+
pub ingot: IngotMetadata,
1010
pub dependencies: Vec<Dependency>,
1111
pub diagnostics: Vec<ConfigDiagnostics>,
1212
}
1313

1414
impl Config {
1515
pub fn from_string(content: String) -> Self {
1616
let mut diagnostics = Vec::new();
17-
let mut ingot = Ingot::default();
17+
let mut ingot = IngotMetadata::default();
1818
let mut dependencies = Vec::new();
1919

2020
let parsed: Value = match content.parse() {
@@ -96,7 +96,7 @@ impl Config {
9696
}
9797

9898
#[derive(Debug, Default, Clone)]
99-
pub struct Ingot {
99+
pub struct IngotMetadata {
100100
pub name: Option<SmolStr>,
101101
pub version: Option<Version>,
102102
}

crates/common/src/file/workspace.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ impl Workspace {
2323
pub fn default(db: &dyn InputDb) -> Self {
2424
Workspace::new(db, Trie::new(), IndexMap::new())
2525
}
26-
pub(crate) fn set(
27-
&self,
28-
db: &mut dyn InputDb,
29-
url: Url,
30-
file: File,
31-
) -> Result<File, InputIndexError> {
26+
pub fn set(&self, db: &mut dyn InputDb, url: Url, file: File) -> Result<File, InputIndexError> {
3227
// Check if the file is already associated with another URL
3328
let paths = self.paths(db);
3429
if let Some(existing_url) = paths.get(&file) {

crates/common/src/ingot.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use camino::Utf8PathBuf;
22
use radix_immutable::StringPrefixView;
3-
use serde::Serialize;
43
use url::Url;
54

6-
use crate::config::IngotMetadata;
7-
// use crate::config::IngotManifest;
5+
use crate::config::{Config, IngotMetadata};
86
use crate::core::BUILTIN_CORE_BASE_URL;
97
use crate::file::{File, Workspace};
108
use crate::urlext::UrlExt;
@@ -106,12 +104,7 @@ pub trait IngotIndex {
106104
fn containing_ingot_base(&self, db: &dyn InputDb, location: &Url) -> Option<Url>;
107105
fn containing_ingot_config(self, db: &dyn InputDb, location: Url) -> Option<File>;
108106
fn containing_ingot<'db>(self, db: &'db dyn InputDb, location: &Url) -> Option<Ingot<'db>>;
109-
fn touch_ingot<'db>(
110-
self,
111-
db: &'db mut dyn InputDb,
112-
base_url: &Url,
113-
initial_config: IngotMetadata,
114-
) -> Option<Ingot<'db>>;
107+
fn touch_ingot<'db>(self, db: &'db mut dyn InputDb, base_url: &Url) -> Option<Ingot<'db>>;
115108
}
116109

117110
pub type Version = serde_semver::semver::Version;
@@ -168,33 +161,19 @@ impl IngotIndex for Workspace {
168161
containing_ingot_impl(db, self, location.clone())
169162
}
170163

171-
fn touch_ingot<'db>(
172-
self,
173-
db: &'db mut dyn InputDb,
174-
base_url: &Url,
175-
config: IngotMetadata,
176-
) -> Option<Ingot<'db>> {
164+
fn touch_ingot<'db>(self, db: &'db mut dyn InputDb, base_url: &Url) -> Option<Ingot<'db>> {
177165
let base_dir = base_url
178166
.directory()
179167
.expect("Base URL should have a directory");
180168
let config_file = base_dir
181169
.join("fe.toml")
182170
.expect("Config file should be indexed");
183-
// Wrap the config in a proper IngotConfig wrapper for serialization
184-
let ingot_config = IngotConfig { ingot: config };
185-
let config_toml = toml::to_string(&ingot_config).unwrap_or_default();
186-
let config = self.touch(db, config_file, Some(config_toml));
171+
let config = self.touch(db, config_file, None);
187172

188173
config.containing_ingot(db)
189174
}
190175
}
191176

192-
/// A wrapper struct to ensure the config is serialized with an [ingot] table
193-
#[derive(Serialize)]
194-
struct IngotConfig {
195-
ingot: IngotMetadata,
196-
}
197-
198177
#[salsa::tracked]
199178
fn containing_ingot_impl<'db>(
200179
db: &'db dyn InputDb,

0 commit comments

Comments
 (0)