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.correction.fix; | 5 library test.services.correction.fix; |
6 | 6 |
7 import 'package:analysis_server/edit/fix/fix_core.dart'; | 7 import 'package:analysis_server/edit/fix/fix_core.dart'; |
8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; | 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; |
9 import 'package:analysis_server/src/services/correction/fix.dart'; | 9 import 'package:analysis_server/src/services/correction/fix.dart'; |
10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; | 10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 main() { | 382 main() { |
383 Test v = null; | 383 Test v = null; |
384 } | 384 } |
385 | 385 |
386 class Test { | 386 class Test { |
387 } | 387 } |
388 '''); | 388 '''); |
389 _assertLinkedGroup(change.linkedEditGroups[0], ['Test v =', 'Test {']); | 389 _assertLinkedGroup(change.linkedEditGroups[0], ['Test v =', 'Test {']); |
390 } | 390 } |
391 | 391 |
| 392 void test_createClass_inLibraryOfPrefix() { |
| 393 // TODO |
| 394 String libCode = r''' |
| 395 library my.lib; |
| 396 |
| 397 class A {} |
| 398 '''; |
| 399 addSource('/lib.dart', libCode); |
| 400 resolveTestUnit(''' |
| 401 import 'lib.dart' as lib; |
| 402 |
| 403 main() { |
| 404 lib.A a = null; |
| 405 lib.Test t = null; |
| 406 } |
| 407 '''); |
| 408 AnalysisError error = _findErrorToFix(); |
| 409 fix = _assertHasFix(DartFixKind.CREATE_CLASS, error); |
| 410 change = fix.change; |
| 411 // apply to "lib.dart" |
| 412 List<SourceFileEdit> fileEdits = change.edits; |
| 413 expect(fileEdits, hasLength(1)); |
| 414 SourceFileEdit fileEdit = change.edits[0]; |
| 415 expect(fileEdit.file, '/lib.dart'); |
| 416 expect(SourceEdit.applySequence(libCode, fileEdit.edits), r''' |
| 417 library my.lib; |
| 418 |
| 419 class A {} |
| 420 |
| 421 class Test { |
| 422 } |
| 423 '''); |
| 424 expect(change.linkedEditGroups, isEmpty); |
| 425 } |
| 426 |
392 void test_createClass_innerLocalFunction() { | 427 void test_createClass_innerLocalFunction() { |
393 resolveTestUnit(''' | 428 resolveTestUnit(''' |
394 f() { | 429 f() { |
395 g() { | 430 g() { |
396 Test v = null; | 431 Test v = null; |
397 } | 432 } |
398 } | 433 } |
399 '''); | 434 '''); |
400 assertHasFix(DartFixKind.CREATE_CLASS, ''' | 435 assertHasFix(DartFixKind.CREATE_CLASS, ''' |
401 f() { | 436 f() { |
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3725 | 3760 |
3726 List<Position> _findResultPositions(List<String> searchStrings) { | 3761 List<Position> _findResultPositions(List<String> searchStrings) { |
3727 List<Position> positions = <Position>[]; | 3762 List<Position> positions = <Position>[]; |
3728 for (String search in searchStrings) { | 3763 for (String search in searchStrings) { |
3729 int offset = resultCode.indexOf(search); | 3764 int offset = resultCode.indexOf(search); |
3730 positions.add(new Position(testFile, offset)); | 3765 positions.add(new Position(testFile, offset)); |
3731 } | 3766 } |
3732 return positions; | 3767 return positions; |
3733 } | 3768 } |
3734 } | 3769 } |
OLD | NEW |