The order of 'Encapsulate field' loses dartdocs.
See original GitHub issueCurrently when using Encapsulate field, the order of the generated values is private var, getter, setter.
It would make more sense to have the generated order be: getter, private var, then setter, instead of having the private var come first: if you had dartdoc documentation on the original var, then it will get lost when encapsulating, since dartdoc will now think the ///
comment is on the private field.
For example, starting with:
/// Counts the foos in a bar.
int foo;
and you run “Encapsulate field” on foo
, then you get:
/// Counts the foos in a bar.
int _foo;
int get foo => _foo;
set foo(int foo) {
_foo = foo;
}
Which means that dartdoc loses the original documentation, because it now sees that as attached to the private var, and not the getter, and so it needs to be moved manually.
It should generate it like this to retain the docs:
/// Counts the foos in a bar.
int get foo => _foo;
int _foo;
set foo(int foo) {
_foo = foo;
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Effective Dart: Usage
If a field doesn't depend on any constructor parameters, it can and should be initialized at its declaration. It takes less code and...
Read more >Encapsulate Fields | IntelliJ IDEA Documentation - JetBrains
The Encapsulate Fields refactoring lets you hide your data and create the necessary accessors. Hiding your data and accessing it through an outward ......
Read more >dartdoc 0.36.2 | Dart Package - Pub.dev
A non-interactive HTML documentation generator for Dart source code.
Read more >CHANGELOG.md
#3220; Make ModelElement.element a getter; subclasses provide the field. ... BREAKING CHANGE: Many breaking changes to dartdoc API, as part of the broad ......
Read more >Intro to encapsulation and decapsulation in networking
Encapsulation and decapsulation in networking are foundational concepts in data transfer. Learn how they work with the layers of the OSI and TCP/IP...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, I see. Of course Flutter has a bit different code style.
Hm… Honestly I’m not sure what to do here. This is not what most of the other code does.
We could go the way of making a lot of code style settings, somewhere in
analysis_options.yaml
- order of declarations, adding type for extracted locals, add or omitnew
keyword. Support for settings costs something, but if it is important, we could do this. @devoncarew @bwilkersonWell, it sure would be useful to have these actions be configurable. If you had those options, then you could also do something along the line of “Sort class members”, but have it apply the ordering in the options instead of sorting alphabetically.