Skip to content
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

[dart fix] inEnum does not apply transform #54188

Closed
Piinks opened this issue Nov 29, 2023 · 4 comments
Closed

[dart fix] inEnum does not apply transform #54188

Piinks opened this issue Nov 29, 2023 · 4 comments
Labels
analyzer-data-driven-fixes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on

Comments

@Piinks
Copy link
Contributor

Piinks commented Nov 29, 2023

I want to rename a deprecated enum value in flutter/flutter#139257

For example:

enum WidgetInspectorServiceExtensions {
  @Deprecated(use add instead)
  setPubRootDirectories,
  addPubRootDirectories,
  // ...
}

I wrote the following rule to try to rename uses of the deprecated enum:

  - title: "Use WidgetServiceExtensions.addPubRootDirectories"
    date: 2023-11-29
    element:
      uris: ['widgets.dart', 'material.dart', 'cupertino.dart']
      enum: 'setPubRootDirectories' # also tried constant?
      inEnum: 'WidgetInspectorServiceExtensions'
    changes:
    - kind: 'rename'
      newName: 'addPubRootDirectories'

The transformation I expected in the test was:

// Before
WidgetInspectorServiceExtensions.setPubRootDirectories;

// After
WidgetInspectorServiceExtensions.addPubRootDirectories;

But nothing happened.
This is the first inEnum fix for the framework, so there could be a bug?
The docs mention enum or constant for the element when using inEnum, neither of those worked. I tried field as well for good measure.

@bwilkerson bwilkerson added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on analyzer-data-driven-fixes labels Nov 29, 2023
@keertip
Copy link
Contributor

keertip commented Nov 29, 2023

As this is the first rename for an enum value, it could be bug, that is does not work. Will take a look.

@bwilkerson
Copy link
Member

It sounds like it's either a bug or a missing bit of functionality.

It should definitely be constant, based on the docs, though if it isn't working we could just change it to field given that enum's can now have other fields, and it would be less syntax to document, implement, and remember. Using enum would mean the whole enum (WidgetInspectorServiceExtensions in your example).

@keertip
Copy link
Contributor

keertip commented Dec 13, 2023

@Piinks , if i use constant to specify the enum value, the transform works, at least as a test - https://dart-review.googlesource.com/c/sdk/+/341389. Yet to try running dart fix, will check that out.

copybara-service bot pushed a commit that referenced this issue Dec 13, 2023
#54188

Change-Id: I3c436a4055f0d99c9c7a00e852e16a798f14aeba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341389
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
@Piinks
Copy link
Contributor Author

Piinks commented Dec 13, 2023

Ah fabulous! I just tried that at tip of tree and it worked! Thanks @keertip!

@Piinks Piinks closed this as completed Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-data-driven-fixes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

3 participants