-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(material/schematics): rename references in MDC generate schematic #25773
fix(material/schematics): rename references in MDC generate schematic #25773
Conversation
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.
Awesome work!!
src/material/schematics/ng-generate/mdc-migration/rules/ts-migration/runtime-migration.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
if (ts.isIdentifier(node)) { | ||
for (const [specifier, newName] of importSpecifiers.entries()) { |
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.
If you're looking for a way to speed things up, I think you could preprocess the importSpecifiers
map before passing it to _renameReferences
.
Convert it to a Map<string, Map<ts.ImportSpecifier, string>>
where the first key is the import specifier's propertyName
/name
(whichever refers to the old name). Then you don't need to check any of the ones that are obviously not it
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.
Maybe I'm misunderstanding this, but I think that this is covered by the first early exit check inside _isReferenceToImport
where it exits if the import specifier doesn't match the name of the identifier.
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.
The way you have it now ensures that we just have to do minimal work for each element of the map, but we still have to iterate over the entire map for every node. With the change I'm proposing we would only have to iterate over a fraction of the map at each node
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.
Done. I ended up going for a simpler Map<string, ts.ImportSpecifier>
instead.
src/material/schematics/ng-generate/mdc-migration/rules/ts-migration/runtime-migration.ts
Outdated
Show resolved
Hide resolved
a8de1e1
to
c18ab88
Compare
The feedback has been addressed. |
c18ab88
to
b59cb27
Compare
Currently the `ng generate` migration that migrates from the legacy symbols to the non-legacy ones renames references, but only in some specific cases (e.g. `imports` of an `NgModule`). These changes expand the migration to cover any reference within the file. I've also tried to reduce the amount of migration data that we need to maintain.
b59cb27
to
e4b8ac9
Compare
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.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently the
ng generate
migration that migrates from the legacy symbols to the non-legacy ones renames references, but only in some specific cases (e.g.imports
of anNgModule
). These changes expand the migration to cover any reference within the file. I've also tried to reduce the amount of migration data that we need to maintain.