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 'package:analysis_server/protocol/protocol_generated.dart'; | 5 import 'package:analysis_server/protocol/protocol_generated.dart'; |
6 import 'package:analysis_server/src/computer/import_elements_computer.dart'; | 6 import 'package:analysis_server/src/computer/import_elements_computer.dart'; |
7 import 'package:analyzer/dart/analysis/results.dart'; | 7 import 'package:analyzer/dart/analysis/results.dart'; |
8 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 8 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
(...skipping 28 matching lines...) Expand all Loading... |
39 targetCode = ''' | 39 targetCode = ''' |
40 main() {} | 40 main() {} |
41 '''; | 41 '''; |
42 provider.newFile(targetPath, targetCode); | 42 provider.newFile(targetPath, targetCode); |
43 result = await driver.getResult(targetPath); | 43 result = await driver.getResult(targetPath); |
44 } | 44 } |
45 | 45 |
46 @failingTest | 46 @failingTest |
47 test_bare_none() { | 47 test_bare_none() { |
48 List<ImportedElements> elements = <ImportedElements>[ | 48 List<ImportedElements> elements = <ImportedElements>[ |
49 new ImportedElements(provider.convertPath('/p/lib/a.dart'), | 49 new ImportedElements( |
50 'package:p/a.dart', '', <String>['A']), | 50 provider.convertPath('/p/lib/a.dart'), '', <String>['A']), |
51 ]; | 51 ]; |
52 List<SourceEdit> edits = _computeEditsFor(elements); | 52 List<SourceEdit> edits = _computeEditsFor(elements); |
53 expect(edits, hasLength(1)); | 53 expect(edits, hasLength(1)); |
54 SourceEdit edit = edits[0]; | 54 SourceEdit edit = edits[0]; |
55 expect(edit, isNotNull); | 55 expect(edit, isNotNull); |
56 expect(edit.offset, 0); | 56 expect(edit.offset, 0); |
57 expect(edit.length, 0); | 57 expect(edit.length, 0); |
58 expect(edit.apply(targetCode), """ | 58 expect(edit.apply(targetCode), """ |
59 import 'source.dart'; | 59 import 'source.dart'; |
60 | 60 |
61 main() {} | 61 main() {} |
62 """); | 62 """); |
63 } | 63 } |
64 | 64 |
65 test_none_none() { | 65 test_none_none() { |
66 List<ImportedElements> elements = <ImportedElements>[]; | 66 List<ImportedElements> elements = <ImportedElements>[]; |
67 List<SourceEdit> edits = _computeEditsFor(elements); | 67 List<SourceEdit> edits = _computeEditsFor(elements); |
68 expect(edits, hasLength(0)); | 68 expect(edits, hasLength(0)); |
69 } | 69 } |
70 | 70 |
71 List<SourceEdit> _computeEditsFor(List<ImportedElements> elements) { | 71 List<SourceEdit> _computeEditsFor(List<ImportedElements> elements) { |
72 ImportElementsComputer computer = | 72 ImportElementsComputer computer = |
73 new ImportElementsComputer(result, targetPath, elements); | 73 new ImportElementsComputer(result, targetPath, elements); |
74 return computer.compute(); | 74 return computer.compute(); |
75 } | 75 } |
76 } | 76 } |
OLD | NEW |