| 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/plugin/edit/fix/fix_core.dart'; | 7 import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
| 8 import 'package:analysis_server/plugin/protocol/protocol.dart' hide AnalysisErro
r; | 8 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 9 hide AnalysisError; |
| 9 import 'package:analysis_server/src/services/correction/fix.dart'; | 10 import 'package:analysis_server/src/services/correction/fix.dart'; |
| 10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; | 11 import 'package:analysis_server/src/services/correction/fix_internal.dart'; |
| 11 import 'package:analyzer/file_system/file_system.dart'; | 12 import 'package:analyzer/file_system/file_system.dart'; |
| 12 import 'package:analyzer/source/package_map_resolver.dart'; | 13 import 'package:analyzer/source/package_map_resolver.dart'; |
| 13 import 'package:analyzer/src/generated/error.dart'; | 14 import 'package:analyzer/src/generated/error.dart'; |
| 14 import 'package:analyzer/src/generated/parser.dart'; | 15 import 'package:analyzer/src/generated/parser.dart'; |
| 15 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
| 16 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 17 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 17 import 'package:unittest/unittest.dart'; | 18 import 'package:unittest/unittest.dart'; |
| 18 | 19 |
| (...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 class A { | 1537 class A { |
| 1537 int get test => null; | 1538 int get test => null; |
| 1538 } | 1539 } |
| 1539 main(A a) { | 1540 main(A a) { |
| 1540 var x = a; | 1541 var x = a; |
| 1541 int v = x.test; | 1542 int v = x.test; |
| 1542 } | 1543 } |
| 1543 '''); | 1544 '''); |
| 1544 } | 1545 } |
| 1545 | 1546 |
| 1547 void test_createGetter_location_afterLastGetter() { |
| 1548 resolveTestUnit(''' |
| 1549 class A { |
| 1550 int existingField; |
| 1551 |
| 1552 int get existingGetter => null; |
| 1553 |
| 1554 existingMethod() {} |
| 1555 } |
| 1556 main(A a) { |
| 1557 int v = a.test; |
| 1558 } |
| 1559 '''); |
| 1560 assertHasFix( |
| 1561 DartFixKind.CREATE_GETTER, |
| 1562 ''' |
| 1563 class A { |
| 1564 int existingField; |
| 1565 |
| 1566 int get existingGetter => null; |
| 1567 |
| 1568 int get test => null; |
| 1569 |
| 1570 existingMethod() {} |
| 1571 } |
| 1572 main(A a) { |
| 1573 int v = a.test; |
| 1574 } |
| 1575 '''); |
| 1576 } |
| 1577 |
| 1546 void test_createGetter_multiLevel() { | 1578 void test_createGetter_multiLevel() { |
| 1547 resolveTestUnit(''' | 1579 resolveTestUnit(''' |
| 1548 class A { | 1580 class A { |
| 1549 } | 1581 } |
| 1550 class B { | 1582 class B { |
| 1551 A a; | 1583 A a; |
| 1552 } | 1584 } |
| 1553 class C { | 1585 class C { |
| 1554 B b; | 1586 B b; |
| 1555 } | 1587 } |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 } | 2237 } |
| 2206 | 2238 |
| 2207 class B extends A { | 2239 class B extends A { |
| 2208 existing() {} | 2240 existing() {} |
| 2209 | 2241 |
| 2210 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2242 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2211 } | 2243 } |
| 2212 '''); | 2244 '''); |
| 2213 } | 2245 } |
| 2214 | 2246 |
| 2215 void test_creatGetter_location_afterLastGetter() { | |
| 2216 resolveTestUnit(''' | |
| 2217 class A { | |
| 2218 int existingField; | |
| 2219 | |
| 2220 int get existingGetter => null; | |
| 2221 | |
| 2222 existingMethod() {} | |
| 2223 } | |
| 2224 main(A a) { | |
| 2225 int v = a.test; | |
| 2226 } | |
| 2227 '''); | |
| 2228 assertHasFix( | |
| 2229 DartFixKind.CREATE_GETTER, | |
| 2230 ''' | |
| 2231 class A { | |
| 2232 int existingField; | |
| 2233 | |
| 2234 int get existingGetter => null; | |
| 2235 | |
| 2236 int get test => null; | |
| 2237 | |
| 2238 existingMethod() {} | |
| 2239 } | |
| 2240 main(A a) { | |
| 2241 int v = a.test; | |
| 2242 } | |
| 2243 '''); | |
| 2244 } | |
| 2245 | |
| 2246 void test_creationFunction_forFunctionType_cascadeSecond() { | 2247 void test_creationFunction_forFunctionType_cascadeSecond() { |
| 2247 resolveTestUnit(''' | 2248 resolveTestUnit(''' |
| 2248 class A { | 2249 class A { |
| 2249 B ma() => null; | 2250 B ma() => null; |
| 2250 } | 2251 } |
| 2251 class B { | 2252 class B { |
| 2252 useFunction(int g(double a, String b)) {} | 2253 useFunction(int g(double a, String b)) {} |
| 2253 } | 2254 } |
| 2254 | 2255 |
| 2255 main() { | 2256 main() { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2640 DartFixKind.IMPORT_LIBRARY_PROJECT, | 2641 DartFixKind.IMPORT_LIBRARY_PROJECT, |
| 2641 ''' | 2642 ''' |
| 2642 import 'lib.dart'; | 2643 import 'lib.dart'; |
| 2643 | 2644 |
| 2644 @Test(0) | 2645 @Test(0) |
| 2645 main() { | 2646 main() { |
| 2646 } | 2647 } |
| 2647 '''); | 2648 '''); |
| 2648 } | 2649 } |
| 2649 | 2650 |
| 2651 void test_importLibraryProject_withClass_hasOtherLibraryWithPrefix() { |
| 2652 testFile = '/project/bin/test.dart'; |
| 2653 addSource( |
| 2654 '/project/bin/a.dart', |
| 2655 ''' |
| 2656 library a; |
| 2657 class One {} |
| 2658 '''); |
| 2659 addSource( |
| 2660 '/project/bin/b.dart', |
| 2661 ''' |
| 2662 library b; |
| 2663 class One {} |
| 2664 class Two {} |
| 2665 '''); |
| 2666 resolveTestUnit(''' |
| 2667 import 'b.dart' show Two; |
| 2668 main () { |
| 2669 new Two(); |
| 2670 new One(); |
| 2671 } |
| 2672 '''); |
| 2673 performAllAnalysisTasks(); |
| 2674 assertHasFix( |
| 2675 DartFixKind.IMPORT_LIBRARY_PROJECT, |
| 2676 ''' |
| 2677 import 'b.dart' show Two; |
| 2678 import 'a.dart'; |
| 2679 main () { |
| 2680 new Two(); |
| 2681 new One(); |
| 2682 } |
| 2683 '''); |
| 2684 } |
| 2685 |
| 2650 void test_importLibraryProject_withClass_inParentFolder() { | 2686 void test_importLibraryProject_withClass_inParentFolder() { |
| 2651 testFile = '/project/bin/test.dart'; | 2687 testFile = '/project/bin/test.dart'; |
| 2652 addSource( | 2688 addSource( |
| 2653 '/project/lib.dart', | 2689 '/project/lib.dart', |
| 2654 ''' | 2690 ''' |
| 2655 library lib; | 2691 library lib; |
| 2656 class Test {} | 2692 class Test {} |
| 2657 '''); | 2693 '''); |
| 2658 resolveTestUnit(''' | 2694 resolveTestUnit(''' |
| 2659 main() { | 2695 main() { |
| (...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4532 int offset = resultCode.indexOf(search); | 4568 int offset = resultCode.indexOf(search); |
| 4533 positions.add(new Position(testFile, offset)); | 4569 positions.add(new Position(testFile, offset)); |
| 4534 } | 4570 } |
| 4535 return positions; | 4571 return positions; |
| 4536 } | 4572 } |
| 4537 | 4573 |
| 4538 void _performAnalysis() { | 4574 void _performAnalysis() { |
| 4539 while (context.performAnalysisTask().hasMoreWork); | 4575 while (context.performAnalysisTask().hasMoreWork); |
| 4540 } | 4576 } |
| 4541 } | 4577 } |
| OLD | NEW |