Chromium Code Reviews| 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:analysis_server/protocol/protocol_generated.dart'; | 7 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 8 import 'package:analysis_server/src/computer/import_elements_computer.dart'; | 8 import 'package:analysis_server/src/computer/import_elements_computer.dart'; |
| 9 import 'package:analyzer/src/dart/analysis/driver.dart'; | 9 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 10 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 10 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 provider.newFile(path, content); | 51 provider.newFile(path, content); |
| 52 AnalysisResult result = await driver.getResult(path); | 52 AnalysisResult result = await driver.getResult(path); |
| 53 computer = new ImportElementsComputer(provider, result); | 53 computer = new ImportElementsComputer(provider, result); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void setUp() { | 56 void setUp() { |
| 57 super.setUp(); | 57 super.setUp(); |
| 58 path = provider.convertPath('/test.dart'); | 58 path = provider.convertPath('/test.dart'); |
| 59 } | 59 } |
| 60 | 60 |
| 61 test_createEdits_addImport_noDirectives() async { | |
|
scheglov
2017/08/14 18:37:51
Maybe also worth to add a test with parts.
Brian Wilkerson
2017/08/14 19:59:20
Absolutely. In fact, I think you found a bug. But
| |
| 62 await createBuilder(''' | |
| 63 main() { | |
| 64 // paste here | |
| 65 } | |
| 66 '''); | |
| 67 await computeChanges(<ImportedElements>[ | |
| 68 new ImportedElements('/lib/math/math.dart', '', <String>['Random']) | |
| 69 ]); | |
| 70 assertChanges(''' | |
| 71 import 'dart:math'; | |
| 72 | |
| 73 main() { | |
| 74 // paste here | |
| 75 } | |
| 76 '''); | |
| 77 } | |
| 78 | |
| 61 test_createEdits_addImport_noPrefix() async { | 79 test_createEdits_addImport_noPrefix() async { |
| 62 Source fooSource = addPackageSource('pkg', 'foo.dart', ''); | 80 Source fooSource = addPackageSource('pkg', 'foo.dart', ''); |
| 63 await createBuilder(''' | 81 await createBuilder(''' |
| 64 import 'package:pkg/foo.dart' as foo; | 82 import 'package:pkg/foo.dart' as foo; |
| 65 '''); | 83 '''); |
| 66 await computeChanges(<ImportedElements>[ | 84 await computeChanges(<ImportedElements>[ |
| 67 new ImportedElements(fooSource.fullName, '', <String>['A']) | 85 new ImportedElements(fooSource.fullName, '', <String>['A']) |
| 68 ]); | 86 ]); |
| 69 assertChanges(''' | 87 assertChanges(''' |
| 70 import 'package:pkg/foo.dart' as foo; | 88 import 'package:pkg/foo.dart' as foo; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 import 'package:pkg/foo.dart' hide A, B; | 334 import 'package:pkg/foo.dart' hide A, B; |
| 317 '''); | 335 '''); |
| 318 await computeChanges(<ImportedElements>[ | 336 await computeChanges(<ImportedElements>[ |
| 319 new ImportedElements(fooSource.fullName, '', <String>['A', 'B']) | 337 new ImportedElements(fooSource.fullName, '', <String>['A', 'B']) |
| 320 ]); | 338 ]); |
| 321 assertChanges(''' | 339 assertChanges(''' |
| 322 import 'package:pkg/foo.dart'; | 340 import 'package:pkg/foo.dart'; |
| 323 '''); | 341 '''); |
| 324 } | 342 } |
| 325 } | 343 } |
| OLD | NEW |