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

Side by Side Diff: pkg/analysis_server/test/services/completion/imported_computer_test.dart

Issue 972933002: add arguments to constructor completions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix tests Created 5 years, 9 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 | Annotate | Revision Log
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.services.completion.toplevel; 5 library test.services.completion.toplevel;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 8 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
9 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt'; 9 import 'package:analysis_server/src/services/completion/dart_completion_cache.da rt';
10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 DartCompletionCache cache = request.cache; 93 DartCompletionCache cache = request.cache;
94 if (isCached(cache.importedTypeSuggestions, completion) || 94 if (isCached(cache.importedTypeSuggestions, completion) ||
95 isCached(cache.importedVoidReturnSuggestions, completion) || 95 isCached(cache.importedVoidReturnSuggestions, completion) ||
96 isCached(cache.libraryPrefixSuggestions, completion) || 96 isCached(cache.libraryPrefixSuggestions, completion) ||
97 isCached(cache.otherImportedSuggestions, completion)) { 97 isCached(cache.otherImportedSuggestions, completion)) {
98 fail('expected $completion NOT to be cached'); 98 fail('expected $completion NOT to be cached');
99 } 99 }
100 } 100 }
101 101
102 @override 102 @override
103 CompletionSuggestion assertSuggestImportedConstructor(String name) {
104 return assertSuggestConstructor(name);
105 }
106
107 @override
103 CompletionSuggestion assertSuggestImportedField(String name, String type, 108 CompletionSuggestion assertSuggestImportedField(String name, String type,
104 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) { 109 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) {
105 return assertSuggestField(name, type, relevance: relevance); 110 return assertSuggestField(name, type, relevance: relevance);
106 } 111 }
107 112
108 CompletionSuggestion assertSuggestImportedGetter( 113 CompletionSuggestion assertSuggestImportedGetter(
109 String name, String returnType, 114 String name, String returnType,
110 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) { 115 {int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) {
111 return assertSuggestGetter(name, returnType, relevance: relevance); 116 return assertSuggestGetter(name, returnType, relevance: relevance);
112 } 117 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 expect(suggestion.parameterNames, hasLength(2)); 345 expect(suggestion.parameterNames, hasLength(2));
341 expect(suggestion.parameterNames[0], 'x'); 346 expect(suggestion.parameterNames[0], 'x');
342 expect(suggestion.parameterTypes[0], 'dynamic'); 347 expect(suggestion.parameterTypes[0], 'dynamic');
343 expect(suggestion.parameterNames[1], 'y'); 348 expect(suggestion.parameterNames[1], 'y');
344 expect(suggestion.parameterTypes[1], 'int'); 349 expect(suggestion.parameterTypes[1], 'int');
345 expect(suggestion.requiredParameterCount, 2); 350 expect(suggestion.requiredParameterCount, 2);
346 expect(suggestion.hasNamedParameters, false); 351 expect(suggestion.hasNamedParameters, false);
347 }); 352 });
348 } 353 }
349 354
355 test_InstanceCreationExpression() {
356 addSource('/testA.dart', '''
357 class A {foo(){var f; {var x;}}}
358 class B {B(this.x, [String boo]) { } int x;}
359 class C {C.bar({boo: 'hoo', int z: 0}) { } }''');
360 addTestSource('''
361 import "/testA.dart";
362 main() {new ^ String x = "hello";}''');
363 computeFast();
364 return computeFull((bool result) {
365 CompletionSuggestion suggestion;
366
367 suggestion = assertSuggestImportedConstructor('Object');
368 expect(suggestion.element.parameters, '()');
369 expect(suggestion.parameterNames, hasLength(0));
370 expect(suggestion.requiredParameterCount, 0);
371 expect(suggestion.hasNamedParameters, false);
372
373 suggestion = assertSuggestImportedConstructor('A');
374 expect(suggestion.element.parameters, '()');
375 expect(suggestion.parameterNames, hasLength(0));
376 expect(suggestion.requiredParameterCount, 0);
377 expect(suggestion.hasNamedParameters, false);
378
379 suggestion = assertSuggestImportedConstructor('B');
380 expect(suggestion.element.parameters, '(int x, [String boo])');
381 expect(suggestion.parameterNames, hasLength(2));
382 expect(suggestion.parameterNames[0], 'x');
383 expect(suggestion.parameterTypes[0], 'int');
384 expect(suggestion.parameterNames[1], 'boo');
385 expect(suggestion.parameterTypes[1], 'String');
386 expect(suggestion.requiredParameterCount, 1);
387 expect(suggestion.hasNamedParameters, false);
388
389 suggestion = assertSuggestImportedConstructor('C.bar');
390 expect(
391 suggestion.element.parameters, "({dynamic boo: 'hoo'}, {int z: 0})");
392 expect(suggestion.parameterNames, hasLength(2));
393 expect(suggestion.parameterNames[0], 'boo');
394 expect(suggestion.parameterTypes[0], 'dynamic');
395 expect(suggestion.parameterNames[1], 'z');
396 expect(suggestion.parameterTypes[1], 'int');
397 expect(suggestion.requiredParameterCount, 0);
398 expect(suggestion.hasNamedParameters, true);
399 });
400 }
401
350 test_method_parameters_mixed_required_and_named() { 402 test_method_parameters_mixed_required_and_named() {
351 addSource('/libA.dart', ''' 403 addSource('/libA.dart', '''
352 class A { 404 class A {
353 void m(x, {int y}) {} 405 void m(x, {int y}) {}
354 } 406 }
355 '''); 407 ''');
356 addTestSource(''' 408 addTestSource('''
357 import '/libA.dart'; 409 import '/libA.dart';
358 class B extends A { 410 class B extends A {
359 main() {^} 411 main() {^}
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 682 }
631 683
632 @override 684 @override
633 test_partFile_TypeName2() { 685 test_partFile_TypeName2() {
634 return super.test_partFile_TypeName2().then((_) { 686 return super.test_partFile_TypeName2().then((_) {
635 expect(request.cache.importKey, 687 expect(request.cache.importKey,
636 'library libA;import "/testB.dart";part "/testA.dart";'); 688 'library libA;import "/testB.dart";part "/testA.dart";');
637 }); 689 });
638 } 690 }
639 } 691 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698