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

Improve project analysis #2

Merged
merged 9 commits into from
Jan 15, 2024
Merged

Improve project analysis #2

merged 9 commits into from
Jan 15, 2024

Conversation

kylewlacy
Copy link
Member

This PR overhauls the "project analysis" phase to find all imported file paths ahead-of-time. This doesn't have much impact on functionality, but it will be important for things like "format all files in this project".

One outcome of this PR that is an improvement though: the TypeScript Language Service Host no longer does blocking I/O to read files! 🎉 This is because we now asynchronously load documents into the BriocheCompilerHost type before calling into the TypeScript code. Then, the TypeScript code uses Deno ops that just read from BriocheCompilerHost, and assume that the documents have already been loaded asynchronously.

There are still some instances of blocking I/O-- namely when resolving import specifiers-- but it'll take some more work to fix those cases.

The sync versions are specifically needed because the TypeScript
Language Service expects functions like `read_file` to be sync. This can
be resolved by reading all the files ahead-of-time, which can be done as
a follow-up
This command mainly exists for testing
`CompilerHost` can now load a file, which loads it and all its imports
(recursively) into the list of documents. Reading a document now only
blocks on the `RwLock`, and never does I/O
@kylewlacy kylewlacy merged commit 7dbb728 into main Jan 15, 2024
3 checks passed
@kylewlacy kylewlacy deleted the improve-project-analysis branch January 15, 2024 09:48
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.

1 participant