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

Side by Side Diff: pkg/analysis_server/test/analysis/notification_navigation_test.dart

Issue 1378713004: Issue 24487. Annotations with constructor resolution should produce navigation reginos to construct… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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/domains/analysis/navigation_dart.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.analysis.notification.navigation; 5 library test.analysis.notification.navigation;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/constants.dart'; 9 import 'package:analysis_server/src/constants.dart';
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 class AAA {} 208 class AAA {}
209 AAA aaa; 209 AAA aaa;
210 '''); 210 ''');
211 return waitForTasksFinished().then((_) { 211 return waitForTasksFinished().then((_) {
212 return prepareNavigation().then((_) { 212 return prepareNavigation().then((_) {
213 assertHasRegionTarget('AAA aaa;', 'AAA {}'); 213 assertHasRegionTarget('AAA aaa;', 'AAA {}');
214 }); 214 });
215 }); 215 });
216 } 216 }
217 217
218 test_annotationConstructor_implicit() async {
219 addTestFile('''
220 class A {
221 }
222 @A()
223 main() {
224 }
225 ''');
226 await prepareNavigation();
227 assertHasRegionString('A()', 'A'.length);
228 assertHasTarget('A {');
229 }
230
231 test_annotationConstructor_importPrefix() async {
232 addFile(
233 '$testFolder/my_annotation.dart',
234 r'''
235 library an;
236 class MyAnnotation {
237 const MyAnnotation();
238 const MyAnnotation.named();
239 }
240 ''');
241 addTestFile('''
242 import 'my_annotation.dart' as man;
243 @man.MyAnnotation()
244 @man.MyAnnotation.named()
245 main() {
246 }
247 ''');
248 await prepareNavigation();
249 assertHasRegion('MyAnnotation()');
250 assertHasRegion('MyAnnotation.named()');
251 assertHasRegion('named()');
252 {
253 assertHasRegion('man.MyAnnotation()');
254 assertHasTarget('man;');
255 }
256 {
257 assertHasRegion('man.MyAnnotation.named()');
258 assertHasTarget('man;');
259 }
260 }
261
262 test_annotationConstructor_named() async {
263 addTestFile('''
264 class A {
265 const A.named(p);
266 }
267 @A.named(0)
268 main() {
269 }
270 ''');
271 await prepareNavigation();
272 {
273 assertHasRegion('A.named(0)');
274 assertHasTarget('named(p);');
275 }
276 {
277 assertHasRegion('named(0)');
278 assertHasTarget('named(p);');
279 }
280 }
281
282 test_annotationConstructor_unnamed() async {
283 addTestFile('''
284 class A {
285 const A();
286 }
287 @A()
288 main() {
289 }
290 ''');
291 await prepareNavigation();
292 assertHasRegionString('A()', 'A'.length);
293 assertHasTarget('A();', 0);
294 }
295
296 test_annotationField() async {
297 addTestFile('''
298 const myan = new Object();
299 @myan // ref
300 main() {
301 }
302 ''');
303 await prepareNavigation();
304 assertHasRegion('myan // ref');
305 assertHasTarget('myan = new Object();');
306 }
307
308 test_annotationField_importPrefix() async {
309 addFile(
310 '$testFolder/mayn.dart',
311 r'''
312 library an;
313 const myan = new Object();
314 ''');
315 addTestFile('''
316 import 'mayn.dart' as man;
317 @man.myan // ref
318 main() {
319 }
320 ''');
321 await prepareNavigation();
322 assertHasRegion('myan // ref');
323 }
324
218 test_class_fromSDK() { 325 test_class_fromSDK() {
219 addTestFile(''' 326 addTestFile('''
220 int V = 42; 327 int V = 42;
221 '''); 328 ''');
222 return prepareNavigation().then((_) { 329 return prepareNavigation().then((_) {
223 assertHasRegion('int V'); 330 assertHasRegion('int V');
224 int targetIndex = testTargetIndexes[0]; 331 int targetIndex = testTargetIndexes[0];
225 NavigationTarget target = targets[targetIndex]; 332 NavigationTarget target = targets[targetIndex];
226 expect(target.startLine, greaterThan(0)); 333 expect(target.startLine, greaterThan(0));
227 expect(target.startColumn, greaterThan(0)); 334 expect(target.startColumn, greaterThan(0));
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 test_type_void() { 924 test_type_void() {
818 addTestFile(''' 925 addTestFile('''
819 void main() { 926 void main() {
820 } 927 }
821 '''); 928 ''');
822 return prepareNavigation().then((_) { 929 return prepareNavigation().then((_) {
823 assertNoRegionAt('void'); 930 assertNoRegionAt('void');
824 }); 931 });
825 } 932 }
826 } 933 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698