stefanhk31 / dart-class-name-updater

0 stars 0 forks source link

Update from File Explorer, validate before changing objects #16

Open markclemons opened 1 year ago

markclemons commented 1 year ago

Using the file explorer context menu to ask the user to rename the class we blindly assume there is only one class in the file. if we have multiple objects in a file we should consider asking the user if they want to rename each object in the file... consider the following file:

my_class.dart

enum Helper { someValue }

class MyClass { }

mixin MyMixin { }

The current behavior is to replace the first instance we encounter, in this case the enum, that means the file name changes to the new enum name, when really we had the file named for the class.

markclemons commented 1 year ago

another option is to disable the file explorer context menu option and only allow refactoring from the open file by right clicking on the object we want to refactor.

markclemons commented 1 year ago

@stefanhk31 what do you think we should do?

stefanhk31 commented 1 year ago

@markclemons I kind of like the idea of refactoring by right clicking on the object, but we'd have to figure out what object(s) in a file trigger this option's availability. If there's a good way to do that, I'm all ears.

stefanhk31 commented 1 year ago

@markclemons after looking into this, I think this is the workflow we should go for:

  1. User selects rename in context menu
  2. Prompt shows up with all possible class (+ enum etc, eventually) names found in the file
  3. User selects which name they want to change
  4. User enters new name
  5. Everything gets renamed

I could be talked into a confirmation prompt between 4 &5 (something like "Renaming 'Widget' to 'NewWidget'. Proceed?")