| 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.services.completion.dart.util; | 5 library test.services.completion.dart.util; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol |
| 10 show Element, ElementKind; | 10 show Element, ElementKind; |
| 11 import 'package:analysis_server/plugin/protocol/protocol.dart' | 11 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 12 hide Element, ElementKind; | 12 hide Element, ElementKind; |
| 13 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 13 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 14 import 'package:analysis_server/src/provisional/completion/completion_core.dart' | |
| 15 show AnalysisRequest, CompletionContributor, CompletionRequest; | |
| 16 import 'package:analysis_server/src/provisional/completion/completion_dart.dart'
; | 14 import 'package:analysis_server/src/provisional/completion/completion_dart.dart'
; |
| 17 import 'package:analysis_server/src/services/completion/completion_dart.dart' | 15 import 'package:analysis_server/src/services/completion/completion_core.dart'; |
| 16 import 'package:analysis_server/src/services/completion/dart/completion_manager.
dart' |
| 18 show DartCompletionRequestImpl; | 17 show DartCompletionRequestImpl; |
| 19 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart' | 18 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart' |
| 20 show DART_RELEVANCE_DEFAULT, DART_RELEVANCE_LOW; | 19 show DART_RELEVANCE_DEFAULT, DART_RELEVANCE_LOW; |
| 21 import 'package:analysis_server/src/services/index/index.dart'; | 20 import 'package:analysis_server/src/services/index/index.dart'; |
| 22 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 21 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 23 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 22 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 24 import 'package:analyzer/src/generated/source.dart'; | 23 import 'package:analyzer/src/generated/source.dart'; |
| 25 import 'package:unittest/unittest.dart'; | 24 import 'package:unittest/unittest.dart'; |
| 26 | 25 |
| 27 import '../../../abstract_context.dart'; | 26 import '../../../abstract_context.dart'; |
| 28 import 'package:analysis_server/src/services/completion/completion_core.dart'; | |
| 29 | 27 |
| 30 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { | 28 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { |
| 31 String c1 = s1.completion.toLowerCase(); | 29 String c1 = s1.completion.toLowerCase(); |
| 32 String c2 = s2.completion.toLowerCase(); | 30 String c2 = s2.completion.toLowerCase(); |
| 33 return c1.compareTo(c2); | 31 return c1.compareTo(c2); |
| 34 } | 32 } |
| 35 | 33 |
| 36 abstract class DartCompletionContributorTest extends AbstractContextTest { | 34 abstract class DartCompletionContributorTest extends AbstractContextTest { |
| 37 Index index; | 35 Index index; |
| 38 SearchEngineImpl searchEngine; | 36 SearchEngineImpl searchEngine; |
| 39 String testFile = '/completionTest.dart'; | 37 String testFile = '/completionTest.dart'; |
| 40 Source testSource; | 38 Source testSource; |
| 41 int completionOffset; | 39 int completionOffset; |
| 42 DartCompletionContributor contributor; | 40 DartCompletionContributor contributor; |
| 43 CompletionRequest request; | 41 DartCompletionRequest request; |
| 44 List<CompletionSuggestion> suggestions; | 42 List<CompletionSuggestion> suggestions; |
| 45 | 43 |
| 46 void addTestSource(String content) { | 44 void addTestSource(String content) { |
| 47 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once'); | 45 expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once'); |
| 48 completionOffset = content.indexOf('^'); | 46 completionOffset = content.indexOf('^'); |
| 49 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); | 47 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); |
| 50 int nextOffset = content.indexOf('^', completionOffset + 1); | 48 int nextOffset = content.indexOf('^', completionOffset + 1); |
| 51 expect(nextOffset, equals(-1), reason: 'too many ^'); | 49 expect(nextOffset, equals(-1), reason: 'too many ^'); |
| 52 content = content.substring(0, completionOffset) + | 50 content = content.substring(0, completionOffset) + |
| 53 content.substring(completionOffset + 1); | 51 content.substring(completionOffset + 1); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 209 } |
| 212 | 210 |
| 213 @override | 211 @override |
| 214 void setUp() { | 212 void setUp() { |
| 215 super.setUp(); | 213 super.setUp(); |
| 216 index = createLocalMemoryIndex(); | 214 index = createLocalMemoryIndex(); |
| 217 searchEngine = new SearchEngineImpl(index); | 215 searchEngine = new SearchEngineImpl(index); |
| 218 contributor = createContributor(); | 216 contributor = createContributor(); |
| 219 } | 217 } |
| 220 } | 218 } |
| OLD | NEW |