| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/source/package_map_resolver.dart'; | 8 import 'package:analyzer/source/package_map_resolver.dart'; |
| 9 import 'package:analyzer/src/dart/analysis/driver.dart'; | 9 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| 11 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 11 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 12 import 'package:analyzer_plugin/src/utilities/completion/completion_core.dart'; | 12 import 'package:analyzer_plugin/src/utilities/completion/completion_core.dart'; |
| 13 import 'package:analyzer_plugin/src/utilities/completion/completion_target.dart'
; | 13 import 'package:analyzer_plugin/src/utilities/completion/completion_target.dart'
; |
| 14 import 'package:analyzer_plugin/utilities/completion/completion_core.dart'; | 14 import 'package:analyzer_plugin/utilities/completion/completion_core.dart'; |
| 15 import 'package:analyzer_plugin/utilities/completion/relevance.dart'; | 15 import 'package:analyzer_plugin/utilities/completion/relevance.dart'; |
| 16 import 'package:analyzer_plugin/utilities/completion/replacement_range.dart'; | |
| 17 import 'package:test/test.dart'; | 16 import 'package:test/test.dart'; |
| 18 | 17 |
| 19 import '../../support/abstract_context.dart'; | 18 import '../../support/abstract_context.dart'; |
| 20 import 'flutter_util.dart'; | 19 import 'flutter_util.dart'; |
| 21 | 20 |
| 22 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { | 21 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { |
| 23 String c1 = s1.completion.toLowerCase(); | 22 String c1 = s1.completion.toLowerCase(); |
| 24 String c2 = s2.completion.toLowerCase(); | 23 String c2 = s2.completion.toLowerCase(); |
| 25 return c1.compareTo(c2); | 24 return c1.compareTo(c2); |
| 26 } | 25 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 455 } |
| 457 | 456 |
| 458 Future computeSuggestions() async { | 457 Future computeSuggestions() async { |
| 459 AnalysisResult analysisResult = await driver.getResult(testFile); | 458 AnalysisResult analysisResult = await driver.getResult(testFile); |
| 460 testSource = analysisResult.unit.element.source; | 459 testSource = analysisResult.unit.element.source; |
| 461 request = | 460 request = |
| 462 new CompletionRequestImpl(provider, analysisResult, completionOffset); | 461 new CompletionRequestImpl(provider, analysisResult, completionOffset); |
| 463 | 462 |
| 464 CompletionTarget target = | 463 CompletionTarget target = |
| 465 new CompletionTarget.forOffset(request.result.unit, request.offset); | 464 new CompletionTarget.forOffset(request.result.unit, request.offset); |
| 466 var range = new ReplacementRange.compute(request.offset, target); | 465 var range = target.computeReplacementRange(request.offset); |
| 467 replacementOffset = range.offset; | 466 replacementOffset = range.offset; |
| 468 replacementLength = range.length; | 467 replacementLength = range.length; |
| 469 | 468 |
| 470 // Request completions | 469 // Request completions |
| 471 CompletionCollectorImpl collector = new CompletionCollectorImpl(); | 470 CompletionCollectorImpl collector = new CompletionCollectorImpl(); |
| 472 await contributor.computeSuggestions(request, collector); | 471 await contributor.computeSuggestions(request, collector); |
| 473 suggestions = collector.suggestions; | 472 suggestions = collector.suggestions; |
| 474 expect(suggestions, isNotNull, reason: 'expected suggestions'); | 473 expect(suggestions, isNotNull, reason: 'expected suggestions'); |
| 475 } | 474 } |
| 476 | 475 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 addSource(path, content); | 560 addSource(path, content); |
| 562 } | 561 } |
| 563 | 562 |
| 564 @override | 563 @override |
| 565 void setUp() { | 564 void setUp() { |
| 566 super.setUp(); | 565 super.setUp(); |
| 567 testFile = provider.convertPath('/completionTest.dart'); | 566 testFile = provider.convertPath('/completionTest.dart'); |
| 568 contributor = createContributor(); | 567 contributor = createContributor(); |
| 569 } | 568 } |
| 570 } | 569 } |
| OLD | NEW |