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

Side by Side Diff: pkg/analysis_server/test/edit/sort_members_test.dart

Issue 1938023002: Keep directive annotations while sorting. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/sort_members.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.edit.sort_members; 5 library test.edit.sort_members;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/edit/edit_domain.dart'; 10 import 'package:analysis_server/src/edit/edit_domain.dart';
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 export 'bbb/bbb.dart'; 137 export 'bbb/bbb.dart';
138 138
139 part 'aaa/aaa.dart'; 139 part 'aaa/aaa.dart';
140 part 'bbb/bbb.dart'; 140 part 'bbb/bbb.dart';
141 141
142 main() { 142 main() {
143 } 143 }
144 '''); 144 ''');
145 } 145 }
146 146
147 test_OK_directives_withAnnotation() async {
148 addTestFile('''
149 library lib;
150
151 export 'dart:bbb';
152 @MyAnnotation(1)
153 @MyAnnotation(2)
154 import 'dart:bbb';
155 @MyAnnotation(3)
156 export 'dart:aaa';
157 import 'dart:aaa';
158
159 class MyAnnotation {
160 const MyAnnotation(_);
161 }
162 ''');
163 return _assertSorted(r'''
164 library lib;
165
166 import 'dart:aaa';
167 @MyAnnotation(1)
168 @MyAnnotation(2)
169 import 'dart:bbb';
170
171 @MyAnnotation(3)
172 export 'dart:aaa';
173 export 'dart:bbb';
174
175 class MyAnnotation {
176 const MyAnnotation(_);
177 }
178 ''');
179 }
180
147 test_OK_unitMembers_class() async { 181 test_OK_unitMembers_class() async {
148 addTestFile(''' 182 addTestFile('''
149 class C {} 183 class C {}
150 class A {} 184 class A {}
151 class B {} 185 class B {}
152 '''); 186 ''');
153 return _assertSorted(r''' 187 return _assertSorted(r'''
154 class A {} 188 class A {}
155 class B {} 189 class B {}
156 class C {} 190 class C {}
157 '''); 191 ''');
158 } 192 }
159 193
160 Future _assertSorted(String expectedCode) async { 194 Future _assertSorted(String expectedCode) async {
161 _requestSort(); 195 _requestSort();
162 String resultCode = SourceEdit.applySequence(testCode, fileEdit.edits); 196 String resultCode = SourceEdit.applySequence(testCode, fileEdit.edits);
163 expect(resultCode, expectedCode); 197 expect(resultCode, expectedCode);
164 } 198 }
165 199
166 void _requestSort() { 200 void _requestSort() {
167 Request request = new EditSortMembersParams(testFile).toRequest('0'); 201 Request request = new EditSortMembersParams(testFile).toRequest('0');
168 Response response = handleSuccessfulRequest(request); 202 Response response = handleSuccessfulRequest(request);
169 var result = new EditSortMembersResult.fromResponse(response); 203 var result = new EditSortMembersResult.fromResponse(response);
170 fileEdit = result.edit; 204 fileEdit = result.edit;
171 } 205 }
172 } 206 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/sort_members.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698