Skip to content

Conversation

@ivanwonder
Copy link
Contributor

@ivanwonder ivanwonder commented Apr 30, 2024

This PR allows the language service to suggest imports for all directives returned from the compiler, and generate the TypeScript module import and the decorator import when the component is selected by the user.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Apr 30, 2024
@thePunderWoman thePunderWoman added the area: language-service Issues related to Angular's VS Code language service label Apr 30, 2024
@ngbot ngbot bot added this to the Backlog milestone Apr 30, 2024
@ivanwonder ivanwonder force-pushed the completion-compoent-not-imported branch 5 times, most recently from 5a9b8ca to fa81eca Compare May 6, 2024 14:29
@ivanwonder
Copy link
Contributor Author

https://github.com/angular/angular/blob/1872fcd8e09fefb52f9b36e8261702cd6fb03f85/packages/compiler-cli/src/ngtsc/typecheck/src/checker.ts#L766_L771

This will be a bug if two components have the same selector name. I think we can fix this later.

Copy link
Contributor

@dylhunn dylhunn left a comment

Choose a reason for hiding this comment

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

Really nice work, thank you for making this improvement! I didn't realize you could provide actions alongside completions like this, and good work factoring out the common code.

reviewed-for: fw-compiler, language-service

@dylhunn dylhunn added the target: minor This PR is targeted for the next minor release label May 16, 2024
@ivanwonder
Copy link
Contributor Author

@dylhunn

I find a bug here. I only tested it in the HTML file, It doesn't work for the template in the ts file because the code action breaks the rule of additionalTextEdits, additional text edits should be used to change text unrelated to the current cursor position, but the auto-import code action change range includes the template where the current cursor is.

I think the code action for auto-import should only touch the imports array instead of the whole component decorators. I will try to fix this.

Sorry about this.

@dylhunn dylhunn added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label May 17, 2024
@ivanwonder ivanwonder force-pushed the completion-compoent-not-imported branch from 1db1e64 to 406fc96 Compare May 18, 2024 12:09
@ivanwonder ivanwonder requested a review from dylhunn May 20, 2024 13:05
This PR allows the language service to suggest imports for all directives returned from the
compiler, and generate the TypeScript module import and the decorator import when the component
is selected by the user.
@ivanwonder ivanwonder force-pushed the completion-compoent-not-imported branch from 406fc96 to 9521fc5 Compare May 31, 2024 13:50
@dylhunn
Copy link
Contributor

dylhunn commented Jun 10, 2024

@ivanwonder Is this ready to merge? LMK and I will run the presubmit and have it merged.

@dylhunn
Copy link
Contributor

dylhunn commented Jun 10, 2024

caretaker: All failures in the presubmit were flakes.

@ivanwonder
Copy link
Contributor Author

@ivanwonder Is this ready to merge? LMK and I will run the presubmit and have it merged.

Yes, it's ready

@dylhunn dylhunn added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jun 12, 2024
@ngbot
Copy link

ngbot bot commented Jun 12, 2024

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google-internal-tests" is failing
    pending 1 pending code review

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@dylhunn dylhunn added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Jun 12, 2024
@alxhub
Copy link
Member

alxhub commented Jun 12, 2024

This PR was merged into the repository by commit b400e2e.

@alxhub alxhub closed this in b400e2e Jun 12, 2024
@ivanwonder ivanwonder deleted the completion-compoent-not-imported branch June 13, 2024 00:44
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 14, 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 detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants