| 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.dart'; | 7 import 'package:analysis_server/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/protocol/protocol_constants.dart'; | 8 import 'package:analysis_server/protocol/protocol_constants.dart'; |
| 9 import 'package:analysis_server/protocol/protocol_generated.dart'; | 9 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| 11 import 'package:analysis_server/src/domain_completion.dart'; | 11 import 'package:analysis_server/src/domain_completion.dart'; |
| 12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 13 import 'package:analysis_server/src/services/index/index.dart'; | |
| 14 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 13 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 15 import 'package:test/test.dart'; | 14 import 'package:test/test.dart'; |
| 16 | 15 |
| 17 import 'analysis_abstract.dart'; | 16 import 'analysis_abstract.dart'; |
| 18 | 17 |
| 19 class AbstractCompletionDomainTest extends AbstractAnalysisTest { | 18 class AbstractCompletionDomainTest extends AbstractAnalysisTest { |
| 20 String completionId; | 19 String completionId; |
| 21 int completionOffset; | 20 int completionOffset; |
| 22 int replacementOffset; | 21 int replacementOffset; |
| 23 int replacementLength; | 22 int replacementLength; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (suggestions.any((cs) => cs.completion == completion)) { | 70 if (suggestions.any((cs) => cs.completion == completion)) { |
| 72 fail('did not expect completion: $completion'); | 71 fail('did not expect completion: $completion'); |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| 76 void assertValidId(String id) { | 75 void assertValidId(String id) { |
| 77 expect(id, isNotNull); | 76 expect(id, isNotNull); |
| 78 expect(id.isNotEmpty, isTrue); | 77 expect(id.isNotEmpty, isTrue); |
| 79 } | 78 } |
| 80 | 79 |
| 81 @override | |
| 82 Index createIndex() { | |
| 83 return createMemoryIndex(); | |
| 84 } | |
| 85 | |
| 86 Future getSuggestions() async { | 80 Future getSuggestions() async { |
| 87 await waitForTasksFinished(); | 81 await waitForTasksFinished(); |
| 88 | 82 |
| 89 Request request = | 83 Request request = |
| 90 new CompletionGetSuggestionsParams(testFile, completionOffset) | 84 new CompletionGetSuggestionsParams(testFile, completionOffset) |
| 91 .toRequest('0'); | 85 .toRequest('0'); |
| 92 Response response = await waitResponse(request); | 86 Response response = await waitResponse(request); |
| 93 var result = new CompletionGetSuggestionsResult.fromResponse(response); | 87 var result = new CompletionGetSuggestionsResult.fromResponse(response); |
| 94 completionId = result.id; | 88 completionId = result.id; |
| 95 assertValidId(completionId); | 89 assertValidId(completionId); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 120 super.setUp(); | 114 super.setUp(); |
| 121 createProject(); | 115 createProject(); |
| 122 handler = new CompletionDomainHandler(server); | 116 handler = new CompletionDomainHandler(server); |
| 123 } | 117 } |
| 124 | 118 |
| 125 Completer<Null> _getResultsCompleter(String id) { | 119 Completer<Null> _getResultsCompleter(String id) { |
| 126 return receivedSuggestionsCompleters.putIfAbsent( | 120 return receivedSuggestionsCompleters.putIfAbsent( |
| 127 id, () => new Completer<Null>()); | 121 id, () => new Completer<Null>()); |
| 128 } | 122 } |
| 129 } | 123 } |
| OLD | NEW |