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

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

Issue 845553005: Change code completion relevance from CompletionRelevance.LOW/DEFAULT/HIGH to int (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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';
11 import 'package:analysis_server/src/constants.dart'; 11 import 'package:analysis_server/src/constants.dart';
12 import 'package:analysis_server/src/domain_analysis.dart'; 12 import 'package:analysis_server/src/domain_analysis.dart';
13 import 'package:analysis_server/src/domain_completion.dart'; 13 import 'package:analysis_server/src/domain_completion.dart';
14 import 'package:analysis_server/src/protocol.dart'; 14 import 'package:analysis_server/src/protocol.dart';
15 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 15 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
16 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
16 import 'package:analysis_server/src/services/index/index.dart' show Index; 17 import 'package:analysis_server/src/services/index/index.dart' show Index;
17 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 18 import 'package:analysis_server/src/services/index/local_memory_index.dart';
18 import 'package:analysis_server/src/services/search/search_engine.dart'; 19 import 'package:analysis_server/src/services/search/search_engine.dart';
19 import 'package:analyzer/file_system/file_system.dart'; 20 import 'package:analyzer/file_system/file_system.dart';
20 import 'package:analyzer/instrumentation/instrumentation.dart'; 21 import 'package:analyzer/instrumentation/instrumentation.dart';
21 import 'package:analyzer/source/package_map_provider.dart'; 22 import 'package:analyzer/source/package_map_provider.dart';
22 import 'package:analyzer/src/generated/engine.dart'; 23 import 'package:analyzer/src/generated/engine.dart';
23 import 'package:analyzer/src/generated/sdk.dart'; 24 import 'package:analyzer/src/generated/sdk.dart';
24 import 'package:analyzer/src/generated/source.dart'; 25 import 'package:analyzer/src/generated/source.dart';
25 import 'package:unittest/unittest.dart'; 26 import 'package:unittest/unittest.dart';
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 completionOffset = content.indexOf('^'); 255 completionOffset = content.indexOf('^');
255 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); 256 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^');
256 int nextOffset = content.indexOf('^', completionOffset + 1); 257 int nextOffset = content.indexOf('^', completionOffset + 1);
257 expect(nextOffset, equals(-1), reason: 'too many ^'); 258 expect(nextOffset, equals(-1), reason: 'too many ^');
258 return super.addTestFile( 259 return super.addTestFile(
259 content.substring(0, completionOffset) + 260 content.substring(0, completionOffset) +
260 content.substring(completionOffset + 1)); 261 content.substring(completionOffset + 1));
261 } 262 }
262 263
263 void assertHasResult(CompletionSuggestionKind kind, String completion, 264 void assertHasResult(CompletionSuggestionKind kind, String completion,
264 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, bool isDepre cated 265 [int relevance = COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated
265 = false, bool isPotential = false]) { 266 = false, bool isPotential = false]) {
266 var cs; 267 var cs;
267 suggestions.forEach((s) { 268 suggestions.forEach((s) {
268 if (s.completion == completion) { 269 if (s.completion == completion) {
269 if (cs == null) { 270 if (cs == null) {
270 cs = s; 271 cs = s;
271 } else { 272 } else {
272 fail('expected exactly one $completion but found > 1'); 273 fail('expected exactly one $completion but found > 1');
273 } 274 }
274 } 275 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 438 }
438 439
439 test_keyword() { 440 test_keyword() {
440 addTestFile('library A; cl^'); 441 addTestFile('library A; cl^');
441 return getSuggestions().then((_) { 442 return getSuggestions().then((_) {
442 expect(replacementOffset, equals(completionOffset - 2)); 443 expect(replacementOffset, equals(completionOffset - 2));
443 expect(replacementLength, equals(2)); 444 expect(replacementLength, equals(2));
444 assertHasResult( 445 assertHasResult(
445 CompletionSuggestionKind.KEYWORD, 446 CompletionSuggestionKind.KEYWORD,
446 'import', 447 'import',
447 CompletionRelevance.HIGH); 448 COMPLETION_RELEVANCE_HIGH);
448 assertHasResult( 449 assertHasResult(
449 CompletionSuggestionKind.KEYWORD, 450 CompletionSuggestionKind.KEYWORD,
450 'class', 451 'class',
451 CompletionRelevance.HIGH); 452 COMPLETION_RELEVANCE_HIGH);
452 }); 453 });
453 } 454 }
454 455
455 test_local_named_constructor() { 456 test_local_named_constructor() {
456 addTestFile('class A {A.c(); x() {new A.^}}'); 457 addTestFile('class A {A.c(); x() {new A.^}}');
457 return getSuggestions().then((_) { 458 return getSuggestions().then((_) {
458 expect(replacementOffset, equals(completionOffset)); 459 expect(replacementOffset, equals(completionOffset));
459 expect(replacementLength, equals(0)); 460 expect(replacementLength, equals(0));
460 assertHasResult(CompletionSuggestionKind.INVOCATION, 'c'); 461 assertHasResult(CompletionSuggestionKind.INVOCATION, 'c');
461 assertNoResult('A'); 462 assertNoResult('A');
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 626
626 void contextsChangedRaw(ContextsChangedEvent newEvent) { 627 void contextsChangedRaw(ContextsChangedEvent newEvent) {
627 super.contextsChanged(newEvent); 628 super.contextsChanged(newEvent);
628 } 629 }
629 630
630 CompletionManager createCompletionManager(AnalysisContext context, 631 CompletionManager createCompletionManager(AnalysisContext context,
631 Source source, SearchEngine searchEngine) { 632 Source source, SearchEngine searchEngine) {
632 return new MockCompletionManager(mockContext, source, searchEngine); 633 return new MockCompletionManager(mockContext, source, searchEngine);
633 } 634 }
634 } 635 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698