Language service fixes by crisbeto · Pull Request #58719 · angular/angular · GitHub
Skip to content

Language service fixes#58719

Closed
crisbeto wants to merge 2 commits into
angular:mainfrom
crisbeto:language-service-fixes
Closed

Language service fixes#58719
crisbeto wants to merge 2 commits into
angular:mainfrom
crisbeto:language-service-fixes

Conversation

@crisbeto

Copy link
Copy Markdown
Member

Includes the following fixes for the language service:

fix(language-service): allow fixes to run without template info

Currently the code fixes won't run if the template information can't be resolved on the diagnostic node. This is incorrect for diagnostics that are reported within .ts files. These changes make the templateInfo nullable and leave the early exit up to the individual fixes.

fix(language-service): add fix for individual unused imports

Fixes that getCodeActions wasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases.

Currently the code fixes won't run if the template information can't be resolved on the diagnostic node. This is incorrect for diagnostics that are reported within `.ts` files. These changes make the `templateInfo` nullable and leave the early exit up to the individual fixes.
Fixes that `getCodeActions` wasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: rc This PR is targeted for the next release-candidate labels Nov 18, 2024
@crisbeto crisbeto requested a review from devversion November 18, 2024 16:21
@pullapprove pullapprove Bot requested a review from alxhub November 18, 2024 16:21
@angular-robot angular-robot Bot added the area: language-service Issues related to Angular's VS Code language service label Nov 18, 2024
@ngbot ngbot Bot added this to the Backlog milestone Nov 18, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note the typo here was spawn.length instead of tc.span.length which meant that the assertion was always incorrect. I've fixed it plus a handful of tests that weren't asserting properly.

@crisbeto crisbeto requested review from clydin and removed request for alxhub November 18, 2024 16:25

@clydin clydin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

As followup, would it be useful to have some sort of requiresTemplateInfo boolean on the code fix action definition? As we increase the amount of code fixes, this would allow bypassing the getCodeActions call completely instead of adding null checks to each action. And it avoids the empty array creation plus spread/push for each.

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 18, 2024
@devversion devversion added target: patch This PR is targeted for the next patch release and removed target: rc This PR is targeted for the next release-candidate labels Nov 19, 2024
@AndrewKushnir

Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit dcd27d7.

The changes were merged into the following branches: main, 19.0.x

AndrewKushnir pushed a commit that referenced this pull request Nov 19, 2024
Fixes that `getCodeActions` wasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases.

PR Close #58719
AndrewKushnir pushed a commit that referenced this pull request Nov 19, 2024
Currently the code fixes won't run if the template information can't be resolved on the diagnostic node. This is incorrect for diagnostics that are reported within `.ts` files. These changes make the `templateInfo` nullable and leave the early exit up to the individual fixes.

PR Close #58719
AndrewKushnir pushed a commit that referenced this pull request Nov 19, 2024
Fixes that `getCodeActions` wasn't implemented for the unused imports fixer which meant that it wouldn't show up in the most common cases.

PR Close #58719
@angular-automatic-lock-bot

Copy link
Copy Markdown

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: language-service Issues related to Angular's VS Code language service target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants