| OLD | NEW |
| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/protocol/protocol_generated.dart'; | 7 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 8 import 'package:analysis_server/src/ide_options.dart'; | 8 import 'package:analysis_server/src/ide_options.dart'; |
| 9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 9 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 10 import 'package:analysis_server/src/services/completion/completion_core.dart'; | 10 import 'package:analysis_server/src/services/completion/completion_core.dart'; |
| 11 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; | 11 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; |
| 12 import 'package:analysis_server/src/services/completion/dart/completion_manager.
dart' | 12 import 'package:analysis_server/src/services/completion/dart/completion_manager.
dart' |
| 13 show DartCompletionRequestImpl, ReplacementRange; | 13 show DartCompletionRequestImpl, ReplacementRange; |
| 14 import 'package:analysis_server/src/services/index/index.dart'; | |
| 15 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | |
| 16 import 'package:analyzer/file_system/file_system.dart'; | 14 import 'package:analyzer/file_system/file_system.dart'; |
| 17 import 'package:analyzer/source/package_map_resolver.dart'; | 15 import 'package:analyzer/source/package_map_resolver.dart'; |
| 18 import 'package:analyzer/src/dart/analysis/ast_provider_context.dart'; | |
| 19 import 'package:analyzer/src/dart/analysis/driver.dart'; | 16 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 20 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
| 21 import 'package:analyzer/task/dart.dart'; | 18 import 'package:analyzer/task/dart.dart'; |
| 22 import 'package:test/test.dart'; | 19 import 'package:test/test.dart'; |
| 23 | 20 |
| 24 import '../../../abstract_context.dart'; | 21 import '../../../abstract_context.dart'; |
| 25 import '../../correction/flutter_util.dart'; | 22 import '../../correction/flutter_util.dart'; |
| 26 | 23 |
| 27 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { | 24 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { |
| 28 String c1 = s1.completion.toLowerCase(); | 25 String c1 = s1.completion.toLowerCase(); |
| 29 String c2 = s2.completion.toLowerCase(); | 26 String c2 = s2.completion.toLowerCase(); |
| 30 return c1.compareTo(c2); | 27 return c1.compareTo(c2); |
| 31 } | 28 } |
| 32 | 29 |
| 33 abstract class DartCompletionContributorTest extends AbstractContextTest { | 30 abstract class DartCompletionContributorTest extends AbstractContextTest { |
| 34 static const String _UNCHECKED = '__UNCHECKED__'; | 31 static const String _UNCHECKED = '__UNCHECKED__'; |
| 35 Index index; | |
| 36 SearchEngineImpl searchEngine; | |
| 37 String testFile = '/completionTest.dart'; | 32 String testFile = '/completionTest.dart'; |
| 38 Source testSource; | 33 Source testSource; |
| 39 int completionOffset; | 34 int completionOffset; |
| 40 int replacementOffset; | 35 int replacementOffset; |
| 41 int replacementLength; | 36 int replacementLength; |
| 42 DartCompletionContributor contributor; | 37 DartCompletionContributor contributor; |
| 43 DartCompletionRequest request; | 38 DartCompletionRequest request; |
| 44 List<CompletionSuggestion> suggestions; | 39 List<CompletionSuggestion> suggestions; |
| 45 | 40 |
| 46 /** | 41 /** |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 if (enableNewAnalysisDriver) { | 478 if (enableNewAnalysisDriver) { |
| 484 analysisResult = await driver.getResult(testFile); | 479 analysisResult = await driver.getResult(testFile); |
| 485 testSource = analysisResult.unit.element.source; | 480 testSource = analysisResult.unit.element.source; |
| 486 } else { | 481 } else { |
| 487 context.analysisPriorityOrder = [testSource]; | 482 context.analysisPriorityOrder = [testSource]; |
| 488 } | 483 } |
| 489 CompletionRequestImpl baseRequest = new CompletionRequestImpl( | 484 CompletionRequestImpl baseRequest = new CompletionRequestImpl( |
| 490 analysisResult, | 485 analysisResult, |
| 491 enableNewAnalysisDriver ? null : context, | 486 enableNewAnalysisDriver ? null : context, |
| 492 provider, | 487 provider, |
| 493 searchEngine, | |
| 494 testSource, | 488 testSource, |
| 495 completionOffset, | 489 completionOffset, |
| 496 new CompletionPerformance(), | 490 new CompletionPerformance(), |
| 497 options); | 491 options); |
| 498 | 492 |
| 499 // Build the request | 493 // Build the request |
| 500 Completer<DartCompletionRequest> requestCompleter = | 494 Completer<DartCompletionRequest> requestCompleter = |
| 501 new Completer<DartCompletionRequest>(); | 495 new Completer<DartCompletionRequest>(); |
| 502 DartCompletionRequestImpl | 496 DartCompletionRequestImpl |
| 503 .from(baseRequest) | 497 .from(baseRequest) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 Source libSource = addSource(path, content); | 618 Source libSource = addSource(path, content); |
| 625 if (!enableNewAnalysisDriver) { | 619 if (!enableNewAnalysisDriver) { |
| 626 var target = new LibrarySpecificUnit(libSource, libSource); | 620 var target = new LibrarySpecificUnit(libSource, libSource); |
| 627 context.computeResult(target, RESOLVED_UNIT); | 621 context.computeResult(target, RESOLVED_UNIT); |
| 628 } | 622 } |
| 629 } | 623 } |
| 630 | 624 |
| 631 @override | 625 @override |
| 632 void setUp() { | 626 void setUp() { |
| 633 super.setUp(); | 627 super.setUp(); |
| 634 index = createMemoryIndex(); | |
| 635 searchEngine = | |
| 636 new SearchEngineImpl(index, (_) => new AstProviderForContext(context)); | |
| 637 contributor = createContributor(); | 628 contributor = createContributor(); |
| 638 } | 629 } |
| 639 } | 630 } |
| OLD | NEW |