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
feat: improve auto import provider #2
feat: improve auto import provider #2
Conversation
5152a9c
to
3d1828f
Compare
if (oldProgram && oldProgram !== this.getCurrentProgram()) { | ||
this.hostProject.clearCachedExportInfoMap(); | ||
} | ||
}, |
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 is the only logic that is not 1:1.
In summary calling updateGraph should:
- update rootFileNames if not truthy
- set the new program from the language service
- mark project as not dirty (sequential changes in same project won't retrigger updateGraph)
- If the program is not the same then clear the cached export info map.
projectVersion = newVersion; | ||
project.hostProject.clearCachedExportInfoMap(); | ||
project.clearCachedExportInfoMap(); | ||
return project.dirty && project.updateGraph(); |
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 now matches the logic 1:1 with this method, if dirty then update graph.
@@ -403,7 +163,8 @@ function createBaseProject( | |||
fileExists: this.program.fileExists, | |||
// @ts-expect-error | |||
directoryExists: this.program.directoryExists, | |||
realpath: undefined, | |||
// @ts-expect-error | |||
realpath: this.program.realpath || this.projectService.host.realpath?.bind(this.projectService.host), |
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.
Reset this back to the original implementation, originally set this to undefined while triaging issue but should have been this originally.
2330b53
to
809b042
Compare
809b042
to
b617817
Compare
Ensure that auto import provider only clears cache when referencing symlink has changed, previously it would reset the cache when any changes to projects where made. This could be slow to pick up auto imports as it would trigger auto import to resolve every time change was made. Copy more source types over from source to make the code more typesafe and easier to reason with. Decouple auto import provider project to seperate file to make easier to work with.
b617817
to
5d6d42d
Compare
Explicitly proxy project methods to host, init project (constructor) seperately as this would proxy twice for auto import provider and allows seperate logic for creating language service.
Ensure that auto import provider only clears cache when referencing symlink has changed, previously it would reset the cache when any changes to projects where made. This could be slow to pick up auto imports as it would trigger auto import
to resolve every time change was made.
Copy more source types over from source to make the code more typesafe and easier to reason with.
Decouple auto import provider project to separate file to make easier to work with.