Add initial documentation for sort members
Change-Id: I2f097d0f9eab08679dfa7660a698ea8dc1775cf4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507461 Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# Sort members
|
||||
|
||||
The sort members command is used to sort both top-level and member declarations.
|
||||
|
||||
The sort order is based on four criteria:
|
||||
|
||||
- The kind of the declaration.
|
||||
- Whether the declaration is static.
|
||||
- The visibility of the declaration.
|
||||
- The name of the declaration.
|
||||
|
||||
The order of the kinds is influenced by the `sort_constructors_first` lint. When
|
||||
the lint is enabled, constructors will be sorted before other members. When the
|
||||
lint isn't enabled, fields will be sorted first, with constructors following.
|
||||
|
||||
## Field declarations
|
||||
|
||||
When a field declaration declares more than one field, for sorting purposes, the
|
||||
name of the first field is used. For example, given the field declaration
|
||||
|
||||
```dart
|
||||
int x, y, z;
|
||||
```
|
||||
|
||||
The declaration will be sorted using the name `x`.
|
||||
|
||||
## Primary constructor bodies
|
||||
|
||||
A primary constructor body is placed in its own group, and that group always
|
||||
sorts immediately before secondary constructors.
|
||||
Reference in New Issue
Block a user