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

Unified Diff: pkg/analysis_server/test/services/completion/imported_computer_test.dart

Issue 977223003: When target requires a function, propose a function reference, not an invocation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and remove unnecessary statement Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/services/completion/imported_computer_test.dart
diff --git a/pkg/analysis_server/test/services/completion/imported_computer_test.dart b/pkg/analysis_server/test/services/completion/imported_computer_test.dart
index 98a10b54a850c896f2c2472a442c69680a50b657..51870d09e13833848eb71a9adce486fac769c392 100644
--- a/pkg/analysis_server/test/services/completion/imported_computer_test.dart
+++ b/pkg/analysis_server/test/services/completion/imported_computer_test.dart
@@ -43,9 +43,9 @@ class ImportedComputerTest extends AbstractSelectorSuggestionTest {
* suggestions to the original set of suggestions.
*/
@override
- void assertCachedCompute(_) {
+ assertCachedCompute(_) {
if (!(computer as ImportedComputer).shouldWaitForLowPrioritySuggestions) {
- return;
+ return null;
}
expect(request.unit.element, isNotNull);
List<CompletionSuggestion> oldSuggestions = request.suggestions;
@@ -65,30 +65,45 @@ class ImportedComputerTest extends AbstractSelectorSuggestionTest {
completionOffset, cache, new CompletionPerformance());
request.replacementOffset = replacementOffset;
request.replacementLength = replacementLength;
- expect(computeFast(), isTrue);
- expect(request.unit.element, isNull);
- List<CompletionSuggestion> newSuggestions = request.suggestions;
- if (newSuggestions.length == oldSuggestions.length) {
- if (!oldSuggestions
- .any((CompletionSuggestion s) => !newSuggestions.contains(s))) {
- return;
+
+ void assertResultsFromCache(List<CompletionSuggestion> oldSuggestions) {
+ List<CompletionSuggestion> newSuggestions = request.suggestions;
+ if (newSuggestions.length == oldSuggestions.length) {
+ if (!oldSuggestions
+ .any((CompletionSuggestion s) => !newSuggestions.contains(s))) {
+ return;
+ }
}
+ StringBuffer sb = new StringBuffer(
+ 'suggestions based upon cached results do not match expectations');
+ sb.write('\n Expected:');
+ oldSuggestions.toList()
+ ..sort(suggestionComparator)
+ ..forEach((CompletionSuggestion suggestion) {
+ sb.write('\n ${suggestion.completion} -> $suggestion');
+ });
+ sb.write('\n Actual:');
+ newSuggestions.toList()
+ ..sort(suggestionComparator)
+ ..forEach((CompletionSuggestion suggestion) {
+ sb.write('\n ${suggestion.completion} -> $suggestion');
+ });
+ fail(sb.toString());
}
- StringBuffer sb = new StringBuffer(
- 'suggestions based upon cached results do not match expectations');
- sb.write('\n Expected:');
- oldSuggestions.toList()
- ..sort(suggestionComparator)
- ..forEach((CompletionSuggestion suggestion) {
- sb.write('\n ${suggestion.completion} -> $suggestion');
- });
- sb.write('\n Actual:');
- newSuggestions.toList()
- ..sort(suggestionComparator)
- ..forEach((CompletionSuggestion suggestion) {
- sb.write('\n ${suggestion.completion} -> $suggestion');
+
+ if (computeFast()) {
+ expect(request.unit.element, isNull);
+ assertResultsFromCache(oldSuggestions);
+ } else {
+ // Results from cache might need to be adjusted
+ // if target is a function argument in an argument list
+ resolve(false);
+ return computer.computeFull(request).then((bool result) {
+ expect(result, isTrue);
+ expect(request.unit.element, isNotNull);
+ assertResultsFromCache(oldSuggestions);
});
- fail(sb.toString());
+ }
}
void assertNotCached(String completion) {
@@ -112,6 +127,15 @@ class ImportedComputerTest extends AbstractSelectorSuggestionTest {
return assertSuggestField(name, type, relevance: relevance);
}
+ @override
+ CompletionSuggestion assertSuggestImportedFunction(
+ String name, String returnType,
+ {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
+ bool deprecated: false, int relevance: DART_RELEVANCE_DEFAULT}) {
+ return assertSuggestFunction(name, returnType,
+ kind: kind, deprecated: deprecated, relevance: relevance);
+ }
+
CompletionSuggestion assertSuggestImportedGetter(
String name, String returnType,
{int relevance: DART_RELEVANCE_INHERITED_ACCESSOR}) {

Powered by Google App Engine
This is Rietveld 408576698