Chromium Code Reviews| 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.assist; | 5 library test.services.correction.assist; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; | 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; |
| 10 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 10 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1425 DartAssistKind.CONVERT_TO_FIELD_PARAMETER, | 1425 DartAssistKind.CONVERT_TO_FIELD_PARAMETER, |
| 1426 ''' | 1426 ''' |
| 1427 class A { | 1427 class A { |
| 1428 double aaa2; | 1428 double aaa2; |
| 1429 int bbb2; | 1429 int bbb2; |
| 1430 A(int aaa, this.bbb2) : aaa2 = aaa; | 1430 A(int aaa, this.bbb2) : aaa2 = aaa; |
| 1431 } | 1431 } |
| 1432 '''); | 1432 '''); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 test_convertToFinalField_BAD_notExpressionBody() async { | |
|
Brian Wilkerson
2016/07/12 19:52:24
What about
class A {
int get foo => 3;
set fo
scheglov
2016/07/12 20:26:28
Thank you.
Fixed.
| |
| 1436 resolveTestUnit(''' | |
| 1437 class A { | |
| 1438 int get foo { | |
| 1439 int v = 1 + 2; | |
| 1440 return v + 3; | |
| 1441 } | |
| 1442 } | |
| 1443 '''); | |
| 1444 await assertNoAssist(DartAssistKind.CONVERT_INTO_FINAL_FIELD); | |
| 1445 } | |
| 1446 | |
| 1447 test_convertToFinalField_BAD_notGetter() async { | |
| 1448 resolveTestUnit(''' | |
| 1449 class A { | |
| 1450 int foo() => 42; | |
| 1451 } | |
| 1452 '''); | |
| 1453 await assertNoAssist(DartAssistKind.CONVERT_INTO_FINAL_FIELD); | |
| 1454 } | |
| 1455 | |
| 1456 test_convertToFinalField_OK_hasOverride() async { | |
| 1457 resolveTestUnit(''' | |
| 1458 const myAnnotation = const Object(); | |
| 1459 class A { | |
| 1460 @myAnnotation | |
| 1461 int get foo => 42; | |
| 1462 } | |
| 1463 '''); | |
| 1464 await assertHasAssistAt( | |
| 1465 'get foo', | |
| 1466 DartAssistKind.CONVERT_INTO_FINAL_FIELD, | |
| 1467 ''' | |
| 1468 const myAnnotation = const Object(); | |
| 1469 class A { | |
| 1470 @myAnnotation | |
| 1471 final int foo = 42; | |
| 1472 } | |
| 1473 '''); | |
| 1474 } | |
| 1475 | |
| 1476 test_convertToFinalField_OK_notNull() async { | |
| 1477 resolveTestUnit(''' | |
| 1478 class A { | |
| 1479 int get foo => 1 + 2; | |
| 1480 } | |
| 1481 '''); | |
| 1482 await assertHasAssistAt( | |
| 1483 'get foo', | |
| 1484 DartAssistKind.CONVERT_INTO_FINAL_FIELD, | |
| 1485 ''' | |
| 1486 class A { | |
| 1487 final int foo = 1 + 2; | |
| 1488 } | |
| 1489 '''); | |
| 1490 } | |
| 1491 | |
| 1492 test_convertToFinalField_OK_null() async { | |
| 1493 resolveTestUnit(''' | |
| 1494 class A { | |
| 1495 int get foo => null; | |
| 1496 } | |
| 1497 '''); | |
| 1498 await assertHasAssistAt( | |
| 1499 'get foo', | |
| 1500 DartAssistKind.CONVERT_INTO_FINAL_FIELD, | |
| 1501 ''' | |
| 1502 class A { | |
| 1503 final int foo; | |
| 1504 } | |
| 1505 '''); | |
| 1506 } | |
| 1507 | |
| 1508 test_convertToFinalField_OK_onName() async { | |
| 1509 resolveTestUnit(''' | |
| 1510 class A { | |
| 1511 int get foo => 42; | |
| 1512 } | |
| 1513 '''); | |
| 1514 await assertHasAssistAt( | |
| 1515 'foo', | |
| 1516 DartAssistKind.CONVERT_INTO_FINAL_FIELD, | |
| 1517 ''' | |
| 1518 class A { | |
| 1519 final int foo = 42; | |
| 1520 } | |
| 1521 '''); | |
| 1522 } | |
| 1523 | |
| 1524 test_convertToFinalField_OK_onReturnType_parameterized() async { | |
| 1525 resolveTestUnit(''' | |
| 1526 class A { | |
| 1527 List<int> get foo => null; | |
| 1528 } | |
| 1529 '''); | |
| 1530 await assertHasAssistAt( | |
| 1531 'nt> get', | |
| 1532 DartAssistKind.CONVERT_INTO_FINAL_FIELD, | |
| 1533 ''' | |
| 1534 class A { | |
| 1535 final List<int> foo; | |
| 1536 } | |
| 1537 '''); | |
| 1538 } | |
| 1539 | |
| 1540 test_convertToFinalField_OK_onReturnType_simple() async { | |
| 1541 resolveTestUnit(''' | |
| 1542 class A { | |
| 1543 int get foo => 42; | |
| 1544 } | |
| 1545 '''); | |
| 1546 await assertHasAssistAt( | |
| 1547 'int get', | |
| 1548 DartAssistKind.CONVERT_INTO_FINAL_FIELD, | |
| 1549 ''' | |
| 1550 class A { | |
| 1551 final int foo = 42; | |
| 1552 } | |
| 1553 '''); | |
| 1554 } | |
| 1555 | |
| 1435 test_convertToForIndex_BAD_bodyNotBlock() async { | 1556 test_convertToForIndex_BAD_bodyNotBlock() async { |
| 1436 resolveTestUnit(''' | 1557 resolveTestUnit(''' |
| 1437 main(List<String> items) { | 1558 main(List<String> items) { |
| 1438 for (String item in items) print(item); | 1559 for (String item in items) print(item); |
| 1439 } | 1560 } |
| 1440 '''); | 1561 '''); |
| 1441 await assertNoAssistAt( | 1562 await assertNoAssistAt( |
| 1442 'for (String', DartAssistKind.CONVERT_INTO_FOR_INDEX); | 1563 'for (String', DartAssistKind.CONVERT_INTO_FOR_INDEX); |
| 1443 } | 1564 } |
| 1444 | 1565 |
| (...skipping 2504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3949 positions.add(new Position(testFile, offset)); | 4070 positions.add(new Position(testFile, offset)); |
| 3950 } | 4071 } |
| 3951 return positions; | 4072 return positions; |
| 3952 } | 4073 } |
| 3953 | 4074 |
| 3954 void _setStartEndSelection() { | 4075 void _setStartEndSelection() { |
| 3955 offset = findOffset('// start\n') + '// start\n'.length; | 4076 offset = findOffset('// start\n') + '// start\n'.length; |
| 3956 length = findOffset('// end') - offset; | 4077 length = findOffset('// end') - offset; |
| 3957 } | 4078 } |
| 3958 } | 4079 } |
| OLD | NEW |