OLD | NEW |
---|---|
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.util; | 5 library test.services.completion.util; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
10 import 'package:analysis_server/src/protocol.dart' as protocol | 10 import 'package:analysis_server/src/protocol.dart' as protocol |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 void addTestSource(String content) { | 58 void addTestSource(String content) { |
59 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once'); | 59 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once'); |
60 completionOffset = content.indexOf('^'); | 60 completionOffset = content.indexOf('^'); |
61 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); | 61 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); |
62 int nextOffset = content.indexOf('^', completionOffset + 1); | 62 int nextOffset = content.indexOf('^', completionOffset + 1); |
63 expect(nextOffset, equals(-1), reason: 'too many ^'); | 63 expect(nextOffset, equals(-1), reason: 'too many ^'); |
64 content = content.substring(0, completionOffset) + | 64 content = content.substring(0, completionOffset) + |
65 content.substring(completionOffset + 1); | 65 content.substring(completionOffset + 1); |
66 testSource = addSource(testFile, content); | 66 testSource = addSource(testFile, content); |
67 cache = new DartCompletionCache(context, testSource); | 67 cache = new DartCompletionCache(context, testSource); |
68 AnalysisServer server = new AnalysisServerMock(searchEngine: searchEngine, r esourceProvider: provider); | 68 AnalysisServer server = new AnalysisServerMock( |
69 searchEngine: searchEngine, resourceProvider: provider); | |
69 request = new DartCompletionRequest( | 70 request = new DartCompletionRequest( |
70 server, context, testSource, completionOffset, cache); | 71 server, context, testSource, completionOffset, cache); |
71 } | 72 } |
72 | 73 |
73 void assertHasNoParameterInfo(CompletionSuggestion suggestion) { | 74 void assertHasNoParameterInfo(CompletionSuggestion suggestion) { |
74 expect(suggestion.parameterNames, isNull); | 75 expect(suggestion.parameterNames, isNull); |
75 expect(suggestion.parameterTypes, isNull); | 76 expect(suggestion.parameterTypes, isNull); |
76 expect(suggestion.requiredParameterCount, isNull); | 77 expect(suggestion.requiredParameterCount, isNull); |
77 expect(suggestion.hasNamedParameters, isNull); | 78 expect(suggestion.hasNamedParameters, isNull); |
78 } | 79 } |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest { | 546 abstract class AbstractSelectorSuggestionTest extends AbstractCompletionTest { |
546 | 547 |
547 /** | 548 /** |
548 * Assert that the ImportedReferenceContributor uses cached results | 549 * Assert that the ImportedReferenceContributor uses cached results |
549 * to produce identical suggestions to the original set of suggestions. | 550 * to produce identical suggestions to the original set of suggestions. |
550 */ | 551 */ |
551 void assertCachedCompute(_) { | 552 void assertCachedCompute(_) { |
552 // Subclasses override | 553 // Subclasses override |
553 } | 554 } |
554 | 555 |
556 CompletionSuggestion assertSuggestEnum(String completion, | |
557 {bool isDeprecated: false}) { | |
558 CompletionSuggestion suggestion = | |
559 assertSuggest(completion, isDeprecated: isDeprecated); | |
560 expect(suggestion.isDeprecated, isDeprecated); | |
561 expect(suggestion.element.kind, protocol.ElementKind.ENUM); | |
562 return suggestion; | |
563 } | |
564 | |
565 CompletionSuggestion assertSuggestEnumConst(String completion, | |
566 {bool isDeprecated: false}) { | |
567 CompletionSuggestion suggestion = | |
568 assertSuggest(completion, isDeprecated: isDeprecated); | |
569 expect(suggestion.isDeprecated, isDeprecated); | |
570 // TODO(danrubel) : Perhaps should be protocol.ElementKind.ENUM_CONST | |
571 // but element model represents them as FIELD | |
572 expect(suggestion.element.kind, protocol.ElementKind.FIELD); | |
Paul Berry
2015/05/29 17:55:57
Should this be protocol.ElementKind.ENUM_CONSTANT
danrubel
2015/06/01 04:26:56
Yes. See comment above code. Need to investigate w
Paul Berry
2015/06/01 12:45:59
Oops. Not sure how I missed the comment. Thanks!
danrubel
2015/06/04 21:48:14
https://codereview.chromium.org/1157283004/
| |
573 return suggestion; | |
574 } | |
575 | |
555 CompletionSuggestion assertSuggestImportedClass(String name, | 576 CompletionSuggestion assertSuggestImportedClass(String name, |
556 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 577 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
557 int relevance: DART_RELEVANCE_DEFAULT, String importUri}) { | 578 int relevance: DART_RELEVANCE_DEFAULT, String importUri}) { |
558 return assertNotSuggested(name); | 579 return assertNotSuggested(name); |
559 } | 580 } |
560 | 581 |
561 CompletionSuggestion assertSuggestImportedConstructor(String name, | 582 CompletionSuggestion assertSuggestImportedConstructor(String name, |
562 {int relevance: DART_RELEVANCE_DEFAULT, String importUri}) { | 583 {int relevance: DART_RELEVANCE_DEFAULT, String importUri}) { |
563 return assertNotSuggested(name); | 584 return assertNotSuggested(name); |
564 } | 585 } |
(...skipping 3781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4346 assertNotSuggested('bar2'); | 4367 assertNotSuggested('bar2'); |
4347 assertNotSuggested('_B'); | 4368 assertNotSuggested('_B'); |
4348 assertSuggestLocalClass('Y'); | 4369 assertSuggestLocalClass('Y'); |
4349 assertSuggestLocalClass('C'); | 4370 assertSuggestLocalClass('C'); |
4350 assertSuggestLocalVariable('f', null); | 4371 assertSuggestLocalVariable('f', null); |
4351 assertNotSuggested('x'); | 4372 assertNotSuggested('x'); |
4352 assertNotSuggested('e'); | 4373 assertNotSuggested('e'); |
4353 }); | 4374 }); |
4354 } | 4375 } |
4355 } | 4376 } |
OLD | NEW |