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

feat: improve auto import provider #2

Conversation

blake-newman
Copy link
Contributor

@blake-newman blake-newman commented Apr 11, 2023

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.

@blake-newman blake-newman force-pushed the blake.newman/auto-import-improvements branch from 5152a9c to 3d1828f Compare April 11, 2023 17:42
if (oldProgram && oldProgram !== this.getCurrentProgram()) {
this.hostProject.clearCachedExportInfoMap();
}
},
Copy link
Contributor Author

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();
Copy link
Contributor Author

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),
Copy link
Contributor Author

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.

@blake-newman blake-newman force-pushed the blake.newman/auto-import-improvements branch 2 times, most recently from 2330b53 to 809b042 Compare April 11, 2023 19:39
@blake-newman blake-newman changed the title wip feat: improve auto import provider Apr 11, 2023
@blake-newman blake-newman force-pushed the blake.newman/auto-import-improvements branch from 809b042 to b617817 Compare April 12, 2023 12:26
@blake-newman blake-newman marked this pull request as ready for review April 12, 2023 12:32
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.
@blake-newman blake-newman force-pushed the blake.newman/auto-import-improvements branch from b617817 to 5d6d42d Compare April 12, 2023 12:34
johnsoncodehk and others added 3 commits April 13, 2023 01:45
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.
@johnsoncodehk johnsoncodehk merged commit 280555b into volarjs:master Apr 15, 2023
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.

None yet

2 participants