Skip to content

Commit 805bc7d

Browse files
author
Grant Wuerker
committed
cleanup
1 parent c9e8419 commit 805bc7d

File tree

7 files changed

+45
-168
lines changed

7 files changed

+45
-168
lines changed

crates/common/src/config.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl Config {
6464
Value::Table(table) => {
6565
let path = table.get("path").and_then(|value| value.as_str());
6666
if let Some(path) = path {
67-
let mut parameters = DependencyParameters::default();
67+
let mut parameters = DependencyArguments::default();
6868
if let Some(name) = table.get("name").and_then(|value| value.as_str()) {
6969
parameters.name = Some(SmolStr::new(name));
7070
}
@@ -139,7 +139,7 @@ pub enum DependencyDescription {
139139
Path(Utf8PathBuf),
140140
PathWithParameters {
141141
path: Utf8PathBuf,
142-
parameters: DependencyParameters,
142+
parameters: DependencyArguments,
143143
},
144144
}
145145

@@ -160,7 +160,7 @@ impl Dependency {
160160
pub fn path_with_arguments(
161161
alias: SmolStr,
162162
path: Utf8PathBuf,
163-
parameters: DependencyParameters,
163+
parameters: DependencyArguments,
164164
) -> Self {
165165
Self {
166166
alias,
@@ -172,15 +172,15 @@ impl Dependency {
172172
match &self.description {
173173
DependencyDescription::Path(path) => BasedDependency {
174174
alias: self.alias.clone(),
175-
parameters: DependencyParameters::default(),
175+
parameters: DependencyArguments::default(),
176176
url: base_url.join_directory(path).unwrap(),
177177
},
178178
DependencyDescription::PathWithParameters {
179179
path,
180180
parameters: _,
181181
} => BasedDependency {
182182
alias: self.alias.clone(),
183-
parameters: DependencyParameters::default(),
183+
parameters: DependencyArguments::default(),
184184
url: base_url.join_directory(path).unwrap(),
185185
},
186186
}
@@ -190,12 +190,12 @@ impl Dependency {
190190
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
191191
pub struct BasedDependency {
192192
pub alias: SmolStr,
193-
pub parameters: DependencyParameters,
193+
pub parameters: DependencyArguments,
194194
pub url: Url,
195195
}
196196

197197
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
198-
pub struct DependencyParameters {
198+
pub struct DependencyArguments {
199199
pub name: Option<SmolStr>,
200200
pub version: Option<Version>,
201201
}

crates/common/src/file/workspace.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use salsa::Setter;
55
use smol_str::SmolStr;
66
use url::Url;
77

8-
use crate::config::IngotArguments;
8+
use crate::config::DependencyArguments;
99
use crate::InputDb;
1010
use crate::{file::File, indexmap::IndexMap};
1111

@@ -19,7 +19,7 @@ pub enum InputIndexError {
1919
pub struct Workspace {
2020
files: StringTrie<Url, File>,
2121
paths: IndexMap<File, Url>,
22-
graph: DiGraph<Url, (SmolStr, IngotArguments)>,
22+
graph: DiGraph<Url, (SmolStr, DependencyArguments)>,
2323
graph_nodes: IndexMap<Url, NodeIndex>,
2424
}
2525

@@ -116,8 +116,8 @@ impl Workspace {
116116
pub fn join_graph(
117117
&self,
118118
db: &mut dyn InputDb,
119-
graph: DiGraph<Url, (SmolStr, IngotArguments)>,
120-
join_edges: Vec<(Url, Url, (SmolStr, IngotArguments))>,
119+
graph: DiGraph<Url, (SmolStr, DependencyArguments)>,
120+
join_edges: Vec<(Url, Url, (SmolStr, DependencyArguments))>,
121121
) {
122122
let old_graph = self.graph(db);
123123
let combined_graph = join_graphs(&old_graph, &graph, &join_edges);
@@ -128,7 +128,7 @@ impl Workspace {
128128
self.set_graph(db).to(combined_graph);
129129
}
130130

131-
pub fn get_graph(&self, db: &dyn InputDb) -> DiGraph<Url, (SmolStr, IngotArguments)> {
131+
pub fn get_graph(&self, db: &dyn InputDb) -> DiGraph<Url, (SmolStr, DependencyArguments)> {
132132
self.graph(db).clone()
133133
}
134134

@@ -151,10 +151,10 @@ use petgraph::graph::NodeIndex;
151151
use std::collections::HashMap;
152152

153153
fn join_graphs(
154-
g1: &DiGraph<Url, (SmolStr, IngotArguments)>,
155-
g2: &DiGraph<Url, (SmolStr, IngotArguments)>,
156-
join_edges: &[(Url, Url, (SmolStr, IngotArguments))],
157-
) -> DiGraph<Url, (SmolStr, IngotArguments)> {
154+
g1: &DiGraph<Url, (SmolStr, DependencyArguments)>,
155+
g2: &DiGraph<Url, (SmolStr, DependencyArguments)>,
156+
join_edges: &[(Url, Url, (SmolStr, DependencyArguments))],
157+
) -> DiGraph<Url, (SmolStr, DependencyArguments)> {
158158
let mut combined = DiGraph::new();
159159

160160
let mut node_map = HashMap::<Url, NodeIndex>::new();

crates/common/src/urlext.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ impl UrlExt for Url {
7070
}
7171
}
7272

73+
pub fn canonical_url(path: &Utf8PathBuf) -> Url {
74+
Url::from_directory_path(path.canonicalize_utf8().unwrap().as_str())
75+
.unwrap()
76+
.directory()
77+
.unwrap()
78+
}
79+
7380
#[cfg(test)]
7481
mod tests {
7582
use super::*;

crates/driver/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ pub mod files;
44

55
use std::{collections::HashSet, mem::take};
66

7-
use common::InputDb;
7+
use common::{config::DependencyArguments, InputDb};
88
pub use db::DriverDataBase;
99

10-
use common::config::{Config, IngotArguments};
10+
use common::config::Config;
1111
use hir::hir_def::TopLevelMod;
1212
use resolver::{
1313
files::{File, FilesResolutionError, FilesResolver},
@@ -64,7 +64,7 @@ pub enum WorkspaceSetupDiagnostics {
6464

6565
pub struct InputNodeHandler<'a> {
6666
pub db: &'a mut dyn InputDb,
67-
pub join_edges: Vec<(Url, Url, (SmolStr, IngotArguments))>,
67+
pub join_edges: Vec<(Url, Url, (SmolStr, DependencyArguments))>,
6868
}
6969

7070
impl<'a> InputNodeHandler<'a> {
@@ -75,15 +75,15 @@ impl<'a> InputNodeHandler<'a> {
7575
}
7676
}
7777

78-
pub fn join_graph(&mut self, graph: DiGraph<Url, (SmolStr, IngotArguments)>) {
78+
pub fn join_graph(&mut self, graph: DiGraph<Url, (SmolStr, DependencyArguments)>) {
7979
self.db
8080
.workspace()
8181
.join_graph(self.db, graph, take(&mut self.join_edges));
8282
}
8383
}
8484

8585
impl<'a> ResolutionHandler<FilesResolver> for InputNodeHandler<'a> {
86-
type Item = Vec<(Url, (SmolStr, IngotArguments))>;
86+
type Item = Vec<(Url, (SmolStr, DependencyArguments))>;
8787

8888
fn handle_resolution(&mut self, ingot_url: &Url, files: Vec<File>) -> Self::Item {
8989
let mut config = None;
@@ -108,7 +108,7 @@ impl<'a> ResolutionHandler<FilesResolver> for InputNodeHandler<'a> {
108108
}
109109

110110
if let Some(content) = config {
111-
let config = Config::from_string(content);
111+
let config = Config::parse(&content).unwrap();
112112

113113
let weights: HashSet<Url> = self
114114
.db
@@ -126,13 +126,13 @@ impl<'a> ResolutionHandler<FilesResolver> for InputNodeHandler<'a> {
126126
self.join_edges.push((
127127
ingot_url.clone(),
128128
based_dependency.url,
129-
(based_dependency.alias, based_dependency.arguments),
129+
(based_dependency.alias, based_dependency.parameters),
130130
));
131131
None
132132
} else {
133133
Some((
134134
based_dependency.url,
135-
(based_dependency.alias, based_dependency.arguments),
135+
(based_dependency.alias, based_dependency.parameters),
136136
))
137137
}
138138
})

crates/fe/src/check.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use camino::Utf8PathBuf;
2-
use common::urlext::canonical_url;
3-
use common::InputDb;
2+
use common::{urlext::canonical_url, InputDb};
43
use driver::DriverDataBase;
54

65
pub fn check(path: &Utf8PathBuf) {
76
let mut db = DriverDataBase::default();
8-
let ingot_url = canonical_url(path).unwrap();
7+
let ingot_url = canonical_url(path);
98
driver::init_workspace_ingot(&mut db, &ingot_url);
109

1110
let ingot = db.workspace().containing_ingot(&db, &ingot_url).unwrap();

crates/fe/src/tree.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};
22

33
use camino::Utf8PathBuf;
44
use common::{
5-
config::{Config, IngotArguments},
5+
config::{Config, DependencyArguments},
66
urlext::canonical_url,
77
};
88
use resolver::{
@@ -15,7 +15,7 @@ use url::Url;
1515

1616
pub fn print_tree(path: &Utf8PathBuf) {
1717
let mut graph_resolver = basic_ingot_graph_resolver();
18-
let ingot_url = canonical_url(path).unwrap();
18+
let ingot_url = canonical_url(path);
1919
let ingot_graph = graph_resolver.transient_resolve(&ingot_url).unwrap();
2020
print!(
2121
"{}",
@@ -53,7 +53,7 @@ impl TreePrefix {
5353
}
5454

5555
pub fn print_tree_impl(
56-
graph: &DiGraph<Url, (SmolStr, IngotArguments)>,
56+
graph: &DiGraph<Url, (SmolStr, DependencyArguments)>,
5757
root_path: &Url,
5858
configs: &HashMap<Url, Config>,
5959
) -> String {
@@ -80,7 +80,7 @@ pub fn print_tree_impl(
8080
}
8181

8282
fn print_node(
83-
graph: &DiGraph<Url, (SmolStr, IngotArguments)>,
83+
graph: &DiGraph<Url, (SmolStr, DependencyArguments)>,
8484
node: NodeIndex,
8585
prefix: TreePrefix,
8686
output: &mut String,
@@ -92,9 +92,9 @@ fn print_node(
9292
let base_label = if let Some(config) = configs.get(ingot_path) {
9393
format!(
9494
"{} v{}",
95-
config.ingot.name.as_deref().unwrap_or("null"),
95+
config.metadata.name.as_deref().unwrap_or("null"),
9696
config
97-
.ingot
97+
.metadata
9898
.version
9999
.as_ref()
100100
.map(ToString::to_string)

0 commit comments

Comments
 (0)