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

Side by Side Diff: pkg/analysis_services/test/completion/completion_test_util.dart

Issue 459853003: remove duplicate suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix suggestion notification processing in test Created 6 years, 4 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.util; 5 library test.services.completion.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_services/completion/completion_computer.dart'; 9 import 'package:analysis_services/completion/completion_computer.dart';
10 import 'package:analysis_services/completion/completion_suggestion.dart'; 10 import 'package:analysis_services/completion/completion_suggestion.dart';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 void assertNotSuggested(String completion) { 49 void assertNotSuggested(String completion) {
50 if (suggestions.any((cs) => cs.completion == completion)) { 50 if (suggestions.any((cs) => cs.completion == completion)) {
51 fail('did not expect completion: $completion'); 51 fail('did not expect completion: $completion');
52 } 52 }
53 } 53 }
54 54
55 void assertSuggest(CompletionSuggestionKind kind, String completion, 55 void assertSuggest(CompletionSuggestionKind kind, String completion,
56 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, bool isDepre cated 56 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, bool isDepre cated
57 = false, bool isPotential = false]) { 57 = false, bool isPotential = false]) {
58 var cs = 58 var cs;
59 suggestions.firstWhere((cs) => cs.completion == completion, orElse: () { 59 suggestions.forEach((s) {
60 if (s.completion == completion) {
61 if (cs == null) {
62 cs = s;
63 } else {
64 fail('expected exactly one $completion but found > 1');
65 }
66 }
67 });
68 if (cs == null) {
60 var completions = suggestions.map((s) => s.completion).toList(); 69 var completions = suggestions.map((s) => s.completion).toList();
61 fail('expected "$completion" but found\n $completions'); 70 fail('expected "$completion" but found\n $completions');
62 }); 71 }
63 expect(cs.kind, equals(kind)); 72 expect(cs.kind, equals(kind));
64 expect(cs.relevance, equals(relevance)); 73 expect(cs.relevance, equals(relevance));
65 expect(cs.selectionOffset, equals(completion.length)); 74 expect(cs.selectionOffset, equals(completion.length));
66 expect(cs.selectionLength, equals(0)); 75 expect(cs.selectionLength, equals(0));
67 expect(cs.isDeprecated, equals(isDeprecated)); 76 expect(cs.isDeprecated, equals(isDeprecated));
68 expect(cs.isPotential, equals(isPotential)); 77 expect(cs.isPotential, equals(isPotential));
69 } 78 }
70 79
71 void assertSuggestClass(String className, [CompletionRelevance relevance = 80 void assertSuggestClass(String className, [CompletionRelevance relevance =
72 CompletionRelevance.DEFAULT]) { 81 CompletionRelevance.DEFAULT]) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 157 }
149 158
150 @override 159 @override
151 void setUp() { 160 void setUp() {
152 super.setUp(); 161 super.setUp();
153 index = createLocalMemoryIndex(); 162 index = createLocalMemoryIndex();
154 searchEngine = new SearchEngineImpl(index); 163 searchEngine = new SearchEngineImpl(index);
155 addResolvedUnit(MockSdk.LIB_CORE.path, MockSdk.LIB_CORE.content); 164 addResolvedUnit(MockSdk.LIB_CORE.path, MockSdk.LIB_CORE.content);
156 } 165 }
157 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698