gmlewis / flutter-stylizer

Flutter Stylizer is a VSCode extension that organizes your Flutter classes and mixins in an opinionated and consistent manner.
https://marketplace.visualstudio.com/items?itemName=gmlewis-vscode.flutter-stylizer
Apache License 2.0
23 stars 3 forks source link

Make "properties" and "operators" first-class concepts #37

Open timshadel opened 2 years ago

timshadel commented 2 years ago

Is your feature request related to a problem? Please describe.

I really love keeping my getters and setters just below my instance variables. In the Dart Language Tour, it uses the term 'properties' for the logical concept that these getters and setters create. I like sorting the properties (matched get-set pairs) by name and within each pair I place get first, then set.

As I looked into it further, the Dart API docs reminded me that operators should also be grouped out.

Describe the solution you'd like

At the core, I want memberOrdering to reflect each of the concepts in the Dart API docs: constructors, properties, methods, and operators. Plus variables—in source we do need the option to group them.

I propose using new optional items for the memberOrdering—similar to private-other-methods. If the option is used, then that set of items is separated out from their normal area and placed in this new group.

Required Optional
public-constructor public-constructor
named-constructors named-constructors
public-static-variables public-static-variables
public-static-properties
public-instance-variables public-instance-variables
public-instance-properties
public-override-variables public-override-variables
public-override-properties
private-static-variables private-static-variables
private-static-properties
private-instance-variables private-instance-variables
private-instance-properties
public-override-methods public-override-methods
public-other-methods public-other-methods
private-other-methods
operators
build-method build-method

Describe alternatives you've considered

I've thought about flags, but they aren't powerful enough. Each API concept needs to have the full breadth of options that apply to it, so they can be moved in blocks.

Additional context

Big projects tend to have a large number of these properties in certain classes. Keeping them organized is important for all the devs to quickly understand a class.

gmlewis commented 2 years ago

Thank you for the request, @timshadel. As I've been working on implementing these changes, I'm trying to figure out how this request will interact with the already-existing groupAndSortGetterMethods variable. Maybe that option would be turned off if any of these new optional settings are found.
I'm trying to keep the options easy to understand, but as this thing keeps growing, it is getting more challenging. Still investigating...

gmlewis commented 2 years ago

@timshadel - I've got my first implementation of this proposal working locally using the standalone Go flutter-stylizer... if you are already familiar with it, then I can push my experimental version to that repo and you can try it out. https://github.com/gmlewis/go-flutter-stylizer/

Otherwise, I won't push that version but will instead work on porting the Go changes back into the TypeScript changes in the VSCode plugin so that you can try it out first there. (Significant changes like this one are much easier to develop in Go then port to TypeScript as opposed to the other way around.)

Please let me know which way you would prefer to proceed, and I'll try to accommodate your preference.