Skip to content
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

First prototype of evaluation #1672

Merged
merged 2 commits into from
Oct 12, 2023
Merged

First prototype of evaluation #1672

merged 2 commits into from
Oct 12, 2023

Conversation

jneem
Copy link
Member

@jneem jneem commented Oct 9, 2023

This is an initial (and pretty dumb) version of evaluation: there's a code action that evaluates the whole file (from scratch every time you ask for it) and presents the diagnostics.

Fixes #1639

@jneem jneem requested review from vkleen and yannham October 9, 2023 22:22
@github-actions github-actions bot temporarily deployed to pull request October 9, 2023 22:27 Inactive

fn eval(server: &mut Server, uri: &Url) -> Result<(), Error> {
if let Some(file_id) = server.cache.file_id(uri)? {
// TODO: avoid cloning the cache. Maybe we can have a VM with a &mut ImportResolver?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this would be annoying because we'd have to add a lifetime parameter to VirtualMachine. I wonder if you can't just implement ImportResolver for &'a mut R when R: ImportResolver, thus passing a mutable reference instead? Or just wrap it as a dedicated type ImportResolverRef<'a, R: ImportResolver>(&'a mut ImportResolver) and implement the trait. After all VirtualMachine is generic over the resolver.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's a good point. I'll give it a quick try, and if it works I'll add it to this PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementing ImportResolver for &'a mut R worked nicely, but it didn't solve the issue because prepare_eval is only defined when the import resolver parameter is ImportCache. I'll just leave the TODO for now...

@jneem jneem enabled auto-merge October 12, 2023 17:13
@github-actions github-actions bot temporarily deployed to pull request October 12, 2023 17:16 Inactive
@jneem jneem added this pull request to the merge queue Oct 12, 2023
Merged via the queue into master with commit 4dfd59a Oct 12, 2023
5 checks passed
@jneem jneem deleted the nls-evaluate branch October 12, 2023 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Evaluate the whole term on-demand through code actions
2 participants