File tree Expand file tree Collapse file tree 4 files changed +21
-19
lines changed Expand file tree Collapse file tree 4 files changed +21
-19
lines changed Original file line number Diff line number Diff line change
1
+ use camino:: Utf8PathBuf ;
1
2
use url:: Url ;
2
3
3
4
#[ derive( Debug ) ]
@@ -51,6 +52,13 @@ impl UrlExt for Url {
51
52
}
52
53
}
53
54
55
+ pub fn canonical_url ( path : & Utf8PathBuf ) -> Result < Url , ( ) > {
56
+ Ok (
57
+ Url :: from_directory_path ( path. canonicalize_utf8 ( ) . map_err ( |_| ( ) ) ?. as_str ( ) )
58
+ . map_err ( |_| ( ) ) ?,
59
+ )
60
+ }
61
+
54
62
#[ cfg( test) ]
55
63
mod tests {
56
64
use super :: * ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ pub mod files;
4
4
5
5
use camino:: Utf8PathBuf ;
6
6
7
- use common:: InputDb ;
7
+ use common:: { urlext :: canonical_url , InputDb } ;
8
8
pub use db:: DriverDataBase ;
9
9
10
10
use common:: {
@@ -24,15 +24,14 @@ pub fn setup_workspace(
24
24
path : & Utf8PathBuf ,
25
25
) -> ( DriverDataBase , Workspace , Vec < WorkspaceSetupDiagnostics > ) {
26
26
let mut db = DriverDataBase :: default ( ) ;
27
+ let ingot_url = canonical_url ( path) . unwrap ( ) ;
27
28
let workspace = db. workspace ( ) ;
28
29
let node_handler = InputNodeHandler {
29
30
db : & mut db,
30
31
workspace,
31
32
} ;
32
33
let mut ingot_graph_resolver = ingot_graph_resolver ( node_handler) ;
33
- let _graph = ingot_graph_resolver
34
- . transient_resolve ( & Url :: from_directory_path ( & path. canonicalize_utf8 ( ) . unwrap ( ) ) . unwrap ( ) )
35
- . unwrap ( ) ;
34
+ let _graph = ingot_graph_resolver. transient_resolve ( & ingot_url) . unwrap ( ) ;
36
35
37
36
let diagnostics = ingot_graph_resolver
38
37
. take_diagnostics ( )
Original file line number Diff line number Diff line change 1
1
use camino:: Utf8PathBuf ;
2
+ use common:: urlext:: canonical_url;
2
3
use url:: Url ;
3
4
4
5
pub fn check ( path : & Utf8PathBuf ) {
@@ -9,14 +10,8 @@ pub fn check(path: &Utf8PathBuf) {
9
10
}
10
11
11
12
let ingot = workspace
12
- . containing_ingot (
13
- & db,
14
- & Url :: from_file_path ( path. canonicalize_utf8 ( ) . unwrap ( ) . join ( "fe.toml" ) ) . unwrap ( ) ,
15
- // &Url::from_directory_path(path.canonicalize_utf8().unwrap())
16
- // .unwrap()
17
- // .directory()
18
- // .unwrap(),
19
- )
13
+ // should probably get url from setup
14
+ . containing_ingot ( & db, & canonical_url ( path) . unwrap ( ) )
20
15
. unwrap ( ) ;
21
16
let diags = db. run_on_ingot ( ingot) ;
22
17
diags. emit ( & db) ;
Original file line number Diff line number Diff line change 1
1
use std:: collections:: { HashMap , HashSet } ;
2
2
3
3
use camino:: Utf8PathBuf ;
4
- use common:: config:: { Config , IngotArguments } ;
4
+ use common:: {
5
+ config:: { Config , IngotArguments } ,
6
+ urlext:: canonical_url,
7
+ } ;
5
8
use resolver:: {
6
9
graph:: { petgraph, DiGraph , NodeIndex } ,
7
10
ingot:: basic_ingot_graph_resolver,
@@ -12,16 +15,13 @@ use url::Url;
12
15
13
16
pub fn print_tree ( path : & Utf8PathBuf ) {
14
17
let mut graph_resolver = basic_ingot_graph_resolver ( ) ;
15
- let c_path = & path. canonicalize_utf8 ( ) . unwrap ( ) ;
16
- println ! ( "{c_path}" ) ;
17
- let ingot_graph = graph_resolver
18
- . transient_resolve ( & Url :: from_directory_path ( c_path. as_str ( ) ) . unwrap ( ) )
19
- . unwrap ( ) ;
18
+ let ingot_url = canonical_url ( path) . unwrap ( ) ;
19
+ let ingot_graph = graph_resolver. transient_resolve ( & ingot_url) . unwrap ( ) ;
20
20
print ! (
21
21
"{}" ,
22
22
print_tree_impl(
23
23
& ingot_graph,
24
- & Url :: from_directory_path ( c_path . as_str ( ) ) . unwrap ( ) ,
24
+ & ingot_url ,
25
25
& graph_resolver. node_handler. configs
26
26
)
27
27
) ;
You can’t perform that action at this time.
0 commit comments