-
Notifications
You must be signed in to change notification settings - Fork 200
Resolution handler #1068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Resolution handler #1068
Conversation
a7ce31a
to
a61d9e9
Compare
fd31a02
to
06381f9
Compare
ec49518
to
5430d93
Compare
685f878
to
1069810
Compare
f28fd37
to
d0b347d
Compare
crates/common/src/config.rs
Outdated
}, | ||
#[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
pub struct DependencyDescription { | ||
pub url: Url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not be expressive enough to handle both relative and absolute dependency paths.
} | ||
|
||
#[derive(Debug, Clone)] | ||
#[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
pub struct Dependency { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be really nice if Dependency
is just a flat thing, something like:
Dependency {
alias: SmolStr,
location: Either<Url, Utf8PathBuf>,
arguments: Option<IngotArguments>
}
crates/common/src/ingot.rs
Outdated
pub fn config(self, db: &'db dyn InputDb) -> Option<Config> { | ||
db.workspace() | ||
.containing_ingot_config_file(db, self.base(db)) | ||
.map(|config_file| Config::from_string(config_file.text(db).clone())) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where the magic happens, where we just parse the config from the config's File
input into a Config
object. I added all the derivations to Config
so that it can be salsa tracked.
crates/resolver/src/ingot.rs
Outdated
@@ -47,16 +47,23 @@ impl ResolutionHandler<FilesResolver> for BasicIngotNodeHandler { | |||
return config | |||
.dependencies | |||
.into_iter() | |||
.map(|dependency| match dependency.description { | |||
DependencyDescription::Path(path) => ( | |||
ingot_path.join(path).canonicalize_utf8().unwrap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the resolver was handling relative paths quite well before. If Dependency
/DependencyDescription
can only store a Url
this gets trickier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the dependency struct should hold onto a url, unless it is a git repo or something. it should just be a simple representation of what is in the config file. it's pretty easy for a function in common::ingot to map a path DependencyDescription
to a file url given the parent ingot.
crates/hir/src/hir_def/mod.rs
Outdated
.filter_map( | ||
|Dependency { | ||
alias, | ||
description: DependencyDescription { url, .. }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The oversimplified DependencyDescription
with its handy Url
is making this a little too easy. In the end we need to be able to consistently map a Dependency
to a URL. In the case of relative path dependencies, there needs to be some way of injecting a base URL so that if the dependency points to a relative path we can resolve an absolute URL for that relative path.
Maybe we can have a method like:
impl Dependency {
fn url(&self, base_url: Url) -> Url {
let flattened_absolute_url = match self.location ... // handle path vs url
return flattened_absolute_url
}
The idea would be that the dependency itself carries around either a url or a path and that this can be resolved given a base url.
crates/common/src/ingot.rs
Outdated
} | ||
|
||
#[salsa::tracked] | ||
pub fn dependencies(self, db: &'db dyn InputDb) -> Vec<Dependency> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could just return the aliases and urls and the dependency descriptions can remain relative
caa2daf
to
f97a007
Compare
f97a007
to
bee0e97
Compare
109a9dd
to
2154b82
Compare
2154b82
to
6b7285d
Compare
No description provided.