Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(language-service): add code reactoring action to migrate @Input to signal input #57214

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

Closed

Conversation

devversion
Copy link
Member

@devversion devversion commented Jul 31, 2024

(experimental action for now; migration is not done/finalized yet)

Language service refactoring action that can convert @Input() declarations to signal inputs.

The user can click on an @Input property declaration in e.g. the VSCode extension and ask
for the input to be migrated. All references, imports and the declaration are updated automatically.

NOTE: Currently based on top of: #57562

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: language-service Issues related to Angular's VS Code language service labels Jul 31, 2024
@ngbot ngbot bot added this to the Backlog milestone Jul 31, 2024
@devversion devversion force-pushed the ls-code-refactoring-signal-inputs branch from dcb93e8 to f77a1f2 Compare July 31, 2024 16:42
@devversion devversion force-pushed the ls-code-refactoring-signal-inputs branch from f77a1f2 to f796f4a Compare August 28, 2024 13:56
@angular-robot angular-robot bot added area: build & ci Related the build and CI infrastructure of the project area: migrations Issues related to `ng update` migrations labels Aug 28, 2024
@devversion devversion requested a review from crisbeto August 28, 2024 13:57
@devversion devversion added target: minor This PR is targeted for the next minor release action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 28, 2024
@devversion devversion marked this pull request as ready for review August 28, 2024 13:58
@pullapprove pullapprove bot requested a review from atscott August 28, 2024 13:58
@devversion devversion force-pushed the ls-code-refactoring-signal-inputs branch 2 times, most recently from 2b0d49e to 9f74be3 Compare August 28, 2024 16:19
return node;
}

function getBeforeMigrateHookToFilterAllUnrelatedInputs(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really difficult to understand because of how it mutates the known inputs and results prior to running the migration on them. It's really hard to follow that this is happening when looking at the actual migration code that calls the hook: from there, it looks like the hook might just be a no-op for the migration since it's a void function. Can we change this to have the "beforeMigration" actually return an object with the modified known inputs and results?

Alternatively, can we document this "beforeMigrateHook" either by renaming it to something that indicates the objects being passed in can be/are mutated or add some jsdoc to the function or comments at the call location in migration.ts?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was done that way to keep the migration code more decoupled from the language service, and it's indeed leveraging a few implementation details.

You are right though. It doesn't feel great. I will have a look, but don't want to make super invasive changes right now since I also need to figure out the same problem when trying to limit to an directory in ng update.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will keep that comment open, and address it in a follow-up, tomorrow. Want to get things moving for now.

This allows us to split up the BUILD rules a bit further, so that
refactorings can be their own BUILD target. This is beneficial as
e.g. refactorings may rely on migration code from Angular core etc.
and this allows for more fine-grained visibility and a better conceptual
split.
…chronously

VSCode explicitly split code actions into two stages:

 - what actions are active?
 - what are the edits, if the user presses the button.

The latter stage may take longer to compute complex edits, perform
analysis. This stage is currently implemented via our non-LSP standard
`applyRefactoring` method. We should make it asynchronous, so that it
can easily integrate with migrations that aren't synchronous/or compute
in parallel.

Long-term we may want to revisit this given integration in 1P with the
language service as an actual TS server plugin; but it's not necessary
right now and we shouldn't block the effort on this for now.
…` to signal-input

(experimental at this point)

Language service refactoring action that can convert `@Input()`
declarations to signal inputs.

The user can click on an `@Input` property declaration in e.g. the VSCode
extension and ask for the input to be migrated. All references, imports and
the declaration are updated automatically.
This allows us to bundle e.g. the signal input migration into
language-service without duplicating code. Rollup with Bazel may end up
duplicating because it isn't able to associate the local sources with
the linked modules from `node_modules/@angular/compiler-cli`.
@devversion devversion force-pushed the ls-code-refactoring-signal-inputs branch from 9f74be3 to 80f2c8c Compare August 28, 2024 20:37
@devversion devversion force-pushed the ls-code-refactoring-signal-inputs branch from 80f2c8c to eb28838 Compare August 28, 2024 20:40
@devversion devversion 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 Aug 28, 2024
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 82f4590.

The changes were merged into the following branches: main

AndrewKushnir pushed a commit that referenced this pull request Aug 29, 2024
…chronously (#57214)

VSCode explicitly split code actions into two stages:

 - what actions are active?
 - what are the edits, if the user presses the button.

The latter stage may take longer to compute complex edits, perform
analysis. This stage is currently implemented via our non-LSP standard
`applyRefactoring` method. We should make it asynchronous, so that it
can easily integrate with migrations that aren't synchronous/or compute
in parallel.

Long-term we may want to revisit this given integration in 1P with the
language service as an actual TS server plugin; but it's not necessary
right now and we shouldn't block the effort on this for now.

PR Close #57214
AndrewKushnir pushed a commit that referenced this pull request Aug 29, 2024
…` to signal-input (#57214)

(experimental at this point)

Language service refactoring action that can convert `@Input()`
declarations to signal inputs.

The user can click on an `@Input` property declaration in e.g. the VSCode
extension and ask for the input to be migrated. All references, imports and
the declaration are updated automatically.

PR Close #57214
AndrewKushnir pushed a commit that referenced this pull request Aug 29, 2024
This allows us to bundle e.g. the signal input migration into
language-service without duplicating code. Rollup with Bazel may end up
duplicating because it isn't able to associate the local sources with
the linked modules from `node_modules/@angular/compiler-cli`.

PR Close #57214
@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 Sep 29, 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: build & ci Related the build and CI infrastructure of the project area: language-service Issues related to Angular's VS Code language service area: migrations Issues related to `ng update` migrations detected: feature PR contains a feature commit 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