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

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

Issue 461063002: add keyword suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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.domain.completion; 5 library test.domain.completion;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/constants.dart'; 9 import 'package:analysis_server/src/constants.dart';
10 import 'package:analysis_server/src/domain_completion.dart'; 10 import 'package:analysis_server/src/domain_completion.dart';
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return getSuggestions().then((_) { 158 return getSuggestions().then((_) {
159 expect(replacementOffset, equals(completionOffset)); 159 expect(replacementOffset, equals(completionOffset));
160 expect(replacementLength, equals(0)); 160 expect(replacementLength, equals(0));
161 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); 161 assertHasResult(CompletionSuggestionKind.CLASS, 'Object');
162 assertHasResult(CompletionSuggestionKind.LIBRARY_PREFIX, 'foo'); 162 assertHasResult(CompletionSuggestionKind.LIBRARY_PREFIX, 'foo');
163 assertNoResult('HtmlElement'); 163 assertNoResult('HtmlElement');
164 assertNoResult('test'); 164 assertNoResult('test');
165 }); 165 });
166 } 166 }
167 167
168 test_keyword() {
169 addTestFile('^');
170 return getSuggestions().then((_) {
171 expect(replacementOffset, equals(completionOffset));
172 expect(replacementLength, equals(0));
173 assertHasResult(CompletionSuggestionKind.KEYWORD, 'library');
174 assertHasResult(CompletionSuggestionKind.KEYWORD, 'import');
175 assertHasResult(CompletionSuggestionKind.KEYWORD, 'class');
176 });
177 }
178
168 test_locals() { 179 test_locals() {
169 addTestFile('class A {var a; x() {var b;^}}'); 180 addTestFile('class A {var a; x() {var b;^}}');
170 return getSuggestions().then((_) { 181 return getSuggestions().then((_) {
171 expect(replacementOffset, equals(completionOffset)); 182 expect(replacementOffset, equals(completionOffset));
172 expect(replacementLength, equals(0)); 183 expect(replacementLength, equals(0));
173 assertHasResult(CompletionSuggestionKind.CLASS, 'A'); 184 assertHasResult(CompletionSuggestionKind.CLASS, 'A');
174 assertHasResult(CompletionSuggestionKind.FIELD, 'a'); 185 assertHasResult(CompletionSuggestionKind.FIELD, 'a');
175 assertHasResult(CompletionSuggestionKind.LOCAL_VARIABLE, 'b'); 186 assertHasResult(CompletionSuggestionKind.LOCAL_VARIABLE, 'b');
176 assertHasResult(CompletionSuggestionKind.METHOD_NAME, 'x'); 187 assertHasResult(CompletionSuggestionKind.METHOD_NAME, 'x');
177 }); 188 });
178 } 189 }
179 190
180 test_topLevel() { 191 test_topLevel() {
181 addTestFile(''' 192 addTestFile('''
182 typedef foo(); 193 typedef foo();
183 var test = ''; 194 var test = '';
184 main() {tes^t} 195 main() {tes^t}
185 '''); 196 ''');
186 return getSuggestions().then((_) { 197 return getSuggestions().then((_) {
187 // expect(replacementOffset, equals(completionOffset - 3)); 198 // expect(replacementOffset, equals(completionOffset - 3));
188 // expect(replacementLength, equals(4)); 199 // expect(replacementLength, equals(4));
189 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); 200 assertHasResult(CompletionSuggestionKind.CLASS, 'Object');
190 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test'); 201 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test');
191 assertNoResult('HtmlElement'); 202 assertNoResult('HtmlElement');
192 }); 203 });
193 } 204 }
194 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698