Skip to content

Commit

Permalink
fix ast file abs path
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <[email protected]>
  • Loading branch information
He1pa committed Sep 20, 2024
1 parent 5e4d764 commit 4e19fb2
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 146 deletions.
8 changes: 7 additions & 1 deletion kclvm/api/src/capi_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,14 @@ fn test_c_api_get_schema_type_mapping() {
"get-schema-type-mapping.json",
"get-schema-type-mapping.response.json",
|r| {
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let root = root.to_str().unwrap();
for (_, s_ty) in &mut r.schema_type_mapping {
s_ty.filename = s_ty.filename.replace('/', "").replace('\\', "")
let filename = match s_ty.filename.strip_prefix(root) {
Some(f) => f.to_string(),
None => s_ty.filename.clone(),
};
s_ty.filename = filename.replace('.', "").replace('/', "").replace('\\', "")
}
},
);
Expand Down
9 changes: 9 additions & 0 deletions kclvm/parser/src/file_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ pub struct PkgFile {
pub pkg_root: String,
}

impl PkgFile {
pub fn canonicalize(&self) -> PathBuf {
match self.path.canonicalize() {
Ok(p) => p.clone(),
_ => self.path.clone(),
}
}
}

/// A graph of files, where each file depends on zero or more other files.
#[derive(Default)]
pub struct PkgFileGraph {
Expand Down
Loading

0 comments on commit 4e19fb2

Please sign in to comment.