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

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

Issue 904603004: rename completion constants and cleanup comment (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 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/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/channel/channel.dart'; 10 import 'package:analysis_server/src/channel/channel.dart';
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 completionOffset = content.indexOf('^'); 255 completionOffset = content.indexOf('^');
256 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); 256 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^');
257 int nextOffset = content.indexOf('^', completionOffset + 1); 257 int nextOffset = content.indexOf('^', completionOffset + 1);
258 expect(nextOffset, equals(-1), reason: 'too many ^'); 258 expect(nextOffset, equals(-1), reason: 'too many ^');
259 return super.addTestFile( 259 return super.addTestFile(
260 content.substring(0, completionOffset) + 260 content.substring(0, completionOffset) +
261 content.substring(completionOffset + 1)); 261 content.substring(completionOffset + 1));
262 } 262 }
263 263
264 void assertHasResult(CompletionSuggestionKind kind, String completion, 264 void assertHasResult(CompletionSuggestionKind kind, String completion,
265 [int relevance = COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated = false, 265 [int relevance = DART_RELEVANCE_DEFAULT, bool isDeprecated = false,
266 bool isPotential = false]) { 266 bool isPotential = false]) {
267 var cs; 267 var cs;
268 suggestions.forEach((s) { 268 suggestions.forEach((s) {
269 if (s.completion == completion) { 269 if (s.completion == completion) {
270 if (cs == null) { 270 if (cs == null) {
271 cs = s; 271 cs = s;
272 } else { 272 } else {
273 fail('expected exactly one $completion but found > 1'); 273 fail('expected exactly one $completion but found > 1');
274 } 274 }
275 } 275 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 438 }
439 439
440 test_keyword() { 440 test_keyword() {
441 addTestFile('library A; cl^'); 441 addTestFile('library A; cl^');
442 return getSuggestions().then((_) { 442 return getSuggestions().then((_) {
443 expect(replacementOffset, equals(completionOffset - 2)); 443 expect(replacementOffset, equals(completionOffset - 2));
444 expect(replacementLength, equals(2)); 444 expect(replacementLength, equals(2));
445 assertHasResult( 445 assertHasResult(
446 CompletionSuggestionKind.KEYWORD, 446 CompletionSuggestionKind.KEYWORD,
447 'import', 447 'import',
448 COMPLETION_RELEVANCE_HIGH); 448 DART_RELEVANCE_HIGH);
449 assertHasResult( 449 assertHasResult(
450 CompletionSuggestionKind.KEYWORD, 450 CompletionSuggestionKind.KEYWORD,
451 'class', 451 'class',
452 COMPLETION_RELEVANCE_HIGH); 452 DART_RELEVANCE_HIGH);
453 }); 453 });
454 } 454 }
455 455
456 test_local_named_constructor() { 456 test_local_named_constructor() {
457 addTestFile('class A {A.c(); x() {new A.^}}'); 457 addTestFile('class A {A.c(); x() {new A.^}}');
458 return getSuggestions().then((_) { 458 return getSuggestions().then((_) {
459 expect(replacementOffset, equals(completionOffset)); 459 expect(replacementOffset, equals(completionOffset));
460 expect(replacementLength, equals(0)); 460 expect(replacementLength, equals(0));
461 assertHasResult(CompletionSuggestionKind.INVOCATION, 'c'); 461 assertHasResult(CompletionSuggestionKind.INVOCATION, 'c');
462 assertNoResult('A'); 462 assertNoResult('A');
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 643
644 void contextsChangedRaw(ContextsChangedEvent newEvent) { 644 void contextsChangedRaw(ContextsChangedEvent newEvent) {
645 super.contextsChanged(newEvent); 645 super.contextsChanged(newEvent);
646 } 646 }
647 647
648 CompletionManager createCompletionManager(AnalysisContext context, 648 CompletionManager createCompletionManager(AnalysisContext context,
649 Source source, SearchEngine searchEngine) { 649 Source source, SearchEngine searchEngine) {
650 return new MockCompletionManager(mockContext, source, searchEngine); 650 return new MockCompletionManager(mockContext, source, searchEngine);
651 } 651 }
652 } 652 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698