@openrewrite/recipes-angular 1.26.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +188 -1
- package/dist/index.js.map +1 -1
- package/dist/libraries/components/lst.d.ts +7 -0
- package/dist/libraries/components/lst.d.ts.map +1 -1
- package/dist/libraries/components/lst.js +12 -0
- package/dist/libraries/components/lst.js.map +1 -1
- package/dist/libraries/components/style-sources.d.ts +15 -0
- package/dist/libraries/components/style-sources.d.ts.map +1 -0
- package/dist/libraries/components/style-sources.js +108 -0
- package/dist/libraries/components/style-sources.js.map +1 -0
- package/dist/libraries/components/stylesheets.d.ts +12 -0
- package/dist/libraries/components/stylesheets.d.ts.map +1 -1
- package/dist/libraries/components/stylesheets.js +37 -1
- package/dist/libraries/components/stylesheets.js.map +1 -1
- package/dist/libraries/components/symbols.d.ts +21 -1
- package/dist/libraries/components/symbols.d.ts.map +1 -1
- package/dist/libraries/components/symbols.js +124 -9
- package/dist/libraries/components/symbols.js.map +1 -1
- package/dist/libraries/components/template-elements.d.ts +38 -0
- package/dist/libraries/components/template-elements.d.ts.map +1 -0
- package/dist/libraries/components/template-elements.js +90 -0
- package/dist/libraries/components/template-elements.js.map +1 -0
- package/dist/libraries/components/templates.d.ts +6 -0
- package/dist/libraries/components/templates.d.ts.map +1 -1
- package/dist/libraries/components/templates.js +17 -2
- package/dist/libraries/components/templates.js.map +1 -1
- package/dist/libraries/material/add-system-variables-prefix.d.ts +9 -0
- package/dist/libraries/material/add-system-variables-prefix.d.ts.map +1 -0
- package/dist/libraries/material/add-system-variables-prefix.js +74 -0
- package/dist/libraries/material/add-system-variables-prefix.js.map +1 -0
- package/dist/libraries/material/add-theme-base-mixins.d.ts +19 -0
- package/dist/libraries/material/add-theme-base-mixins.d.ts.map +1 -0
- package/dist/libraries/material/add-theme-base-mixins.js +176 -0
- package/dist/libraries/material/add-theme-base-mixins.js.map +1 -0
- package/dist/libraries/material/find-chip-input-event-without-chip-input.d.ts +8 -0
- package/dist/libraries/material/find-chip-input-event-without-chip-input.d.ts.map +1 -0
- package/dist/libraries/material/find-chip-input-event-without-chip-input.js +95 -0
- package/dist/libraries/material/find-chip-input-event-without-chip-input.js.map +1 -0
- package/dist/libraries/material/find-legacy-material-usage.d.ts +8 -0
- package/dist/libraries/material/find-legacy-material-usage.d.ts.map +1 -0
- package/dist/libraries/material/find-legacy-material-usage.js +103 -0
- package/dist/libraries/material/find-legacy-material-usage.js.map +1 -0
- package/dist/libraries/material/find-material-constructor-changes.d.ts +74 -0
- package/dist/libraries/material/find-material-constructor-changes.d.ts.map +1 -0
- package/dist/libraries/material/find-material-constructor-changes.js +267 -0
- package/dist/libraries/material/find-material-constructor-changes.js.map +1 -0
- package/dist/libraries/material/find-mdc-breaking-changes.d.ts +45 -0
- package/dist/libraries/material/find-mdc-breaking-changes.d.ts.map +1 -0
- package/dist/libraries/material/find-mdc-breaking-changes.js +326 -0
- package/dist/libraries/material/find-mdc-breaking-changes.js.map +1 -0
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.d.ts +8 -0
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.d.ts.map +1 -0
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.js +125 -0
- package/dist/libraries/material/find-mixin-error-state-without-state-changes.js.map +1 -0
- package/dist/libraries/material/find-raw-palette-themes.d.ts +28 -0
- package/dist/libraries/material/find-raw-palette-themes.d.ts.map +1 -0
- package/dist/libraries/material/find-raw-palette-themes.js +124 -0
- package/dist/libraries/material/find-raw-palette-themes.js.map +1 -0
- package/dist/libraries/material/find-removed-material-apis.d.ts +20 -0
- package/dist/libraries/material/find-removed-material-apis.d.ts.map +1 -0
- package/dist/libraries/material/find-removed-material-apis.js +60 -0
- package/dist/libraries/material/find-removed-material-apis.js.map +1 -0
- package/dist/libraries/material/find-removed-material-classes.d.ts +13 -0
- package/dist/libraries/material/find-removed-material-classes.d.ts.map +1 -0
- package/dist/libraries/material/find-removed-material-classes.js +154 -0
- package/dist/libraries/material/find-removed-material-classes.js.map +1 -0
- package/dist/libraries/material/find-removed-material-members.d.ts +67 -0
- package/dist/libraries/material/find-removed-material-members.d.ts.map +1 -0
- package/dist/libraries/material/find-removed-material-members.js +168 -0
- package/dist/libraries/material/find-removed-material-members.js.map +1 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.d.ts +8 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.d.ts.map +1 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.js +102 -0
- package/dist/libraries/material/find-slide-toggle-drag-options.js.map +1 -0
- package/dist/libraries/material/material-15-classes.d.ts +6 -0
- package/dist/libraries/material/material-15-classes.d.ts.map +1 -0
- package/dist/libraries/material/material-15-classes.js +435 -0
- package/dist/libraries/material/material-15-classes.js.map +1 -0
- package/dist/libraries/material/material-entry-points.d.ts +3 -0
- package/dist/libraries/material/material-entry-points.d.ts.map +1 -0
- package/dist/libraries/material/material-entry-points.js +201 -0
- package/dist/libraries/material/material-entry-points.js.map +1 -0
- package/dist/libraries/material/material-legacy-symbols.d.ts +2 -0
- package/dist/libraries/material/material-legacy-symbols.d.ts.map +1 -0
- package/dist/libraries/material/material-legacy-symbols.js +559 -0
- package/dist/libraries/material/material-legacy-symbols.js.map +1 -0
- package/dist/libraries/material/material-theming-api.d.ts +23 -0
- package/dist/libraries/material/material-theming-api.d.ts.map +1 -0
- package/dist/libraries/material/material-theming-api.js +446 -0
- package/dist/libraries/material/material-theming-api.js.map +1 -0
- package/dist/libraries/material/material-version.d.ts +24 -0
- package/dist/libraries/material/material-version.d.ts.map +1 -0
- package/dist/libraries/material/material-version.js +160 -0
- package/dist/libraries/material/material-version.js.map +1 -0
- package/dist/libraries/material/migrate-legacy-material.d.ts +60 -0
- package/dist/libraries/material/migrate-legacy-material.d.ts.map +1 -0
- package/dist/libraries/material/migrate-legacy-material.js +230 -0
- package/dist/libraries/material/migrate-legacy-material.js.map +1 -0
- package/dist/libraries/material/migrate-list-item-harness-content-loader.d.ts +8 -0
- package/dist/libraries/material/migrate-list-item-harness-content-loader.d.ts.map +1 -0
- package/dist/libraries/material/migrate-list-item-harness-content-loader.js +62 -0
- package/dist/libraries/material/migrate-list-item-harness-content-loader.js.map +1 -0
- package/dist/libraries/material/migrate-m2-theming-api.d.ts +12 -0
- package/dist/libraries/material/migrate-m2-theming-api.d.ts.map +1 -0
- package/dist/libraries/material/migrate-m2-theming-api.js +120 -0
- package/dist/libraries/material/migrate-m2-theming-api.js.map +1 -0
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts +9 -0
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.d.ts.map +1 -0
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js +36 -0
- package/dist/libraries/material/migrate-mat-core-to-elevation-classes.js.map +1 -0
- package/dist/libraries/material/migrate-material-15-typography.d.ts +21 -0
- package/dist/libraries/material/migrate-material-15-typography.d.ts.map +1 -0
- package/dist/libraries/material/migrate-material-15-typography.js +185 -0
- package/dist/libraries/material/migrate-material-15-typography.js.map +1 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.d.ts +8 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.d.ts.map +1 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.js +157 -0
- package/dist/libraries/material/migrate-material-secondary-entry-points.js.map +1 -0
- package/dist/libraries/material/migrate-material-theming-api.d.ts +17 -0
- package/dist/libraries/material/migrate-material-theming-api.d.ts.map +1 -0
- package/dist/libraries/material/migrate-material-theming-api.js +190 -0
- package/dist/libraries/material/migrate-material-theming-api.js.map +1 -0
- package/dist/libraries/material/migrate-mdc-styles.d.ts +23 -0
- package/dist/libraries/material/migrate-mdc-styles.d.ts.map +1 -0
- package/dist/libraries/material/migrate-mdc-styles.js +145 -0
- package/dist/libraries/material/migrate-mdc-styles.js.map +1 -0
- package/dist/libraries/material/migrate-mdc-templates.d.ts +18 -0
- package/dist/libraries/material/migrate-mdc-templates.d.ts.map +1 -0
- package/dist/libraries/material/migrate-mdc-templates.js +306 -0
- package/dist/libraries/material/migrate-mdc-templates.js.map +1 -0
- package/dist/libraries/material/migrate-selection-list-change-option.d.ts +8 -0
- package/dist/libraries/material/migrate-selection-list-change-option.d.ts.map +1 -0
- package/dist/libraries/material/migrate-selection-list-change-option.js +49 -0
- package/dist/libraries/material/migrate-selection-list-change-option.js.map +1 -0
- package/dist/libraries/material/remove-mat-stepper-document-argument.d.ts +8 -0
- package/dist/libraries/material/remove-mat-stepper-document-argument.d.ts.map +1 -0
- package/dist/libraries/material/remove-mat-stepper-document-argument.js +72 -0
- package/dist/libraries/material/remove-mat-stepper-document-argument.js.map +1 -0
- package/dist/libraries/material/remove-update-active-link-argument.d.ts +8 -0
- package/dist/libraries/material/remove-update-active-link-argument.d.ts.map +1 -0
- package/dist/libraries/material/remove-update-active-link-argument.js +54 -0
- package/dist/libraries/material/remove-update-active-link-argument.js.map +1 -0
- package/dist/libraries/material/rename-material-members.d.ts +51 -0
- package/dist/libraries/material/rename-material-members.d.ts.map +1 -0
- package/dist/libraries/material/rename-material-members.js +125 -0
- package/dist/libraries/material/rename-material-members.js.map +1 -0
- package/dist/libraries/material/rename-material-style-names.d.ts +28 -0
- package/dist/libraries/material/rename-material-style-names.d.ts.map +1 -0
- package/dist/libraries/material/rename-material-style-names.js +148 -0
- package/dist/libraries/material/rename-material-style-names.js.map +1 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts +20 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.d.ts.map +1 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.js +32 -0
- package/dist/libraries/material/rename-textarea-autosize-attributes.js.map +1 -0
- package/dist/libraries/material/upgrade-to-material.d.ts +74 -0
- package/dist/libraries/material/upgrade-to-material.d.ts.map +1 -0
- package/dist/libraries/material/upgrade-to-material.js +324 -0
- package/dist/libraries/material/upgrade-to-material.js.map +1 -0
- package/dist/libraries/primeng/18/migrate-primeng-config.d.ts.map +1 -1
- package/dist/libraries/primeng/18/migrate-primeng-config.js +0 -59
- package/dist/libraries/primeng/18/migrate-primeng-config.js.map +1 -1
- package/dist/libraries/primeng/18/rename-calendar-to-datepicker.d.ts.map +1 -1
- package/dist/libraries/primeng/18/rename-calendar-to-datepicker.js +0 -65
- package/dist/libraries/primeng/18/rename-calendar-to-datepicker.js.map +1 -1
- package/dist/libraries/primeng/18/rename-dropdown-to-select.d.ts.map +1 -1
- package/dist/libraries/primeng/18/rename-dropdown-to-select.js +0 -65
- package/dist/libraries/primeng/18/rename-dropdown-to-select.js.map +1 -1
- package/dist/libraries/primeng/18/rename-inputswitch-to-toggleswitch.d.ts.map +1 -1
- package/dist/libraries/primeng/18/rename-inputswitch-to-toggleswitch.js +0 -65
- package/dist/libraries/primeng/18/rename-inputswitch-to-toggleswitch.js.map +1 -1
- package/dist/libraries/primeng/18/rename-overlaypanel-to-popover.d.ts.map +1 -1
- package/dist/libraries/primeng/18/rename-overlaypanel-to-popover.js +0 -65
- package/dist/libraries/primeng/18/rename-overlaypanel-to-popover.js.map +1 -1
- package/dist/libraries/primeng/18/rename-sidebar-to-drawer.d.ts.map +1 -1
- package/dist/libraries/primeng/18/rename-sidebar-to-drawer.js +0 -65
- package/dist/libraries/primeng/18/rename-sidebar-to-drawer.js.map +1 -1
- package/dist/migration/rename-after-render.d.ts +2 -2
- package/dist/migration/rename-after-render.d.ts.map +1 -1
- package/dist/migration/rename-after-render.js +9 -25
- package/dist/migration/rename-after-render.js.map +1 -1
- package/dist/migration/rename-check-no-changes.d.ts +2 -2
- package/dist/migration/rename-check-no-changes.d.ts.map +1 -1
- package/dist/migration/rename-check-no-changes.js +23 -19
- package/dist/migration/rename-check-no-changes.js.map +1 -1
- package/dist/migration/rename-pending-tasks.d.ts +2 -2
- package/dist/migration/rename-pending-tasks.d.ts.map +1 -1
- package/dist/migration/rename-pending-tasks.js +9 -22
- package/dist/migration/rename-pending-tasks.js.map +1 -1
- package/dist/migration/rename-zoneless-provider.d.ts +2 -2
- package/dist/migration/rename-zoneless-provider.d.ts.map +1 -1
- package/dist/migration/rename-zoneless-provider.js +9 -21
- package/dist/migration/rename-zoneless-provider.js.map +1 -1
- package/dist/migration/upgrade-angular-dependencies.d.ts +2 -0
- package/dist/migration/upgrade-angular-dependencies.d.ts.map +1 -1
- package/dist/migration/upgrade-angular-dependencies.js +6 -0
- package/dist/migration/upgrade-angular-dependencies.js.map +1 -1
- package/dist/migration/upgrade-to-angular-10.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-10.js +5 -1
- package/dist/migration/upgrade-to-angular-10.js.map +1 -1
- package/dist/migration/upgrade-to-angular-11.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-11.js +10 -1
- package/dist/migration/upgrade-to-angular-11.js.map +1 -1
- package/dist/migration/upgrade-to-angular-12.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-12.js +5 -1
- package/dist/migration/upgrade-to-angular-12.js.map +1 -1
- package/dist/migration/upgrade-to-angular-13.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-13.js +5 -1
- package/dist/migration/upgrade-to-angular-13.js.map +1 -1
- package/dist/migration/upgrade-to-angular-14.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-14.js +5 -1
- package/dist/migration/upgrade-to-angular-14.js.map +1 -1
- package/dist/migration/upgrade-to-angular-15.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-15.js +5 -1
- package/dist/migration/upgrade-to-angular-15.js.map +1 -1
- package/dist/migration/upgrade-to-angular-16.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-16.js +2 -1
- package/dist/migration/upgrade-to-angular-16.js.map +1 -1
- package/dist/migration/upgrade-to-angular-17.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-17.js +5 -1
- package/dist/migration/upgrade-to-angular-17.js.map +1 -1
- package/dist/migration/upgrade-to-angular-18.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-18.js +5 -1
- package/dist/migration/upgrade-to-angular-18.js.map +1 -1
- package/dist/migration/upgrade-to-angular-19.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-19.js +5 -1
- package/dist/migration/upgrade-to-angular-19.js.map +1 -1
- package/dist/migration/upgrade-to-angular-20.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-20.js +5 -1
- package/dist/migration/upgrade-to-angular-20.js.map +1 -1
- package/dist/migration/upgrade-to-angular-21.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-21.js +2 -1
- package/dist/migration/upgrade-to-angular-21.js.map +1 -1
- package/dist/migration/upgrade-to-angular-22.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-22.js +2 -1
- package/dist/migration/upgrade-to-angular-22.js.map +1 -1
- package/dist/migration/upgrade-to-angular-8.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-8.js +6 -1
- package/dist/migration/upgrade-to-angular-8.js.map +1 -1
- package/dist/migration/upgrade-to-angular-9.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-9.js +5 -1
- package/dist/migration/upgrade-to-angular-9.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +189 -0
- package/src/libraries/components/lst.ts +13 -2
- package/src/libraries/components/style-sources.ts +80 -0
- package/src/libraries/components/stylesheets.ts +37 -0
- package/src/libraries/components/symbols.ts +95 -10
- package/src/libraries/components/template-elements.ts +113 -0
- package/src/libraries/components/templates.ts +18 -4
- package/src/libraries/material/add-system-variables-prefix.ts +71 -0
- package/src/libraries/material/add-theme-base-mixins.ts +159 -0
- package/src/libraries/material/find-chip-input-event-without-chip-input.ts +63 -0
- package/src/libraries/material/find-legacy-material-usage.ts +73 -0
- package/src/libraries/material/find-material-constructor-changes.ts +231 -0
- package/src/libraries/material/find-mdc-breaking-changes.ts +273 -0
- package/src/libraries/material/find-mixin-error-state-without-state-changes.ts +89 -0
- package/src/libraries/material/find-raw-palette-themes.ts +100 -0
- package/src/libraries/material/find-removed-material-apis.ts +54 -0
- package/src/libraries/material/find-removed-material-classes.ts +127 -0
- package/src/libraries/material/find-removed-material-members.ts +146 -0
- package/src/libraries/material/find-slide-toggle-drag-options.ts +69 -0
- package/src/libraries/material/material-15-classes.ts +435 -0
- package/src/libraries/material/material-entry-points.ts +198 -0
- package/src/libraries/material/material-legacy-symbols.ts +557 -0
- package/src/libraries/material/material-theming-api.ts +454 -0
- package/src/libraries/material/material-version.ts +142 -0
- package/src/libraries/material/migrate-legacy-material.ts +202 -0
- package/src/libraries/material/migrate-list-item-harness-content-loader.ts +39 -0
- package/src/libraries/material/migrate-m2-theming-api.ts +98 -0
- package/src/libraries/material/migrate-mat-core-to-elevation-classes.ts +32 -0
- package/src/libraries/material/migrate-material-15-typography.ts +153 -0
- package/src/libraries/material/migrate-material-secondary-entry-points.ts +154 -0
- package/src/libraries/material/migrate-material-theming-api.ts +189 -0
- package/src/libraries/material/migrate-mdc-styles.ts +117 -0
- package/src/libraries/material/migrate-mdc-templates.ts +269 -0
- package/src/libraries/material/migrate-selection-list-change-option.ts +28 -0
- package/src/libraries/material/remove-mat-stepper-document-argument.ts +44 -0
- package/src/libraries/material/remove-update-active-link-argument.ts +33 -0
- package/src/libraries/material/rename-material-members.ts +109 -0
- package/src/libraries/material/rename-material-style-names.ts +116 -0
- package/src/libraries/material/rename-textarea-autosize-attributes.ts +27 -0
- package/src/libraries/material/upgrade-to-material.ts +286 -0
- package/src/libraries/primeng/18/migrate-primeng-config.ts +2 -43
- package/src/libraries/primeng/18/rename-calendar-to-datepicker.ts +2 -50
- package/src/libraries/primeng/18/rename-dropdown-to-select.ts +2 -50
- package/src/libraries/primeng/18/rename-inputswitch-to-toggleswitch.ts +2 -50
- package/src/libraries/primeng/18/rename-overlaypanel-to-popover.ts +2 -50
- package/src/libraries/primeng/18/rename-sidebar-to-drawer.ts +2 -50
- package/src/migration/rename-after-render.ts +11 -24
- package/src/migration/rename-check-no-changes.ts +21 -18
- package/src/migration/rename-pending-tasks.ts +11 -22
- package/src/migration/rename-zoneless-provider.ts +11 -21
- package/src/migration/upgrade-angular-dependencies.ts +6 -0
- package/src/migration/upgrade-to-angular-10.ts +6 -2
- package/src/migration/upgrade-to-angular-11.ts +11 -2
- package/src/migration/upgrade-to-angular-12.ts +6 -2
- package/src/migration/upgrade-to-angular-13.ts +6 -2
- package/src/migration/upgrade-to-angular-14.ts +6 -2
- package/src/migration/upgrade-to-angular-15.ts +6 -2
- package/src/migration/upgrade-to-angular-16.ts +3 -2
- package/src/migration/upgrade-to-angular-17.ts +6 -2
- package/src/migration/upgrade-to-angular-18.ts +6 -2
- package/src/migration/upgrade-to-angular-19.ts +6 -2
- package/src/migration/upgrade-to-angular-20.ts +6 -2
- package/src/migration/upgrade-to-angular-21.ts +3 -2
- package/src/migration/upgrade-to-angular-22.ts +3 -2
- package/src/migration/upgrade-to-angular-8.ts +6 -1
- package/src/migration/upgrade-to-angular-9.ts +6 -2
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 the original author or authors.
|
|
3
|
+
*
|
|
4
|
+
* Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {ExecutionContext, foundSearchResult, ScanningRecipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
|
+
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
9
|
+
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
10
|
+
import {importedNames} from "../components/symbols";
|
|
11
|
+
import {extendedClassName, hasSearchResult, isSuperCall} from "../components/lst";
|
|
12
|
+
import {argumentCount} from "../cdk/find-cdk-signature-changes";
|
|
13
|
+
import {beforeMaterialVersion, MATERIAL, materialMajorScanner} from "./material-version";
|
|
14
|
+
|
|
15
|
+
/** The number of arguments the constructor of an `@angular/material` class accepts as of a major version. */
|
|
16
|
+
interface ChangedConstructor {
|
|
17
|
+
module: string;
|
|
18
|
+
name: string;
|
|
19
|
+
min: number;
|
|
20
|
+
max: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Marks constructor calls that no longer fit a changed `@angular/material` constructor, in files whose `package.json` is not on that major yet. */
|
|
24
|
+
export abstract class FindMaterialConstructorChanges extends ScanningRecipe<Map<string, number>> {
|
|
25
|
+
protected abstract readonly version: number;
|
|
26
|
+
protected abstract readonly constructors: ChangedConstructor[];
|
|
27
|
+
|
|
28
|
+
initialValue(_ctx: ExecutionContext): Map<string, number> {
|
|
29
|
+
return new Map();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async scanner(majors: Map<string, number>): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
33
|
+
return materialMajorScanner((directory, major) => majors.set(directory, major));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async editorWithData(majors: Map<string, number>): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
37
|
+
const version = this.version;
|
|
38
|
+
const constructors = this.constructors;
|
|
39
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
40
|
+
private classes = new Map<string, ChangedConstructor>();
|
|
41
|
+
|
|
42
|
+
protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
|
|
43
|
+
if (!beforeMaterialVersion(majors, cu.sourcePath, version)) return cu;
|
|
44
|
+
this.classes = new Map();
|
|
45
|
+
for (const c of constructors) {
|
|
46
|
+
for (const local of importedNames(cu, c.module, [c.name]).keys()) this.classes.set(local, c);
|
|
47
|
+
}
|
|
48
|
+
return this.classes.size === 0 ? cu : super.visitJsCompilationUnit(cu, p);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected async visitNewClass(newClass: J.NewClass, p: ExecutionContext): Promise<J | undefined> {
|
|
52
|
+
const n = await super.visitNewClass(newClass, p) as J.NewClass;
|
|
53
|
+
const changed = n.class && isIdentifier(n.class) ? this.classes.get(n.class.simpleName) : undefined;
|
|
54
|
+
return changed ? mark(n, n.arguments, changed) : n;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected async visitFunctionCall(functionCall: JS.FunctionCall, p: ExecutionContext): Promise<J | undefined> {
|
|
58
|
+
const call = await super.visitFunctionCall(functionCall, p) as JS.FunctionCall;
|
|
59
|
+
if (!isSuperCall(call)) return call;
|
|
60
|
+
const classDecl = this.cursor.firstEnclosing((t: any): t is J.ClassDeclaration => t?.kind === J.Kind.ClassDeclaration);
|
|
61
|
+
const extended = classDecl && extendedClassName(classDecl);
|
|
62
|
+
const changed = extended ? this.classes.get(extended) : undefined;
|
|
63
|
+
return changed ? mark(call, call.arguments, changed) : call;
|
|
64
|
+
}
|
|
65
|
+
}();
|
|
66
|
+
|
|
67
|
+
function mark<T extends J>(call: T, args: J.Container<J>, changed: ChangedConstructor): T {
|
|
68
|
+
const count = argumentCount(args);
|
|
69
|
+
const spread = args.elements.some(a => a.element.kind === JS.Kind.Spread);
|
|
70
|
+
if (spread || (count >= changed.min && count <= changed.max) || hasSearchResult(call, `changed in @angular/material ${version} and takes`)) return call;
|
|
71
|
+
const expected = changed.min === changed.max ? `${changed.min}` : `${changed.min} to ${changed.max}`;
|
|
72
|
+
return foundSearchResult(call, `The constructor of \`${changed.name}\` changed in @angular/material ${version} ` +
|
|
73
|
+
`and takes ${expected} arguments. Update the arguments to match it.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function constructorOf(module: string, name: string, min: number, max: number): ChangedConstructor {
|
|
79
|
+
return {module: `${MATERIAL}/${module}`, name, min, max};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class FindMaterial8ConstructorChanges extends FindMaterialConstructorChanges {
|
|
83
|
+
readonly name = "org.openrewrite.angular.material.FindMaterial8ConstructorChanges";
|
|
84
|
+
readonly displayName = "Find constructor calls broken by Angular Material 8";
|
|
85
|
+
readonly description = "Finds `new` and `super(...)` calls of Angular Material classes whose constructor changed in " +
|
|
86
|
+
"version 8, such as `MatFormField` and `MatButton`, when they pass a number of arguments the new constructor does not accept.";
|
|
87
|
+
|
|
88
|
+
protected readonly version = 8;
|
|
89
|
+
protected readonly constructors = [
|
|
90
|
+
constructorOf('form-field', 'MatFormField', 8, 8),
|
|
91
|
+
constructorOf('tabs', 'MatTabLink', 7, 8),
|
|
92
|
+
constructorOf('stepper', 'MatVerticalStepper', 2, 4),
|
|
93
|
+
constructorOf('badge', 'MatBadge', 4, 5),
|
|
94
|
+
constructorOf('button', 'MatButton', 3, 3),
|
|
95
|
+
constructorOf('button', 'MatAnchor', 3, 3),
|
|
96
|
+
constructorOf('progress-spinner', 'MatSpinner', 4, 5),
|
|
97
|
+
constructorOf('progress-spinner', 'MatProgressSpinner', 4, 5),
|
|
98
|
+
constructorOf('list', 'MatList', 1, 1),
|
|
99
|
+
constructorOf('list', 'MatListItem', 2, 4),
|
|
100
|
+
constructorOf('expansion', 'MatExpansionPanel', 6, 7),
|
|
101
|
+
constructorOf('tabs', 'MatTabHeader', 6, 7),
|
|
102
|
+
constructorOf('tabs', 'MatTabBody', 3, 3),
|
|
103
|
+
constructorOf('slide-toggle', 'MatSlideToggle', 6, 8),
|
|
104
|
+
constructorOf('sidenav', 'MatDrawerContainer', 5, 7),
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class FindMaterial9ConstructorChanges extends FindMaterialConstructorChanges {
|
|
109
|
+
readonly name = "org.openrewrite.angular.material.FindMaterial9ConstructorChanges";
|
|
110
|
+
readonly displayName = "Find constructor calls broken by Angular Material 9";
|
|
111
|
+
readonly description = "Finds `new` and `super(...)` calls of `MatSelect` and `MatDialogRef`, whose constructor " +
|
|
112
|
+
"changed in Angular Material 9, when they pass a number of arguments the new constructor does not accept.";
|
|
113
|
+
|
|
114
|
+
protected readonly version = 9;
|
|
115
|
+
protected readonly constructors = [
|
|
116
|
+
constructorOf('select', 'MatSelect', 13, 14),
|
|
117
|
+
constructorOf('dialog', 'MatDialogRef', 2, 3),
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export class FindMaterial10ConstructorChanges extends FindMaterialConstructorChanges {
|
|
122
|
+
readonly name = "org.openrewrite.angular.material.FindMaterial10ConstructorChanges";
|
|
123
|
+
readonly displayName = "Find constructor calls broken by Angular Material 10";
|
|
124
|
+
readonly description = "Finds `new` and `super(...)` calls of Angular Material classes whose constructor changed in " +
|
|
125
|
+
"version 10, such as `MatTooltip` and `MatIcon`, when they pass a number of arguments the new constructor does not accept.";
|
|
126
|
+
|
|
127
|
+
protected readonly version = 10;
|
|
128
|
+
protected readonly constructors = [
|
|
129
|
+
constructorOf('slide-toggle', 'MatSlideToggle', 5, 6),
|
|
130
|
+
constructorOf('slider', 'MatSlider', 7, 8),
|
|
131
|
+
constructorOf('sort', 'MatSortHeader', 6, 6),
|
|
132
|
+
constructorOf('autocomplete', 'MatAutocompleteTrigger', 10, 10),
|
|
133
|
+
constructorOf('tooltip', 'MatTooltip', 11, 11),
|
|
134
|
+
constructorOf('icon', 'MatIcon', 5, 5),
|
|
135
|
+
constructorOf('icon', 'MatIconRegistry', 4, 4),
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export class FindMaterial11ConstructorChanges extends FindMaterialConstructorChanges {
|
|
140
|
+
readonly name = "org.openrewrite.angular.material.FindMaterial11ConstructorChanges";
|
|
141
|
+
readonly displayName = "Find constructor calls broken by Angular Material 11";
|
|
142
|
+
readonly description = "Finds `new` and `super(...)` calls of Angular Material classes whose constructor changed in " +
|
|
143
|
+
"version 11, such as `MatChip` and `MatCheckbox`, when they pass a number of arguments the new constructor does not accept.";
|
|
144
|
+
|
|
145
|
+
protected readonly version = 11;
|
|
146
|
+
protected readonly constructors = [
|
|
147
|
+
constructorOf('chips', 'MatChip', 6, 8),
|
|
148
|
+
constructorOf('chips', 'MatChipRemove', 2, 2),
|
|
149
|
+
constructorOf('datepicker', 'MatDatepickerContent', 5, 6),
|
|
150
|
+
constructorOf('bottom-sheet', 'MatBottomSheet', 3, 4),
|
|
151
|
+
constructorOf('bottom-sheet', 'MatBottomSheetRef', 2, 2),
|
|
152
|
+
constructorOf('checkbox', 'MatCheckbox', 5, 7),
|
|
153
|
+
constructorOf('tabs', 'MatTabBodyPortal', 4, 4),
|
|
154
|
+
constructorOf('tabs', 'MatTabNav', 6, 7),
|
|
155
|
+
constructorOf('tabs', 'MatTab', 2, 2),
|
|
156
|
+
constructorOf('core', 'MatCommonModule', 3, 3),
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export class FindMaterial12ConstructorChanges extends FindMaterialConstructorChanges {
|
|
161
|
+
readonly name = "org.openrewrite.angular.material.FindMaterial12ConstructorChanges";
|
|
162
|
+
readonly displayName = "Find constructor calls broken by Angular Material 12";
|
|
163
|
+
readonly description = "Finds `new` and `super(...)` calls of Angular Material classes whose constructor changed in " +
|
|
164
|
+
"version 12, such as `MatTooltip` and `MatStep`, when they pass a number of arguments the new constructor does not accept.";
|
|
165
|
+
|
|
166
|
+
protected readonly version = 12;
|
|
167
|
+
protected readonly constructors = [
|
|
168
|
+
constructorOf('tooltip', 'MatTooltip', 12, 12),
|
|
169
|
+
constructorOf('datepicker', 'MatDatepickerContent', 6, 6),
|
|
170
|
+
constructorOf('stepper', 'MatVerticalStepper', 4, 4),
|
|
171
|
+
constructorOf('stepper', 'MatStep', 3, 4),
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export class FindMaterial13ConstructorChanges extends FindMaterialConstructorChanges {
|
|
176
|
+
readonly name = "org.openrewrite.angular.material.FindMaterial13ConstructorChanges";
|
|
177
|
+
readonly displayName = "Find constructor calls broken by Angular Material 13";
|
|
178
|
+
readonly description = "Finds `new` and `super(...)` calls of Angular Material classes whose constructor changed in " +
|
|
179
|
+
"version 13, such as `MatFormField` and `MatDatepicker`, when they pass a number of arguments the new constructor does not accept.";
|
|
180
|
+
|
|
181
|
+
protected readonly version = 13;
|
|
182
|
+
protected readonly constructors = [
|
|
183
|
+
constructorOf('form-field', 'MatFormField', 7, 7),
|
|
184
|
+
constructorOf('datepicker', 'MatDatepicker', 7, 7),
|
|
185
|
+
constructorOf('datepicker', 'MatDateRangePicker', 7, 7),
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export class FindMaterial14ConstructorChanges extends FindMaterialConstructorChanges {
|
|
190
|
+
readonly name = "org.openrewrite.angular.material.FindMaterial14ConstructorChanges";
|
|
191
|
+
readonly displayName = "Find constructor calls broken by Angular Material 14";
|
|
192
|
+
readonly description = "Finds `new` and `super(...)` calls of `MatSelectionList`, `MatSelectionListChange` and " +
|
|
193
|
+
"`MatStepper`, whose constructor changed in Angular Material 14, when they pass a number of arguments the new " +
|
|
194
|
+
"constructor does not accept.";
|
|
195
|
+
|
|
196
|
+
protected readonly version = 14;
|
|
197
|
+
protected readonly constructors = [
|
|
198
|
+
constructorOf('list', 'MatSelectionList', 3, 3),
|
|
199
|
+
constructorOf('list', 'MatSelectionListChange', 2, 2),
|
|
200
|
+
constructorOf('stepper', 'MatStepper', 3, 3),
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export class FindMaterial15ConstructorChanges extends FindMaterialConstructorChanges {
|
|
205
|
+
readonly name = "org.openrewrite.angular.material.FindMaterial15ConstructorChanges";
|
|
206
|
+
readonly displayName = "Find constructor calls broken by Angular Material 15";
|
|
207
|
+
readonly description = "Finds `new` and `super(...)` calls of the Angular Material classes whose constructor the " +
|
|
208
|
+
"MDC-based components of version 15 changed, such as `MatFormField` and `MatListItem`, when they pass a number " +
|
|
209
|
+
"of arguments the new constructor does not accept.";
|
|
210
|
+
|
|
211
|
+
protected readonly version = 15;
|
|
212
|
+
protected readonly constructors = [
|
|
213
|
+
constructorOf('button', 'MatButton', 3, 4),
|
|
214
|
+
constructorOf('checkbox', 'MatCheckbox', 4, 6),
|
|
215
|
+
constructorOf('chips', 'MatChip', 5, 8),
|
|
216
|
+
constructorOf('chips', 'MatChipInput', 2, 3),
|
|
217
|
+
constructorOf('chips', 'MatChipTrailingIcon', 2, 2),
|
|
218
|
+
constructorOf('dialog', 'MatDialogContainer', 7, 9),
|
|
219
|
+
constructorOf('form-field', 'MatFormField', 5, 8),
|
|
220
|
+
constructorOf('list', 'MatList', 0, 0),
|
|
221
|
+
constructorOf('list', 'MatListItem', 4, 6),
|
|
222
|
+
constructorOf('list', 'MatListOption', 5, 7),
|
|
223
|
+
constructorOf('list', 'MatSelectionList', 2, 2),
|
|
224
|
+
constructorOf('progress-bar', 'MatProgressBar', 3, 5),
|
|
225
|
+
constructorOf('progress-spinner', 'MatProgressSpinner', 2, 3),
|
|
226
|
+
constructorOf('slider', 'MatSlider', 5, 7),
|
|
227
|
+
constructorOf('tabs', 'MatInkBar', 1, 1),
|
|
228
|
+
constructorOf('tabs', 'MatTabLink', 5, 6),
|
|
229
|
+
constructorOf('tabs', 'MatTabNav', 6, 8),
|
|
230
|
+
];
|
|
231
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 the original author or authors.
|
|
3
|
+
*
|
|
4
|
+
* Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {Cursor, ExecutionContext, foundSearchResult, ScanningRecipe, Tree, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
|
+
import {PlainText, PlainTextVisitor} from "@openrewrite/rewrite/text";
|
|
9
|
+
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
10
|
+
import {isLiteral, J} from "@openrewrite/rewrite/java";
|
|
11
|
+
import {hasSearchResult, propertyName} from "../components/lst";
|
|
12
|
+
import {FindRemovedSymbols, RemovedSymbol} from "../components/symbols";
|
|
13
|
+
import {mapOpeningTags, withoutHtmlComments} from "../components/templates";
|
|
14
|
+
import {attributeNamed, descendants, parseElements} from "../components/template-elements";
|
|
15
|
+
import {FindRemovedMaterialMembers, RemovedMember} from "./find-removed-material-members";
|
|
16
|
+
import {beforeMaterialVersion, MaterialProjects, materialProjectScanner} from "./material-version";
|
|
17
|
+
|
|
18
|
+
const GUIDE = "See the Angular Material v15 MDC migration guide.";
|
|
19
|
+
|
|
20
|
+
const CHIPS = "Chips were rewritten in @angular/material 15. Use `<mat-chip-listbox>` with `<mat-chip-option>` " +
|
|
21
|
+
"for selectable chips, or `<mat-chip-grid>` with `<mat-chip-row>` for chips with a text input.";
|
|
22
|
+
const SLIDER = "The slider was rewritten in @angular/material 15. Put an `<input matSliderThumb>` inside `<mat-slider>` " +
|
|
23
|
+
"and move `value`, `(change)` and `(input)` to it; `thumbLabel` became `discrete`, and `tickInterval`, `displayValue`, " +
|
|
24
|
+
"`valueText`, `invert` and `vertical` were removed.";
|
|
25
|
+
const LIST = "List items were reworked in @angular/material 15. Use `matListItemTitle` and `matListItemLine` instead " +
|
|
26
|
+
"of `matLine`, and `matListItemIcon` and `matListItemAvatar` instead of `matListIcon` and `matListAvatar`.";
|
|
27
|
+
|
|
28
|
+
function removed(entryPoint: string, names: string[], hint: string): RemovedSymbol[] {
|
|
29
|
+
return names.map(name => ({
|
|
30
|
+
module: `@angular/material/${entryPoint}`,
|
|
31
|
+
name,
|
|
32
|
+
message: `\`${name}\` was removed from \`@angular/material/${entryPoint}\` in @angular/material 15. ${hint}`,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class FindRemovedMaterial15Apis extends FindRemovedSymbols {
|
|
37
|
+
readonly name = "org.openrewrite.angular.material.FindRemovedMaterial15Apis";
|
|
38
|
+
readonly displayName = "Find APIs removed by the Angular Material 15 MDC components";
|
|
39
|
+
readonly description = "Finds imports of the chips, form field, list and slider APIs that the MDC-based components " +
|
|
40
|
+
"of Angular Material 15 no longer export, such as `MatChipList` and `MatPlaceholder`.";
|
|
41
|
+
|
|
42
|
+
protected readonly symbols = [
|
|
43
|
+
...removed('chips', ['MatChipList', 'MatChipListChange'],
|
|
44
|
+
"Use `MatChipListbox` and `MatChipListboxChange`, or `MatChipGrid` for chips with a text input."),
|
|
45
|
+
...removed('form-field', ['MatPlaceholder'], "Use `<mat-label>` or the `placeholder` of the input instead."),
|
|
46
|
+
...removed('list', ['MatListAvatarCssMatStyler', 'MatListIconCssMatStyler'],
|
|
47
|
+
"Use the `matListItemAvatar` and `matListItemIcon` directives instead."),
|
|
48
|
+
...removed('slider', ['MAT_SLIDER_VALUE_ACCESSOR'], "The `<input matSliderThumb>` inside the slider is the form control now."),
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function members(classNames: string[], names: string[], message: string): RemovedMember[] {
|
|
53
|
+
return names.map(name => ({classNames, name, message: `\`${classNames[0]}.${name}\` ${message}`}));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Members that the MDC-based components of Material 15 removed or changed. */
|
|
57
|
+
export const MATERIAL_15_MEMBERS: RemovedMember[] = [
|
|
58
|
+
...members(['MatChip'], ['selected', 'selectable', 'selectionChange', 'ariaSelected', 'select', 'deselect',
|
|
59
|
+
'selectViaInteraction', 'toggleSelected', 'chipListSelectable', 'avatar', 'rippleConfig', 'rippleDisabled'],
|
|
60
|
+
"was removed in @angular/material 15. Selection moved to `MatChipOption` inside a `<mat-chip-listbox>`."),
|
|
61
|
+
...members(['MatChipInput'], ['chipList'], "was removed in @angular/material 15. Use `chipGrid` instead."),
|
|
62
|
+
...members(['MatSlider', '_MatSliderBase'], ['value', 'valueChange', 'change', 'input', 'focus', 'blur', 'tabIndex', 'thumbLabel',
|
|
63
|
+
'tickInterval', 'valueText', 'displayValue', 'invert', 'vertical', 'percent', 'defaultTabIndex', 'onTouched',
|
|
64
|
+
'writeValue', 'registerOnChange', 'registerOnTouched', 'setDisabledState'],
|
|
65
|
+
"was removed in @angular/material 15. The value, its events and focus moved to the `MatSliderThumb` input inside the slider."),
|
|
66
|
+
...members(['MatFormField'], ['updateOutlineGap', 'defaultColor'], "was removed in @angular/material 15."),
|
|
67
|
+
...members(['MatListOption'], ['selectionList'], "was removed in @angular/material 15."),
|
|
68
|
+
...members(['MatButton', 'MatAnchor'], ['isRoundButton', 'isIconButton'],
|
|
69
|
+
"was removed in @angular/material 15. Icon buttons and FABs are separate components now."),
|
|
70
|
+
...members(['MatProgressBar'], ['progressbarId'], "was removed in @angular/material 15."),
|
|
71
|
+
...members(['MatSnackBar', '_MatSnackBarBase'], ['openFromComponent', 'openFromTemplate'],
|
|
72
|
+
"shows custom content with the MDC snack bar as of @angular/material 15. Mark the text with " +
|
|
73
|
+
"`matSnackBarLabel`, the action container with `matSnackBarActions` and each action with `matSnackBarAction`, " +
|
|
74
|
+
"or all content is treated as the label."),
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
export class FindRemovedMaterial15Members extends FindRemovedMaterialMembers {
|
|
78
|
+
readonly name = "org.openrewrite.angular.material.FindRemovedMaterial15Members";
|
|
79
|
+
readonly displayName = "Find members removed by the Angular Material 15 MDC components";
|
|
80
|
+
readonly description = "Finds uses of the chip, slider, form field, list, button and progress bar members that the " +
|
|
81
|
+
"MDC-based components of Angular Material 15 removed, and the custom snack bar content that needs the new " +
|
|
82
|
+
"snack bar directives.";
|
|
83
|
+
|
|
84
|
+
protected readonly version = 15;
|
|
85
|
+
protected readonly members = MATERIAL_15_MEMBERS;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const LIST_TAGS = /<(mat-list|mat-nav-list|mat-action-list|mat-selection-list|mat-list-item|mat-list-option)\b|mat-list-item/;
|
|
89
|
+
|
|
90
|
+
/** The MDC migration problems of one template, as distinct messages. */
|
|
91
|
+
export function mdcTemplateFindings(source: string): string[] {
|
|
92
|
+
const template = withoutHtmlComments(source);
|
|
93
|
+
const findings = new Set<string>();
|
|
94
|
+
const migratedSlider = /matSlider(Start|End)?Thumb/.test(template);
|
|
95
|
+
const usesLists = LIST_TAGS.test(template);
|
|
96
|
+
mapOpeningTags(template, (tag, attrs) => {
|
|
97
|
+
const names = attrs.replace(/"[^"]*"|'[^']*'/g, '""');
|
|
98
|
+
const has = (name: string) => new RegExp(`(^|\\s)[\\[(]*${name}[\\])]*(?=[\\s=/]|$)`).test(names);
|
|
99
|
+
if (tag === 'mat-chip-list') findings.add(CHIPS);
|
|
100
|
+
if ((tag === 'mat-chip' || tag === 'mat-basic-chip' || has('mat-chip') || has('mat-basic-chip')) &&
|
|
101
|
+
(has('selected') || has('selectable') || has('selectionChange'))) {
|
|
102
|
+
findings.add(CHIPS);
|
|
103
|
+
}
|
|
104
|
+
if ((tag === 'mat-chip-grid' && (has('multiple') || has('selectable') || has('compareWith'))) ||
|
|
105
|
+
(tag === 'mat-chip-row' && (has('selected') || has('selectable') || has('selectionChange')))) {
|
|
106
|
+
findings.add("Chips in a `<mat-chip-grid>` can't be selected as of @angular/material 15, so its `multiple` " +
|
|
107
|
+
"and `compareWith` and the `selected` and `selectionChange` of its chips are gone. " +
|
|
108
|
+
"Remove them, or use `<mat-chip-listbox>` with `<mat-chip-option>` for selectable chips.");
|
|
109
|
+
}
|
|
110
|
+
if (tag === 'mat-slider' && !migratedSlider) findings.add(SLIDER);
|
|
111
|
+
if (tag === 'mat-form-field' && /(^|\s)(appearance\s*=\s*["']\s*(legacy|standard)\s*["']|\[appearance\]\s*=\s*["']\s*'(legacy|standard)'\s*["'])/.test(attrs)) {
|
|
112
|
+
findings.add("The `legacy` and `standard` form field appearances were removed in @angular/material 15. " +
|
|
113
|
+
"Use `fill` or `outline`, and add a `<mat-label>` where the placeholder served as the label.");
|
|
114
|
+
}
|
|
115
|
+
if (tag === 'mat-form-field' && /(^|\s)(floatLabel\s*=\s*["']\s*never\s*["']|\[floatLabel\]\s*=\s*["']\s*'never'\s*["'])/.test(attrs)) {
|
|
116
|
+
findings.add("`floatLabel=\"never\"` was removed in @angular/material 15. Use the `placeholder` of the input instead.");
|
|
117
|
+
}
|
|
118
|
+
if (has('matListIcon') || has('mat-list-icon') || has('matListAvatar') || has('mat-list-avatar')) {
|
|
119
|
+
findings.add(usesLists ? LIST : "`matListIcon` and `matListAvatar` were removed in @angular/material 15, so " +
|
|
120
|
+
"outside a list they no longer add the `mat-list-icon` and `mat-list-avatar` classes. Remove them, or " +
|
|
121
|
+
"add the class and its styles yourself.");
|
|
122
|
+
}
|
|
123
|
+
if (usesLists && (has('matLine') || has('mat-line'))) findings.add(LIST);
|
|
124
|
+
if (tag === 'mat-placeholder') {
|
|
125
|
+
findings.add("`<mat-placeholder>` was removed in @angular/material 15. Use `<mat-label>` or the `placeholder` of the input instead.");
|
|
126
|
+
}
|
|
127
|
+
if (has('mat-tab-nav-bar') && !has('tabPanel')) {
|
|
128
|
+
findings.add("A `mat-tab-nav-bar` needs a `[tabPanel]` as of @angular/material 15. Wrap the routed content in " +
|
|
129
|
+
"`<mat-tab-nav-panel #tabPanel>` and bind it with `[tabPanel]=\"tabPanel\"`.");
|
|
130
|
+
}
|
|
131
|
+
if (has('mat-card-content') || has('matCardContent')) {
|
|
132
|
+
findings.add("`mat-card-content` only matches the element as of @angular/material 15. Use `<mat-card-content>` instead of the attribute.");
|
|
133
|
+
}
|
|
134
|
+
return attrs;
|
|
135
|
+
});
|
|
136
|
+
return [...findings];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const PLACEHOLDER_LABEL = "A `<mat-form-field>` without a `<mat-label>` showed the placeholder of its control as the " +
|
|
140
|
+
"floating label only with the `legacy` appearance, the default before @angular/material 15. Add a `<mat-label>` to " +
|
|
141
|
+
"keep the label.";
|
|
142
|
+
|
|
143
|
+
/** Form fields that relied on the `legacy` appearance to show the placeholder of their control as the label. */
|
|
144
|
+
export function placeholderLabelFields(template: string): {explicit: boolean, implicit: boolean} {
|
|
145
|
+
const result = {explicit: false, implicit: false};
|
|
146
|
+
if (!template.includes('mat-form-field')) return result;
|
|
147
|
+
for (const field of parseElements(template).filter(e => e.name === 'mat-form-field')) {
|
|
148
|
+
const inside = descendants(field);
|
|
149
|
+
if (inside.some(e => e.name === 'mat-label') || !inside.some(e => attributeNamed(e, 'placeholder'))) continue;
|
|
150
|
+
const appearance = attributeNamed(field, 'appearance');
|
|
151
|
+
const value = appearance?.name.startsWith('[') ? appearance.value?.trim().match(/^'(\w+)'$/)?.[1] : appearance?.value?.trim();
|
|
152
|
+
if (!appearance) result.implicit = true;
|
|
153
|
+
else if (value === 'legacy' || value === 'standard') result.explicit = true;
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface MdcTemplateScan extends MaterialProjects {
|
|
159
|
+
/** Source paths whose form fields relied on the `legacy` appearance, explicitly or as the default. */
|
|
160
|
+
explicitLegacy: Set<string>;
|
|
161
|
+
implicitLegacy: Set<string>;
|
|
162
|
+
defaultsToken: boolean;
|
|
163
|
+
defaultsAppearance: boolean;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export class FindMdcTemplateChanges extends ScanningRecipe<MdcTemplateScan> {
|
|
167
|
+
readonly name: string = "org.openrewrite.angular.material.FindMdcTemplateChanges";
|
|
168
|
+
readonly displayName: string = "Find templates affected by the Angular Material 15 MDC components";
|
|
169
|
+
readonly description: string = "Finds `.html` templates and inline `template` metadata of projects not on Material 15 yet that use component APIs the MDC-based " +
|
|
170
|
+
"components of Angular Material 15 changed: `<mat-chip-list>` and chip selection, the old slider markup, the " +
|
|
171
|
+
"`legacy` and `standard` form field appearances, `floatLabel=\"never\"`, `<mat-placeholder>`, `matLine`, " +
|
|
172
|
+
"`matListIcon` and `matListAvatar` in lists, a `mat-tab-nav-bar` without `tabPanel`, and the " +
|
|
173
|
+
"`mat-card-content` attribute, selection on chips in a `<mat-chip-grid>`, and form fields that relied on the " +
|
|
174
|
+
"`legacy` appearance to show the placeholder as the label, unless `MAT_FORM_FIELD_DEFAULT_OPTIONS` sets another " +
|
|
175
|
+
"default appearance.";
|
|
176
|
+
|
|
177
|
+
/** Whether the recipe applies to a source file, which by default means its project is not on Material 15 yet. */
|
|
178
|
+
protected appliesTo(projects: MaterialProjects, sourcePath: string): boolean {
|
|
179
|
+
return beforeMaterialVersion(projects.majors, sourcePath, 15);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
initialValue(_ctx: ExecutionContext): MdcTemplateScan {
|
|
183
|
+
return {majors: new Map(), legacyPaths: new Set(), explicitLegacy: new Set(), implicitLegacy: new Set(), defaultsToken: false, defaultsAppearance: false};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async scanner(acc: MdcTemplateScan): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
187
|
+
const majors = materialProjectScanner(acc);
|
|
188
|
+
const record = (sourcePath: string, template: string) => {
|
|
189
|
+
const fields = placeholderLabelFields(template);
|
|
190
|
+
if (fields.explicit) acc.explicitLegacy.add(sourcePath);
|
|
191
|
+
if (fields.implicit) acc.implicitLegacy.add(sourcePath);
|
|
192
|
+
};
|
|
193
|
+
const html = new class extends PlainTextVisitor<ExecutionContext> {
|
|
194
|
+
override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
|
|
195
|
+
if (text.sourcePath.endsWith('.html')) record(text.sourcePath, text.text);
|
|
196
|
+
return text;
|
|
197
|
+
}
|
|
198
|
+
}();
|
|
199
|
+
const typescript = new class extends JavaScriptVisitor<ExecutionContext> {
|
|
200
|
+
private sourcePath = '';
|
|
201
|
+
|
|
202
|
+
protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
|
|
203
|
+
this.sourcePath = cu.sourcePath;
|
|
204
|
+
return super.visitJsCompilationUnit(cu, p);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
protected async visitIdentifier(identifier: J.Identifier, p: ExecutionContext): Promise<J | undefined> {
|
|
208
|
+
if (identifier.simpleName === 'MAT_FORM_FIELD_DEFAULT_OPTIONS') acc.defaultsToken = true;
|
|
209
|
+
return super.visitIdentifier(identifier, p);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
protected async visitPropertyAssignment(property: JS.PropertyAssignment, p: ExecutionContext): Promise<J | undefined> {
|
|
213
|
+
const name = propertyName(property.name.element);
|
|
214
|
+
const initializer = property.initializer;
|
|
215
|
+
if (initializer && isLiteral(initializer) && typeof initializer.value === 'string') {
|
|
216
|
+
if (name === 'template') record(this.sourcePath, initializer.value);
|
|
217
|
+
if (name === 'appearance' && ['fill', 'outline'].includes(initializer.value)) acc.defaultsAppearance = true;
|
|
218
|
+
}
|
|
219
|
+
return super.visitPropertyAssignment(property, p);
|
|
220
|
+
}
|
|
221
|
+
}();
|
|
222
|
+
return new class extends TreeVisitor<any, ExecutionContext> {
|
|
223
|
+
async visit<R extends Tree>(tree: Tree, p: ExecutionContext, parent?: Cursor): Promise<R | undefined> {
|
|
224
|
+
await majors.visit(tree, p, parent);
|
|
225
|
+
await html.visit(tree, p, parent);
|
|
226
|
+
await typescript.visit(tree, p, parent);
|
|
227
|
+
return tree as R;
|
|
228
|
+
}
|
|
229
|
+
}();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
async editorWithData(acc: MdcTemplateScan): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
233
|
+
const defaults = acc.defaultsToken && acc.defaultsAppearance;
|
|
234
|
+
const reliesOnPlaceholder = (sourcePath: string) =>
|
|
235
|
+
acc.explicitLegacy.has(sourcePath) || (!defaults && acc.implicitLegacy.has(sourcePath));
|
|
236
|
+
const message = (findings: string[]) => `${findings.join(' ')} ${GUIDE}`;
|
|
237
|
+
const applies = (sourcePath: string) => this.appliesTo(acc, sourcePath);
|
|
238
|
+
const html = new class extends PlainTextVisitor<ExecutionContext> {
|
|
239
|
+
override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
|
|
240
|
+
const t = await super.visitText(text, p) as PlainText;
|
|
241
|
+
if (!t || !t.sourcePath.endsWith('.html') || !applies(t.sourcePath) || hasSearchResult(t, GUIDE)) return t;
|
|
242
|
+
const findings = mdcTemplateFindings(t.text);
|
|
243
|
+
if (reliesOnPlaceholder(t.sourcePath)) findings.push(PLACEHOLDER_LABEL);
|
|
244
|
+
return findings.length === 0 ? t : foundSearchResult(t, message(findings));
|
|
245
|
+
}
|
|
246
|
+
}();
|
|
247
|
+
const inline = new class extends JavaScriptVisitor<ExecutionContext> {
|
|
248
|
+
private sourcePath = '';
|
|
249
|
+
|
|
250
|
+
protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
|
|
251
|
+
this.sourcePath = cu.sourcePath;
|
|
252
|
+
return applies(cu.sourcePath) ? super.visitJsCompilationUnit(cu, p) : cu;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
protected async visitPropertyAssignment(property: JS.PropertyAssignment, p: ExecutionContext): Promise<J | undefined> {
|
|
256
|
+
const prop = await super.visitPropertyAssignment(property, p) as JS.PropertyAssignment;
|
|
257
|
+
const initializer = prop.initializer;
|
|
258
|
+
if (propertyName(prop.name.element) !== 'template' || hasSearchResult(prop, GUIDE)) return prop;
|
|
259
|
+
if (!initializer || !isLiteral(initializer) || typeof initializer.value !== 'string') return prop;
|
|
260
|
+
const findings = mdcTemplateFindings(initializer.value);
|
|
261
|
+
if (reliesOnPlaceholder(this.sourcePath) && placeholderLabelFields(initializer.value).implicit) findings.push(PLACEHOLDER_LABEL);
|
|
262
|
+
return findings.length === 0 ? prop : foundSearchResult(prop, message(findings));
|
|
263
|
+
}
|
|
264
|
+
}();
|
|
265
|
+
// Each visitor returns a source file it does not accept unchanged.
|
|
266
|
+
return new class extends TreeVisitor<any, ExecutionContext> {
|
|
267
|
+
async visit<R extends Tree>(tree: Tree, p: ExecutionContext, parent?: Cursor): Promise<R | undefined> {
|
|
268
|
+
const visited = await html.visit<Tree>(tree, p, parent);
|
|
269
|
+
return visited && await inline.visit(visited, p, parent) as R | undefined;
|
|
270
|
+
}
|
|
271
|
+
}();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 the original author or authors.
|
|
3
|
+
*
|
|
4
|
+
* Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
|
+
import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
|
|
9
|
+
import {isIdentifier, J} from "@openrewrite/rewrite/java";
|
|
10
|
+
import {importedNames} from "../components/symbols";
|
|
11
|
+
import {extendedClassName, hasSearchResult} from "../components/lst";
|
|
12
|
+
|
|
13
|
+
export class FindMixinErrorStateWithoutStateChanges extends Recipe {
|
|
14
|
+
readonly name = "org.openrewrite.angular.material.FindMixinErrorStateWithoutStateChanges";
|
|
15
|
+
readonly displayName = "Find `mixinErrorState` classes without `stateChanges`";
|
|
16
|
+
readonly description = "Material 14 stopped declaring `stateChanges` in the class that `mixinErrorState` returns. " +
|
|
17
|
+
"Finds classes that extend a `mixinErrorState(...)` class when neither they nor the mixed-in base class " +
|
|
18
|
+
"declare `stateChanges`.";
|
|
19
|
+
|
|
20
|
+
async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
|
|
21
|
+
return new class extends JavaScriptVisitor<ExecutionContext> {
|
|
22
|
+
private mixin = '';
|
|
23
|
+
/** Mixin classes of the file, mapped to the base class each passes to `mixinErrorState`. */
|
|
24
|
+
private mixins = new Map<string, string>();
|
|
25
|
+
private withStateChanges = new Set<string>();
|
|
26
|
+
|
|
27
|
+
protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
|
|
28
|
+
const mixin = [...importedNames(cu, '@angular/material/core', ['mixinErrorState']).keys()][0];
|
|
29
|
+
if (!mixin) return cu;
|
|
30
|
+
this.mixin = mixin;
|
|
31
|
+
this.mixins = new Map();
|
|
32
|
+
this.withStateChanges = new Set();
|
|
33
|
+
for (const statement of cu.statements.map(s => s.element)) {
|
|
34
|
+
if (statement.kind === J.Kind.ClassDeclaration && declaresStateChanges(statement as J.ClassDeclaration)) {
|
|
35
|
+
this.withStateChanges.add((statement as J.ClassDeclaration).name.simpleName);
|
|
36
|
+
}
|
|
37
|
+
if (statement.kind !== J.Kind.VariableDeclarations) continue;
|
|
38
|
+
for (const variable of (statement as J.VariableDeclarations).variables.map(v => v.element)) {
|
|
39
|
+
const initializer = variable.initializer?.element;
|
|
40
|
+
const mixedIn = initializer && mixedInBase(initializer, mixin);
|
|
41
|
+
if (mixedIn !== undefined && isIdentifier(variable.name)) this.mixins.set(variable.name.simpleName, mixedIn);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return super.visitJsCompilationUnit(cu, p);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected async visitClassDeclaration(classDecl: J.ClassDeclaration, p: ExecutionContext): Promise<J | undefined> {
|
|
48
|
+
const c = await super.visitClassDeclaration(classDecl, p) as J.ClassDeclaration;
|
|
49
|
+
const extended = c.extends?.element;
|
|
50
|
+
if (!extended || declaresStateChanges(c) || hasSearchResult(c, "`mixinErrorState` no longer declares `stateChanges`")) return c;
|
|
51
|
+
const name = extendedClassName(c);
|
|
52
|
+
const base = name !== undefined && this.mixins.has(name)
|
|
53
|
+
? this.mixins.get(name)
|
|
54
|
+
: mixedInBase(extended.kind === JS.Kind.TypeTreeExpression ? (extended as JS.TypeTreeExpression).expression : extended, this.mixin);
|
|
55
|
+
if (base === undefined || this.withStateChanges.has(base)) return c;
|
|
56
|
+
return foundSearchResult(c, "`mixinErrorState` no longer declares `stateChanges` as of @angular/material 14. " +
|
|
57
|
+
"Declare `readonly stateChanges = new Subject<void>()` in this class.");
|
|
58
|
+
}
|
|
59
|
+
}();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The base class name that an expression passes to `mixinErrorState`, an empty string if it passes something else, or
|
|
65
|
+
* `undefined` if the expression does not call `mixinErrorState`.
|
|
66
|
+
*/
|
|
67
|
+
function mixedInBase(expression: J, mixin: string): string | undefined {
|
|
68
|
+
if (expression.kind !== J.Kind.MethodInvocation) return undefined;
|
|
69
|
+
const call = expression as J.MethodInvocation;
|
|
70
|
+
const args = call.arguments.elements.map(a => a.element);
|
|
71
|
+
if (call.name.simpleName === mixin && !call.select) {
|
|
72
|
+
const base = args[0];
|
|
73
|
+
return base && isIdentifier(base) ? base.simpleName : '';
|
|
74
|
+
}
|
|
75
|
+
for (const arg of args) {
|
|
76
|
+
const base = mixedInBase(arg, mixin);
|
|
77
|
+
if (base !== undefined) return base;
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function declaresStateChanges(classDecl: J.ClassDeclaration): boolean {
|
|
83
|
+
return classDecl.body.statements.some(s => {
|
|
84
|
+
const member = s.element;
|
|
85
|
+
if (member.kind === J.Kind.MethodDeclaration) return (member as J.MethodDeclaration).name.simpleName === 'stateChanges';
|
|
86
|
+
if (member.kind !== J.Kind.VariableDeclarations) return false;
|
|
87
|
+
return (member as J.VariableDeclarations).variables.some(v => isIdentifier(v.element.name) && v.element.name.simpleName === 'stateChanges');
|
|
88
|
+
});
|
|
89
|
+
}
|