| 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 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/completion/dart_completion_manager.
dart'; |
| 17 import 'package:analysis_server/src/services/index/index.dart' show Index; | 17 import 'package:analysis_server/src/services/index/index.dart' show Index; |
| 18 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 18 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 19 import 'package:analysis_server/src/services/search/search_engine.dart'; | 19 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 20 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; |
| 20 import 'package:analyzer/file_system/file_system.dart'; | 21 import 'package:analyzer/file_system/file_system.dart'; |
| 21 import 'package:analyzer/instrumentation/instrumentation.dart'; | 22 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 22 import 'package:analyzer/source/package_map_provider.dart'; | |
| 23 import 'package:analyzer/src/generated/engine.dart'; | 23 import 'package:analyzer/src/generated/engine.dart'; |
| 24 import 'package:analyzer/src/generated/sdk.dart'; | 24 import 'package:analyzer/src/generated/sdk.dart'; |
| 25 import 'package:analyzer/src/generated/source.dart'; | 25 import 'package:analyzer/src/generated/source.dart'; |
| 26 import 'package:unittest/unittest.dart'; | 26 import 'package:unittest/unittest.dart'; |
| 27 | 27 |
| 28 import 'analysis_abstract.dart'; | 28 import 'analysis_abstract.dart'; |
| 29 import 'mock_sdk.dart'; | 29 import 'mock_sdk.dart'; |
| 30 import 'mocks.dart'; | 30 import 'mocks.dart'; |
| 31 import 'reflective_tests.dart'; | 31 import 'reflective_tests.dart'; |
| 32 | 32 |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 SourceFactory sourceFactory = DEFAULT_SOURCE_FACTORY; | 591 SourceFactory sourceFactory = DEFAULT_SOURCE_FACTORY; |
| 592 | 592 |
| 593 MockContext() { | 593 MockContext() { |
| 594 mockStream = new MockStream<SourcesChangedEvent>(); | 594 mockStream = new MockStream<SourcesChangedEvent>(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 @override | 597 @override |
| 598 Stream<SourcesChangedEvent> get onSourcesChanged => mockStream; | 598 Stream<SourcesChangedEvent> get onSourcesChanged => mockStream; |
| 599 | 599 |
| 600 @override | 600 @override |
| 601 bool exists(Source source) { |
| 602 return source != null && source.exists(); |
| 603 } |
| 604 |
| 605 @override |
| 601 TimestampedData<String> getContents(Source source) { | 606 TimestampedData<String> getContents(Source source) { |
| 602 return source.contents; | 607 return source.contents; |
| 603 } | 608 } |
| 604 | 609 |
| 605 @override | |
| 606 bool exists(Source source) { | |
| 607 return source != null && source.exists(); | |
| 608 } | |
| 609 | |
| 610 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 610 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 611 } | 611 } |
| 612 | 612 |
| 613 /** | 613 /** |
| 614 * Mock stream for tracking calls to listen and subscription.cancel. | 614 * Mock stream for tracking calls to listen and subscription.cancel. |
| 615 */ | 615 */ |
| 616 class MockStream<E> implements Stream<E> { | 616 class MockStream<E> implements Stream<E> { |
| 617 MockSubscription<E> mockSubscription = new MockSubscription<E>(); | 617 MockSubscription<E> mockSubscription = new MockSubscription<E>(); |
| 618 int listenCount = 0; | 618 int listenCount = 0; |
| 619 | 619 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 640 return new Future.value(true); | 640 return new Future.value(true); |
| 641 } | 641 } |
| 642 | 642 |
| 643 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 643 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 644 } | 644 } |
| 645 | 645 |
| 646 class Test_AnalysisServer extends AnalysisServer { | 646 class Test_AnalysisServer extends AnalysisServer { |
| 647 final MockContext mockContext = new MockContext(); | 647 final MockContext mockContext = new MockContext(); |
| 648 | 648 |
| 649 Test_AnalysisServer(ServerCommunicationChannel channel, | 649 Test_AnalysisServer(ServerCommunicationChannel channel, |
| 650 ResourceProvider resourceProvider, PackageMapProvider packageMapProvider, | 650 ResourceProvider resourceProvider, OptimizingPubPackageMapProvider package
MapProvider, |
| 651 Index index, AnalysisServerOptions analysisServerOptions, | 651 Index index, AnalysisServerOptions analysisServerOptions, |
| 652 DartSdk defaultSdk, InstrumentationService instrumentationService) | 652 DartSdk defaultSdk, InstrumentationService instrumentationService) |
| 653 : super(channel, resourceProvider, packageMapProvider, index, | 653 : super(channel, resourceProvider, packageMapProvider, index, |
| 654 analysisServerOptions, defaultSdk, instrumentationService); | 654 analysisServerOptions, defaultSdk, instrumentationService); |
| 655 | 655 |
| 656 @override | 656 @override |
| 657 AnalysisContext getAnalysisContext(String path) { | 657 AnalysisContext getAnalysisContext(String path) { |
| 658 return mockContext; | 658 return mockContext; |
| 659 } | 659 } |
| 660 | 660 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 709 } |
| 710 '''); | 710 '''); |
| 711 await waitForTasksFinished(); | 711 await waitForTasksFinished(); |
| 712 Request request = | 712 Request request = |
| 713 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); | 713 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); |
| 714 Response response = handler.handleRequest(request); | 714 Response response = handler.handleRequest(request); |
| 715 expect(response.error, isNotNull); | 715 expect(response.error, isNotNull); |
| 716 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 716 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
| 717 } | 717 } |
| 718 } | 718 } |
| OLD | NEW |