Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1737)

Unified Diff: pkg/analysis_server/lib/src/services/correction/sort_members.dart

Issue 1306083003: Sort top-level constants before other top-level variables. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/sort_members_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/correction/sort_members.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/sort_members.dart b/pkg/analysis_server/lib/src/services/correction/sort_members.dart
index e6acec706cc56e86c5893f345613a47de662f5e6..c27de98bc8f3e7336d1d2314b60a418f79b9874d 100644
--- a/pkg/analysis_server/lib/src/services/correction/sort_members.dart
+++ b/pkg/analysis_server/lib/src/services/correction/sort_members.dart
@@ -15,6 +15,8 @@ import 'package:analyzer/src/generated/scanner.dart';
class MemberSorter {
static List<_PriorityItem> _PRIORITY_ITEMS = [
new _PriorityItem(false, _MemberKind.UNIT_FUNCTION_MAIN, false),
+ new _PriorityItem(false, _MemberKind.UNIT_VARIABLE_CONST, false),
+ new _PriorityItem(false, _MemberKind.UNIT_VARIABLE_CONST, true),
new _PriorityItem(false, _MemberKind.UNIT_VARIABLE, false),
new _PriorityItem(false, _MemberKind.UNIT_VARIABLE, true),
new _PriorityItem(false, _MemberKind.UNIT_ACCESSOR, false),
@@ -67,7 +69,8 @@ class MemberSorter {
String suffix = code.substring(code.length - suffixLength, code.length);
int commonLength = findCommonOverlap(prefix, suffix);
suffixLength -= commonLength;
- SourceEdit edit = new SourceEdit(prefixLength,
+ SourceEdit edit = new SourceEdit(
+ prefixLength,
initialCode.length - suffixLength - prefixLength,
code.substring(prefixLength, code.length - suffixLength));
edits.add(edit);
@@ -300,7 +303,11 @@ class MemberSorter {
List<VariableDeclaration> variables =
variableDeclaration.variables.variables;
if (!variables.isEmpty) {
- kind = _MemberKind.UNIT_VARIABLE;
+ if (variableDeclaration.variables.isConst) {
+ kind = _MemberKind.UNIT_VARIABLE_CONST;
+ } else {
+ kind = _MemberKind.UNIT_VARIABLE;
+ }
name = variables[0].name.name;
}
}
@@ -443,11 +450,12 @@ class _MemberKind {
static const UNIT_FUNCTION = const _MemberKind('UNIT_FUNCTION', 2);
static const UNIT_FUNCTION_TYPE = const _MemberKind('UNIT_FUNCTION_TYPE', 3);
static const UNIT_CLASS = const _MemberKind('UNIT_CLASS', 4);
- static const UNIT_VARIABLE = const _MemberKind('UNIT_VARIABLE', 5);
- static const CLASS_ACCESSOR = const _MemberKind('CLASS_ACCESSOR', 6);
- static const CLASS_CONSTRUCTOR = const _MemberKind('CLASS_CONSTRUCTOR', 7);
- static const CLASS_FIELD = const _MemberKind('CLASS_FIELD', 8);
- static const CLASS_METHOD = const _MemberKind('CLASS_METHOD', 9);
+ static const UNIT_VARIABLE_CONST = const _MemberKind('UNIT_VARIABLE', 5);
+ static const UNIT_VARIABLE = const _MemberKind('UNIT_VARIABLE', 6);
+ static const CLASS_ACCESSOR = const _MemberKind('CLASS_ACCESSOR', 7);
+ static const CLASS_CONSTRUCTOR = const _MemberKind('CLASS_CONSTRUCTOR', 8);
+ static const CLASS_FIELD = const _MemberKind('CLASS_FIELD', 9);
+ static const CLASS_METHOD = const _MemberKind('CLASS_METHOD', 10);
final String name;
final int ordinal;
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/sort_members_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698