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

Side by Side Diff: pkg/analysis_server/test/domain_completion_test.dart

Issue 1867063003: show only named argument suggestions - fixes #25198, fixes #23992 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
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.domain.completion; 5 library test.domain.completion;
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/domain_completion.dart'; 10 import 'package:analysis_server/src/domain_completion.dart';
(...skipping 10 matching lines...) Expand all
21 import 'utils.dart'; 21 import 'utils.dart';
22 22
23 main() { 23 main() {
24 initializeTestEnvironment(); 24 initializeTestEnvironment();
25 defineReflectiveTests(CompletionDomainHandlerTest); 25 defineReflectiveTests(CompletionDomainHandlerTest);
26 defineReflectiveTests(_NoSearchEngine); 26 defineReflectiveTests(_NoSearchEngine);
27 } 27 }
28 28
29 @reflectiveTest 29 @reflectiveTest
30 class CompletionDomainHandlerTest extends AbstractCompletionDomainTest { 30 class CompletionDomainHandlerTest extends AbstractCompletionDomainTest {
31 test_ArgumentList_imported_function_named_param() async {
32 addTestFile('main() { int.parse("16", ^);}');
33 await getSuggestions();
34 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'radix: ',
35 relevance: DART_RELEVANCE_NAMED_PARAMETER);
36 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'onError: ',
37 relevance: DART_RELEVANCE_NAMED_PARAMETER);
38 expect(suggestions, hasLength(2));
39 }
40
41 test_ArgumentList_imported_function_named_param1() async {
42 addTestFile('main() { foo(o^);} foo({one, two}) {}');
43 await getSuggestions();
44 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'one: ',
45 relevance: DART_RELEVANCE_NAMED_PARAMETER);
46 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'two: ',
47 relevance: DART_RELEVANCE_NAMED_PARAMETER);
48 expect(suggestions, hasLength(2));
49 }
50
51 test_ArgumentList_imported_function_named_param_label1() async {
52 addTestFile('main() { int.parse("16", r^: 16);}');
53 await getSuggestions();
54 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'radix: ',
55 relevance: DART_RELEVANCE_NAMED_PARAMETER);
56 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'onError: ',
57 relevance: DART_RELEVANCE_NAMED_PARAMETER);
58 expect(suggestions, hasLength(2));
59 }
60
61 test_ArgumentList_imported_function_named_param_label3() async {
62 addTestFile('main() { int.parse("16", ^: 16);}');
63 await getSuggestions();
64 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'radix: ',
65 relevance: DART_RELEVANCE_NAMED_PARAMETER);
66 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'onError: ',
67 relevance: DART_RELEVANCE_NAMED_PARAMETER);
68 expect(suggestions, hasLength(2));
69 }
70
71 test_ArgumentList_imported_function_named_param2() async {
72 addTestFile('mainx() {A a = new A(); a.foo(one: 7, ^);}'
73 'class A { foo({one, two}) {} }');
74 await getSuggestions();
75 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'two: ',
76 relevance: DART_RELEVANCE_NAMED_PARAMETER);
77 expect(suggestions, hasLength(1));
78 }
79
31 test_html() { 80 test_html() {
32 testFile = '/project/web/test.html'; 81 testFile = '/project/web/test.html';
33 addTestFile(''' 82 addTestFile('''
34 <html>^</html> 83 <html>^</html>
35 '''); 84 ''');
36 return getSuggestions().then((_) { 85 return getSuggestions().then((_) {
37 expect(replacementOffset, equals(completionOffset)); 86 expect(replacementOffset, equals(completionOffset));
38 expect(replacementLength, equals(0)); 87 expect(replacementLength, equals(0));
39 expect(suggestions, hasLength(0)); 88 expect(suggestions, hasLength(0));
40 }); 89 });
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 606 }
558 '''); 607 ''');
559 await waitForTasksFinished(); 608 await waitForTasksFinished();
560 Request request = 609 Request request =
561 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); 610 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0');
562 Response response = handler.handleRequest(request); 611 Response response = handler.handleRequest(request);
563 expect(response.error, isNotNull); 612 expect(response.error, isNotNull);
564 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); 613 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED);
565 } 614 }
566 } 615 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698