| 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/dart/completion_dart.
dart'; | 14 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 15 import 'package:analysis_server/src/services/completion/completion_core.dart'; | 15 import 'package:analysis_server/src/services/completion/completion_core.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 show DartCompletionRequestImpl, ReplacementRange; | 17 show DartCompletionRequestImpl, ReplacementRange; |
| 18 import 'package:analysis_server/src/services/index/index.dart'; | 18 import 'package:analysis_server/src/services/index/index.dart'; |
| 19 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 19 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 20 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 20 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 21 import 'package:analyzer/src/generated/source.dart'; | 21 import 'package:analyzer/src/generated/source.dart'; |
| 22 import 'package:analyzer/task/dart.dart'; | 22 import 'package:analyzer/task/dart.dart'; |
| 23 import 'package:unittest/unittest.dart'; | 23 import 'package:unittest/unittest.dart'; |
| 24 | 24 |
| 25 import '../../../abstract_context.dart'; | 25 import '../../../abstract_context.dart'; |
| 26 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; |
| 26 | 27 |
| 27 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { | 28 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { |
| 28 String c1 = s1.completion.toLowerCase(); | 29 String c1 = s1.completion.toLowerCase(); |
| 29 String c2 = s2.completion.toLowerCase(); | 30 String c2 = s2.completion.toLowerCase(); |
| 30 return c1.compareTo(c2); | 31 return c1.compareTo(c2); |
| 31 } | 32 } |
| 32 | 33 |
| 33 abstract class DartCompletionContributorTest extends AbstractContextTest { | 34 abstract class DartCompletionContributorTest extends AbstractContextTest { |
| 34 Index index; | 35 Index index; |
| 35 SearchEngineImpl searchEngine; | 36 SearchEngineImpl searchEngine; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 // We use a delayed future to allow microtask events to finish. The | 430 // We use a delayed future to allow microtask events to finish. The |
| 430 // Future.value or Future() constructors use scheduleMicrotask themselves an
d | 431 // Future.value or Future() constructors use scheduleMicrotask themselves an
d |
| 431 // would therefore not wait for microtask callbacks that are scheduled after | 432 // would therefore not wait for microtask callbacks that are scheduled after |
| 432 // invoking this method. | 433 // invoking this method. |
| 433 return new Future.delayed( | 434 return new Future.delayed( |
| 434 Duration.ZERO, () => computeLibrariesContaining(times - 1)); | 435 Duration.ZERO, () => computeLibrariesContaining(times - 1)); |
| 435 } | 436 } |
| 436 | 437 |
| 437 Future computeSuggestions([int times = 200]) async { | 438 Future computeSuggestions([int times = 200]) async { |
| 438 CompletionRequestImpl baseRequest = new CompletionRequestImpl( | 439 CompletionRequestImpl baseRequest = new CompletionRequestImpl( |
| 439 context, provider, searchEngine, testSource, completionOffset); | 440 context, |
| 441 provider, |
| 442 searchEngine, |
| 443 testSource, |
| 444 completionOffset, |
| 445 new CompletionPerformance()); |
| 440 | 446 |
| 441 // Build the request | 447 // Build the request |
| 442 Completer<DartCompletionRequest> requestCompleter = | 448 Completer<DartCompletionRequest> requestCompleter = |
| 443 new Completer<DartCompletionRequest>(); | 449 new Completer<DartCompletionRequest>(); |
| 444 DartCompletionRequestImpl | 450 DartCompletionRequestImpl |
| 445 .from(baseRequest) | 451 .from(baseRequest) |
| 446 .then((DartCompletionRequest request) { | 452 .then((DartCompletionRequest request) { |
| 447 requestCompleter.complete(request); | 453 requestCompleter.complete(request); |
| 448 }); | 454 }); |
| 449 request = await performAnalysis(times, requestCompleter); | 455 request = await performAnalysis(times, requestCompleter); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 538 } |
| 533 | 539 |
| 534 @override | 540 @override |
| 535 void setUp() { | 541 void setUp() { |
| 536 super.setUp(); | 542 super.setUp(); |
| 537 index = createLocalMemoryIndex(); | 543 index = createLocalMemoryIndex(); |
| 538 searchEngine = new SearchEngineImpl(index); | 544 searchEngine = new SearchEngineImpl(index); |
| 539 contributor = createContributor(); | 545 contributor = createContributor(); |
| 540 } | 546 } |
| 541 } | 547 } |
| OLD | NEW |