|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2012 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2013 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 620-628
Link Here
|
| 620 |
AssistContext context= getCorrectionContext(cu, offset, string.length()); |
620 |
AssistContext context= getCorrectionContext(cu, offset, string.length()); |
| 621 |
List proposals= collectAssists(context, false); |
621 |
List proposals= collectAssists(context, false); |
| 622 |
|
622 |
|
|
|
623 |
assertNumberOfProposals(proposals, 3); |
| 623 |
assertCorrectLabels(proposals); |
624 |
assertCorrectLabels(proposals); |
| 624 |
|
625 |
|
| 625 |
String[] expected= new String[2]; |
626 |
String[] expected= new String[3]; |
| 626 |
|
627 |
|
| 627 |
buf= new StringBuffer(); |
628 |
buf= new StringBuffer(); |
| 628 |
buf.append("package test1;\n"); |
629 |
buf.append("package test1;\n"); |
|
Lines 644-649
Link Here
|
| 644 |
buf.append(" }\n"); |
645 |
buf.append(" }\n"); |
| 645 |
buf.append("}\n"); |
646 |
buf.append("}\n"); |
| 646 |
expected[1]= buf.toString(); |
647 |
expected[1]= buf.toString(); |
|
|
648 |
|
| 649 |
buf= new StringBuffer(); |
| 650 |
buf.append("package test1;\n"); |
| 651 |
buf.append("public class E {\n"); |
| 652 |
buf.append(" private int[] fField;\n"); |
| 653 |
buf.append(" public void foo() {\n"); |
| 654 |
buf.append(" extracted();\n"); |
| 655 |
buf.append(" }\n"); |
| 656 |
buf.append(" private void extracted() {\n"); |
| 657 |
buf.append(" fField[0];\n"); |
| 658 |
buf.append(" }\n"); |
| 659 |
buf.append("}\n"); |
| 660 |
expected[2]= buf.toString(); |
| 647 |
|
661 |
|
| 648 |
assertExpectedExistInProposals(proposals, expected); |
662 |
assertExpectedExistInProposals(proposals, expected); |
| 649 |
} |
663 |
} |
|
Lines 850-856
Link Here
|
| 850 |
assertNumberOfProposals(proposals, 5); |
864 |
assertNumberOfProposals(proposals, 5); |
| 851 |
assertCorrectLabels(proposals); |
865 |
assertCorrectLabels(proposals); |
| 852 |
|
866 |
|
| 853 |
String[] expecteds= new String[2]; |
867 |
String[] expecteds= new String[5]; |
| 854 |
|
868 |
|
| 855 |
buf= new StringBuffer(); |
869 |
buf= new StringBuffer(); |
| 856 |
buf.append("package test1;\n"); |
870 |
buf.append("package test1;\n"); |
|
Lines 872-877
Link Here
|
| 872 |
buf.append("}\n"); |
886 |
buf.append("}\n"); |
| 873 |
expecteds[1]= buf.toString(); |
887 |
expecteds[1]= buf.toString(); |
| 874 |
|
888 |
|
|
|
889 |
buf= new StringBuffer(); |
| 890 |
buf.append("package test1;\n"); |
| 891 |
buf.append("public class Timer {\n"); |
| 892 |
buf.append(" public static void main(String[] args) {\n"); |
| 893 |
buf.append(" java.util.Timer timer = new java.util.Timer();\n"); |
| 894 |
buf.append(" }\n"); |
| 895 |
buf.append("}\n"); |
| 896 |
expecteds[2]= buf.toString(); |
| 897 |
|
| 898 |
buf= new StringBuffer(); |
| 899 |
buf.append("package test1;\n"); |
| 900 |
buf.append("public class Timer {\n"); |
| 901 |
buf.append(" public static void main(String[] args) {\n"); |
| 902 |
buf.append(" java.util.Timer timer = new java.util.Timer();\n"); |
| 903 |
buf.append(" }\n"); |
| 904 |
buf.append("}\n"); |
| 905 |
expecteds[3]= buf.toString(); |
| 906 |
|
| 907 |
buf= new StringBuffer(); |
| 908 |
buf.append("package test1;\n"); |
| 909 |
buf.append("public class Timer {\n"); |
| 910 |
buf.append(" private static final java.util.Timer TIMER = new java.util.Timer();\n"); |
| 911 |
buf.append("\n"); |
| 912 |
buf.append(" public static void main(String[] args) {\n"); |
| 913 |
buf.append(" new java.util.Timer();\n"); |
| 914 |
buf.append(" }\n"); |
| 915 |
buf.append("}\n"); |
| 916 |
expecteds[4]= buf.toString(); |
| 917 |
|
| 875 |
assertExpectedExistInProposals(proposals, expecteds); |
918 |
assertExpectedExistInProposals(proposals, expecteds); |
| 876 |
} |
919 |
} |
| 877 |
|
920 |
|
|
Lines 1297-1303
Link Here
|
| 1297 |
buf.append("}\n"); |
1340 |
buf.append("}\n"); |
| 1298 |
String ex1= buf.toString(); |
1341 |
String ex1= buf.toString(); |
| 1299 |
|
1342 |
|
| 1300 |
assertExpectedExistInProposals(proposals, new String[] { ex1 }); |
1343 |
buf= new StringBuffer(); |
|
|
1344 |
buf.append("package test1;\n"); |
| 1345 |
buf.append("public class E {\n"); |
| 1346 |
buf.append(" public E() {\n"); |
| 1347 |
buf.append(" int a = 1;\n"); |
| 1348 |
buf.append(" int b = 1;\n"); |
| 1349 |
buf.append(" int i = a + b;\n"); |
| 1350 |
buf.append(" int d = i;\n"); |
| 1351 |
buf.append(" }\n"); |
| 1352 |
buf.append("}\n"); |
| 1353 |
String ex2= buf.toString(); |
| 1354 |
|
| 1355 |
buf= new StringBuffer(); |
| 1356 |
buf.append("package test1;\n"); |
| 1357 |
buf.append("public class E {\n"); |
| 1358 |
buf.append(" public E() {\n"); |
| 1359 |
buf.append(" int a = 1;\n"); |
| 1360 |
buf.append(" int b = 1;\n"); |
| 1361 |
buf.append(" int d = extracted(a, b);\n"); |
| 1362 |
buf.append(" }\n"); |
| 1363 |
buf.append("\n"); |
| 1364 |
buf.append(" private int extracted(int a, int b) {\n"); |
| 1365 |
buf.append(" return a + b;\n"); |
| 1366 |
buf.append(" }\n"); |
| 1367 |
buf.append("}\n"); |
| 1368 |
String ex3= buf.toString(); |
| 1369 |
|
| 1370 |
buf= new StringBuffer(); |
| 1371 |
buf.append("package test1;\n"); |
| 1372 |
buf.append("public class E {\n"); |
| 1373 |
buf.append(" public E() {\n"); |
| 1374 |
buf.append(" int a = 1;\n"); |
| 1375 |
buf.append(" int b = 1;\n"); |
| 1376 |
buf.append(" int d = (a + b);\n"); |
| 1377 |
buf.append(" }\n"); |
| 1378 |
buf.append("}\n"); |
| 1379 |
String ex4= buf.toString(); |
| 1380 |
|
| 1381 |
buf= new StringBuffer(); |
| 1382 |
buf.append("package test1;\n"); |
| 1383 |
buf.append("public class E {\n"); |
| 1384 |
buf.append(" public E() {\n"); |
| 1385 |
buf.append(" int a = 1;\n"); |
| 1386 |
buf.append(" int b = 1;\n"); |
| 1387 |
buf.append(" int d = b + a;\n"); |
| 1388 |
buf.append(" }\n"); |
| 1389 |
buf.append("}\n"); |
| 1390 |
String ex5= buf.toString(); |
| 1391 |
|
| 1392 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3, ex4, ex5 }); |
| 1301 |
} |
1393 |
} |
| 1302 |
|
1394 |
|
| 1303 |
public void testExtractToLocalVariable2() throws Exception { |
1395 |
public void testExtractToLocalVariable2() throws Exception { |
|
Lines 1336-1342
Link Here
|
| 1336 |
buf.append("}\n"); |
1428 |
buf.append("}\n"); |
| 1337 |
String ex1= buf.toString(); |
1429 |
String ex1= buf.toString(); |
| 1338 |
|
1430 |
|
| 1339 |
assertExpectedExistInProposals(proposals, new String[] { ex1 }); |
1431 |
buf= new StringBuffer(); |
|
|
1432 |
buf.append("package test1;\n"); |
| 1433 |
buf.append("public class E {\n"); |
| 1434 |
buf.append(" public E() {\n"); |
| 1435 |
buf.append(" int a = 1;\n"); |
| 1436 |
buf.append(" int b = 1;\n"); |
| 1437 |
buf.append(" int c = 1;\n"); |
| 1438 |
buf.append(" int i = b + c;\n"); |
| 1439 |
buf.append(" int d = a + i;\n"); |
| 1440 |
buf.append(" }\n"); |
| 1441 |
buf.append("}\n"); |
| 1442 |
String ex2= buf.toString(); |
| 1443 |
|
| 1444 |
buf= new StringBuffer(); |
| 1445 |
buf.append("package test1;\n"); |
| 1446 |
buf.append("public class E {\n"); |
| 1447 |
buf.append(" public E() {\n"); |
| 1448 |
buf.append(" int a = 1;\n"); |
| 1449 |
buf.append(" int b = 1;\n"); |
| 1450 |
buf.append(" int c = 1;\n"); |
| 1451 |
buf.append(" int d = c + a + b;\n"); |
| 1452 |
buf.append(" }\n"); |
| 1453 |
buf.append("}\n"); |
| 1454 |
String ex3= buf.toString(); |
| 1455 |
|
| 1456 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3 }); |
| 1340 |
} |
1457 |
} |
| 1341 |
|
1458 |
|
| 1342 |
public void testExtractToLocalVariable3() throws Exception { |
1459 |
public void testExtractToLocalVariable3() throws Exception { |
|
Lines 1377-1383
Link Here
|
| 1377 |
buf.append("}\n"); |
1494 |
buf.append("}\n"); |
| 1378 |
String ex1= buf.toString(); |
1495 |
String ex1= buf.toString(); |
| 1379 |
|
1496 |
|
| 1380 |
assertExpectedExistInProposals(proposals, new String[] { ex1 }); |
1497 |
buf= new StringBuffer(); |
|
|
1498 |
buf.append("package test1;\n"); |
| 1499 |
buf.append("public class E {\n"); |
| 1500 |
buf.append(" public E() {\n"); |
| 1501 |
buf.append(" int a = 1;\n"); |
| 1502 |
buf.append(" int b = 1;\n"); |
| 1503 |
buf.append(" int c = 1;\n"); |
| 1504 |
buf.append(" int i = b + c;\n"); |
| 1505 |
buf.append(" int d = a + i;\n"); |
| 1506 |
buf.append(" int e = a + b + c;\n"); |
| 1507 |
buf.append(" }\n"); |
| 1508 |
buf.append("}\n"); |
| 1509 |
String ex2= buf.toString(); |
| 1510 |
|
| 1511 |
buf= new StringBuffer(); |
| 1512 |
buf.append("package test1;\n"); |
| 1513 |
buf.append("public class E {\n"); |
| 1514 |
buf.append(" public E() {\n"); |
| 1515 |
buf.append(" int a = 1;\n"); |
| 1516 |
buf.append(" int b = 1;\n"); |
| 1517 |
buf.append(" int c = 1;\n"); |
| 1518 |
buf.append(" int d = c + a + b;\n"); |
| 1519 |
buf.append(" int e = a + b + c;\n"); |
| 1520 |
buf.append(" }\n"); |
| 1521 |
buf.append("}\n"); |
| 1522 |
String ex3= buf.toString(); |
| 1523 |
|
| 1524 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3 }); |
| 1381 |
} |
1525 |
} |
| 1382 |
|
1526 |
|
| 1383 |
public void testExtractToMethod1() throws Exception { |
1527 |
public void testExtractToMethod1() throws Exception { |
|
Lines 1417-1423
Link Here
|
| 1417 |
buf.append("}\n"); |
1561 |
buf.append("}\n"); |
| 1418 |
String ex1= buf.toString(); |
1562 |
String ex1= buf.toString(); |
| 1419 |
|
1563 |
|
| 1420 |
assertExpectedExistInProposals(proposals, new String[] { ex1 }); |
1564 |
buf= new StringBuffer(); |
|
|
1565 |
buf.append("package test1;\n"); |
| 1566 |
buf.append("public class E {\n"); |
| 1567 |
buf.append(" public E() {\n"); |
| 1568 |
buf.append(" int a = 1;\n"); |
| 1569 |
buf.append(" int b = 1;\n"); |
| 1570 |
buf.append(" int i = a + b;\n"); |
| 1571 |
buf.append(" int d = i;\n"); |
| 1572 |
buf.append(" }\n"); |
| 1573 |
buf.append("}\n"); |
| 1574 |
String ex2= buf.toString(); |
| 1575 |
|
| 1576 |
buf= new StringBuffer(); |
| 1577 |
buf.append("package test1;\n"); |
| 1578 |
buf.append("public class E {\n"); |
| 1579 |
buf.append(" public E() {\n"); |
| 1580 |
buf.append(" int a = 1;\n"); |
| 1581 |
buf.append(" int b = 1;\n"); |
| 1582 |
buf.append(" int i = a + b;\n"); |
| 1583 |
buf.append(" int d = i;\n"); |
| 1584 |
buf.append(" }\n"); |
| 1585 |
buf.append("}\n"); |
| 1586 |
String ex3= buf.toString(); |
| 1587 |
|
| 1588 |
buf= new StringBuffer(); |
| 1589 |
buf.append("package test1;\n"); |
| 1590 |
buf.append("public class E {\n"); |
| 1591 |
buf.append(" public E() {\n"); |
| 1592 |
buf.append(" int a = 1;\n"); |
| 1593 |
buf.append(" int b = 1;\n"); |
| 1594 |
buf.append(" int d = (a + b);\n"); |
| 1595 |
buf.append(" }\n"); |
| 1596 |
buf.append("}\n"); |
| 1597 |
String ex4= buf.toString(); |
| 1598 |
|
| 1599 |
buf= new StringBuffer(); |
| 1600 |
buf.append("package test1;\n"); |
| 1601 |
buf.append("public class E {\n"); |
| 1602 |
buf.append(" public E() {\n"); |
| 1603 |
buf.append(" int a = 1;\n"); |
| 1604 |
buf.append(" int b = 1;\n"); |
| 1605 |
buf.append(" int d = b + a;\n"); |
| 1606 |
buf.append(" }\n"); |
| 1607 |
buf.append("}\n"); |
| 1608 |
String ex5= buf.toString(); |
| 1609 |
|
| 1610 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3, ex4, ex5 }); |
| 1421 |
} |
1611 |
} |
| 1422 |
|
1612 |
|
| 1423 |
public void testExtractToMethod2() throws Exception { |
1613 |
public void testExtractToMethod2() throws Exception { |
|
Lines 1457-1463
Link Here
|
| 1457 |
buf.append("}\n"); |
1647 |
buf.append("}\n"); |
| 1458 |
String ex1= buf.toString(); |
1648 |
String ex1= buf.toString(); |
| 1459 |
|
1649 |
|
| 1460 |
assertExpectedExistInProposals(proposals, new String[] { ex1 }); |
1650 |
buf= new StringBuffer(); |
|
|
1651 |
buf.append("package test1;\n"); |
| 1652 |
buf.append("public class E {\n"); |
| 1653 |
buf.append(" void foo() {\n"); |
| 1654 |
buf.append(" int a = 1;\n"); |
| 1655 |
buf.append(" final int b = 1;\n"); |
| 1656 |
buf.append(" final int d = a + b;\n"); |
| 1657 |
buf.append(" }\n"); |
| 1658 |
buf.append("}\n"); |
| 1659 |
String ex2= buf.toString(); |
| 1660 |
|
| 1661 |
buf= new StringBuffer(); |
| 1662 |
String ex3= null; // Wrap in buf.append() (to clipboard) |
| 1663 |
|
| 1664 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3 }); |
| 1461 |
} |
1665 |
} |
| 1462 |
|
1666 |
|
| 1463 |
public void testExtractToMethod3() throws Exception { |
1667 |
public void testExtractToMethod3() throws Exception { |
|
Lines 1497-1503
Link Here
|
| 1497 |
buf.append("}\n"); |
1701 |
buf.append("}\n"); |
| 1498 |
String ex1= buf.toString(); |
1702 |
String ex1= buf.toString(); |
| 1499 |
|
1703 |
|
| 1500 |
assertExpectedExistInProposals(proposals, new String[] { ex1 }); |
1704 |
buf= new StringBuffer(); |
|
|
1705 |
buf.append("package test1;\n"); |
| 1706 |
buf.append("public class E {\n"); |
| 1707 |
buf.append(" void foo() {\n"); |
| 1708 |
buf.append(" final int a = 1;\n"); |
| 1709 |
buf.append(" final int b = 1;\n"); |
| 1710 |
buf.append(" final int d = a + b;\n"); |
| 1711 |
buf.append(" }\n"); |
| 1712 |
buf.append("}\n"); |
| 1713 |
String ex2= buf.toString(); |
| 1714 |
|
| 1715 |
buf= new StringBuffer(); |
| 1716 |
String ex3= null; // Wrap in buf.append() (to clipboard) |
| 1717 |
|
| 1718 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3 }); |
| 1501 |
} |
1719 |
} |
| 1502 |
|
1720 |
|
| 1503 |
public void testExtractToMethod4() throws Exception { |
1721 |
public void testExtractToMethod4() throws Exception { |
|
Lines 1540-1546
Link Here
|
| 1540 |
buf.append("}\n"); |
1758 |
buf.append("}\n"); |
| 1541 |
String ex1= buf.toString(); |
1759 |
String ex1= buf.toString(); |
| 1542 |
|
1760 |
|
| 1543 |
assertExpectedExistInProposals(proposals, new String[] { ex1 }); |
1761 |
buf= new StringBuffer(); |
|
|
1762 |
buf.append("package test1;\n"); |
| 1763 |
buf.append("public class E {\n"); |
| 1764 |
buf.append(" void foo() {\n"); |
| 1765 |
buf.append(" int i = 0;\n"); |
| 1766 |
buf.append(" for (; true;) {\n"); |
| 1767 |
buf.append(" int j = i++;\n"); |
| 1768 |
buf.append(" }\n"); |
| 1769 |
buf.append(" }\n"); |
| 1770 |
buf.append("}\n"); |
| 1771 |
String ex2= buf.toString(); |
| 1772 |
|
| 1773 |
buf= new StringBuffer(); |
| 1774 |
buf.append("package test1;\n"); |
| 1775 |
buf.append("public class E {\n"); |
| 1776 |
buf.append(" private int j;\n"); |
| 1777 |
buf.append("\n"); |
| 1778 |
buf.append(" void foo() {\n"); |
| 1779 |
buf.append(" int i = 0;\n"); |
| 1780 |
buf.append(" for (; true;)\n"); |
| 1781 |
buf.append(" j = i++;\n"); |
| 1782 |
buf.append(" }\n"); |
| 1783 |
buf.append("}\n"); |
| 1784 |
String ex3= buf.toString(); |
| 1785 |
|
| 1786 |
buf= new StringBuffer(); |
| 1787 |
buf.append("package test1;\n"); |
| 1788 |
buf.append("public class E {\n"); |
| 1789 |
buf.append(" void foo() {\n"); |
| 1790 |
buf.append(" int i = 0;\n"); |
| 1791 |
buf.append(" for (; true;) {\n"); |
| 1792 |
buf.append(" i++;\n"); |
| 1793 |
buf.append(" }\n"); |
| 1794 |
buf.append(" }\n"); |
| 1795 |
buf.append("}\n"); |
| 1796 |
String ex4= buf.toString(); |
| 1797 |
|
| 1798 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3, ex4 }); |
| 1544 |
} |
1799 |
} |
| 1545 |
|
1800 |
|
| 1546 |
public void testReplaceCatchClauseWithThrowsWithFinally() throws Exception { |
1801 |
public void testReplaceCatchClauseWithThrowsWithFinally() throws Exception { |
|
Lines 1705-1710
Link Here
|
| 1705 |
buf.append(" }\n"); |
1960 |
buf.append(" }\n"); |
| 1706 |
buf.append("}\n"); |
1961 |
buf.append("}\n"); |
| 1707 |
assertEqualString(preview, buf.toString()); |
1962 |
assertEqualString(preview, buf.toString()); |
|
|
1963 |
|
| 1964 |
proposal= (CUCorrectionProposal)proposals.get(1); |
| 1965 |
preview= getPreviewContent(proposal); |
| 1966 |
|
| 1967 |
buf= new StringBuffer(); |
| 1968 |
buf.append("package test1;\n"); |
| 1969 |
buf.append("public class E {\n"); |
| 1970 |
buf.append(" public void foo() {\n"); |
| 1971 |
buf.append(" for (int i= 0; i < 3; i++)\n"); |
| 1972 |
buf.append(" goo();\n"); |
| 1973 |
buf.append(" }\n"); |
| 1974 |
buf.append("}\n"); |
| 1975 |
assertEqualString(preview, buf.toString()); |
| 1708 |
} |
1976 |
} |
| 1709 |
|
1977 |
|
| 1710 |
public void testUnwrapDoStatement() throws Exception { |
1978 |
public void testUnwrapDoStatement() throws Exception { |
|
Lines 1802-1808
Link Here
|
| 1802 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0); |
2070 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0); |
| 1803 |
List proposals= collectAssists(context, false); |
2071 |
List proposals= collectAssists(context, false); |
| 1804 |
|
2072 |
|
| 1805 |
assertNumberOfProposals(proposals, 3); |
2073 |
assertNumberOfProposals(proposals, 4); |
| 1806 |
assertCorrectLabels(proposals); |
2074 |
assertCorrectLabels(proposals); |
| 1807 |
|
2075 |
|
| 1808 |
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
2076 |
CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); |
|
Lines 1838-1844
Link Here
|
| 1838 |
buf.append("}\n"); |
2106 |
buf.append("}\n"); |
| 1839 |
String expected2= buf.toString(); |
2107 |
String expected2= buf.toString(); |
| 1840 |
|
2108 |
|
| 1841 |
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); |
2109 |
proposal= (CUCorrectionProposal)proposals.get(2); |
|
|
2110 |
String preview3= getPreviewContent(proposal); |
| 2111 |
|
| 2112 |
buf= new StringBuffer(); |
| 2113 |
buf.append("package test1;\n"); |
| 2114 |
buf.append("public class E {\n"); |
| 2115 |
buf.append(" public void foo() {\n"); |
| 2116 |
buf.append(" if (1+ 3 != 6)\n"); |
| 2117 |
buf.append(" return;\n"); |
| 2118 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 2119 |
buf.append(" buf.append(1);\n"); |
| 2120 |
buf.append(" buf.append(2);\n"); |
| 2121 |
buf.append(" buf.append(3);\n"); |
| 2122 |
buf.append(" }\n"); |
| 2123 |
buf.append("}\n"); |
| 2124 |
String expected3= buf.toString(); |
| 2125 |
|
| 2126 |
proposal= (CUCorrectionProposal)proposals.get(3); |
| 2127 |
String preview4= getPreviewContent(proposal); |
| 2128 |
|
| 2129 |
buf= new StringBuffer(); |
| 2130 |
buf.append("package test1;\n"); |
| 2131 |
buf.append("public class E {\n"); |
| 2132 |
buf.append(" public void foo() {\n"); |
| 2133 |
buf.append(" switch (6) {\n"); |
| 2134 |
buf.append(" case 1+ 3 :\n"); |
| 2135 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 2136 |
buf.append(" buf.append(1);\n"); |
| 2137 |
buf.append(" buf.append(2);\n"); |
| 2138 |
buf.append(" buf.append(3);\n"); |
| 2139 |
buf.append(" break;\n"); |
| 2140 |
buf.append(" }\n"); |
| 2141 |
buf.append(" }\n"); |
| 2142 |
buf.append("}\n"); |
| 2143 |
String expected4= buf.toString(); |
| 2144 |
|
| 2145 |
assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3, preview4 }, new String[] { expected1, expected2, expected3, expected4 }); |
| 1842 |
} |
2146 |
} |
| 1843 |
|
2147 |
|
| 1844 |
public void testUnwrapTryStatement() throws Exception { |
2148 |
public void testUnwrapTryStatement() throws Exception { |
|
Lines 1973-1978
Link Here
|
| 1973 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0); |
2277 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str) + str.length(), 0); |
| 1974 |
List proposals= collectAssists(context, false); |
2278 |
List proposals= collectAssists(context, false); |
| 1975 |
|
2279 |
|
|
|
2280 |
assertNumberOfProposals(proposals, 4); |
| 2281 |
assertCorrectLabels(proposals); |
| 2282 |
|
| 1976 |
buf= new StringBuffer(); |
2283 |
buf= new StringBuffer(); |
| 1977 |
buf.append("package test1;\n"); |
2284 |
buf.append("package test1;\n"); |
| 1978 |
buf.append("public class E {\n"); |
2285 |
buf.append("public class E {\n"); |
|
Lines 1982-1988
Link Here
|
| 1982 |
buf.append("}\n"); |
2289 |
buf.append("}\n"); |
| 1983 |
String expected1= buf.toString(); |
2290 |
String expected1= buf.toString(); |
| 1984 |
|
2291 |
|
| 1985 |
assertExpectedExistInProposals(proposals, new String[] {expected1}); |
2292 |
buf= new StringBuffer(); |
|
|
2293 |
buf.append("package test1;\n"); |
| 2294 |
buf.append("public class E {\n"); |
| 2295 |
buf.append(" public int foo() {\n"); |
| 2296 |
buf.append(" int abs = Math.abs(9+ 8);\n"); |
| 2297 |
buf.append(" return abs;\n"); |
| 2298 |
buf.append(" }\n"); |
| 2299 |
buf.append("}\n"); |
| 2300 |
String expected2= buf.toString(); |
| 2301 |
|
| 2302 |
buf= new StringBuffer(); |
| 2303 |
buf.append("package test1;\n"); |
| 2304 |
buf.append("public class E {\n"); |
| 2305 |
buf.append(" public int foo() {\n"); |
| 2306 |
buf.append(" int abs = Math.abs(9+ 8);\n"); |
| 2307 |
buf.append(" return abs;\n"); |
| 2308 |
buf.append(" }\n"); |
| 2309 |
buf.append("}\n"); |
| 2310 |
String expected3= buf.toString(); |
| 2311 |
|
| 2312 |
buf= new StringBuffer(); |
| 2313 |
buf.append("package test1;\n"); |
| 2314 |
buf.append("public class E {\n"); |
| 2315 |
buf.append(" private static final int ABS = Math.abs(9+ 8);\n"); |
| 2316 |
buf.append("\n"); |
| 2317 |
buf.append(" public int foo() {\n"); |
| 2318 |
buf.append(" return ABS;\n"); |
| 2319 |
buf.append(" }\n"); |
| 2320 |
buf.append("}\n"); |
| 2321 |
String expected4= buf.toString(); |
| 2322 |
|
| 2323 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4 }); |
| 1986 |
} |
2324 |
} |
| 1987 |
|
2325 |
|
| 1988 |
public void testSplitDeclaration1() throws Exception { |
2326 |
public void testSplitDeclaration1() throws Exception { |
|
Lines 2077-2083
Link Here
|
| 2077 |
buf.append(" i = null;\n"); |
2415 |
buf.append(" i = null;\n"); |
| 2078 |
buf.append(" }\n"); |
2416 |
buf.append(" }\n"); |
| 2079 |
buf.append("}\n"); |
2417 |
buf.append("}\n"); |
| 2080 |
assertExpectedExistInProposals(proposals, new String[] { buf.toString() }); |
2418 |
String ex1= buf.toString(); |
|
|
2419 |
|
| 2420 |
buf= new StringBuffer(); |
| 2421 |
buf.append("package test1;\n"); |
| 2422 |
buf.append("public class E {\n"); |
| 2423 |
buf.append(" private int is[];\n"); |
| 2424 |
buf.append("\n"); |
| 2425 |
buf.append(" public void foo() {\n"); |
| 2426 |
buf.append(" is = null;\n"); |
| 2427 |
buf.append(" }\n"); |
| 2428 |
buf.append("}\n"); |
| 2429 |
String ex2= buf.toString(); |
| 2430 |
|
| 2431 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2 }); |
| 2081 |
} |
2432 |
} |
| 2082 |
|
2433 |
|
| 2083 |
public void testSplitDeclaration4() throws Exception { |
2434 |
public void testSplitDeclaration4() throws Exception { |
|
Lines 2236-2243
Link Here
|
| 2236 |
buf.append(" foo();\n"); |
2587 |
buf.append(" foo();\n"); |
| 2237 |
buf.append(" }\n"); |
2588 |
buf.append(" }\n"); |
| 2238 |
buf.append("}\n"); |
2589 |
buf.append("}\n"); |
|
|
2590 |
String ex1= buf.toString(); |
| 2239 |
|
2591 |
|
| 2240 |
assertExpectedExistInProposals(proposals, new String[] { buf.toString() }); |
2592 |
buf= new StringBuffer(); |
|
|
2593 |
buf.append("package test1;\n"); |
| 2594 |
buf.append("public class E {\n"); |
| 2595 |
buf.append(" private int vars[];\n"); |
| 2596 |
buf.append("\n"); |
| 2597 |
buf.append(" public void foo() {\n"); |
| 2598 |
buf.append(" foo();\n"); |
| 2599 |
buf.append(" vars = null;\n"); |
| 2600 |
buf.append(" }\n"); |
| 2601 |
buf.append("}\n"); |
| 2602 |
String ex2= buf.toString(); |
| 2603 |
|
| 2604 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2 }); |
| 2241 |
} |
2605 |
} |
| 2242 |
|
2606 |
|
| 2243 |
|
2607 |
|
|
Lines 2258-2263
Link Here
|
| 2258 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); |
2622 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); |
| 2259 |
List proposals= collectAssists(context, false); |
2623 |
List proposals= collectAssists(context, false); |
| 2260 |
|
2624 |
|
|
|
2625 |
assertNumberOfProposals(proposals, 4); |
| 2261 |
assertCorrectLabels(proposals); |
2626 |
assertCorrectLabels(proposals); |
| 2262 |
|
2627 |
|
| 2263 |
buf= new StringBuffer(); |
2628 |
buf= new StringBuffer(); |
|
Lines 2270-2276
Link Here
|
| 2270 |
buf.append("}\n"); |
2635 |
buf.append("}\n"); |
| 2271 |
String expected1= buf.toString(); |
2636 |
String expected1= buf.toString(); |
| 2272 |
|
2637 |
|
| 2273 |
assertExpectedExistInProposals(proposals, new String[] {expected1}); |
2638 |
buf= new StringBuffer(); |
|
|
2639 |
buf.append("package test1;\n"); |
| 2640 |
buf.append("public class E {\n"); |
| 2641 |
buf.append(" public void foo() {\n"); |
| 2642 |
buf.append(" int var[];\n"); |
| 2643 |
buf.append(" foo();\n"); |
| 2644 |
buf.append(" int[] var2 = var;\n"); |
| 2645 |
buf.append(" var = null;\n"); |
| 2646 |
buf.append(" }\n"); |
| 2647 |
buf.append("}\n"); |
| 2648 |
String expected2= buf.toString(); |
| 2649 |
|
| 2650 |
buf= new StringBuffer(); |
| 2651 |
buf.append("package test1;\n"); |
| 2652 |
buf.append("public class E {\n"); |
| 2653 |
buf.append(" public void foo() {\n"); |
| 2654 |
buf.append(" int var[];\n"); |
| 2655 |
buf.append(" foo();\n"); |
| 2656 |
buf.append(" int[] var2 = var;\n"); |
| 2657 |
buf.append(" var = null;\n"); |
| 2658 |
buf.append(" }\n"); |
| 2659 |
buf.append("}\n"); |
| 2660 |
String expected3= buf.toString(); |
| 2661 |
|
| 2662 |
buf= new StringBuffer(); |
| 2663 |
buf.append("package test1;\n"); |
| 2664 |
buf.append("public class E {\n"); |
| 2665 |
buf.append(" private int vars[];\n"); |
| 2666 |
buf.append("\n"); |
| 2667 |
buf.append(" public void foo() {\n"); |
| 2668 |
buf.append(" foo();\n"); |
| 2669 |
buf.append(" vars = null;\n"); |
| 2670 |
buf.append(" }\n"); |
| 2671 |
buf.append("}\n"); |
| 2672 |
String expected4= buf.toString(); |
| 2673 |
|
| 2674 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4 }); |
| 2274 |
} |
2675 |
} |
| 2275 |
|
2676 |
|
| 2276 |
public void testJoinDeclaration3() throws Exception { |
2677 |
public void testJoinDeclaration3() throws Exception { |
|
Lines 2301-2308
Link Here
|
| 2301 |
buf.append(" foo();\n"); |
2702 |
buf.append(" foo();\n"); |
| 2302 |
buf.append(" }\n"); |
2703 |
buf.append(" }\n"); |
| 2303 |
buf.append("}\n"); |
2704 |
buf.append("}\n"); |
|
|
2705 |
String ex1= buf.toString(); |
| 2304 |
|
2706 |
|
| 2305 |
assertExpectedExistInProposals(proposals, new String[] { buf.toString() }); |
2707 |
buf= new StringBuffer(); |
|
|
2708 |
buf.append("package test1;\n"); |
| 2709 |
buf.append("public class E {\n"); |
| 2710 |
buf.append(" public void foo() {\n"); |
| 2711 |
buf.append(" int var[];\n"); |
| 2712 |
buf.append(" var = null;\n"); |
| 2713 |
buf.append(" foo();\n"); |
| 2714 |
buf.append(" var = new int[10];\n"); |
| 2715 |
buf.append(" }\n"); |
| 2716 |
buf.append("}\n"); |
| 2717 |
String ex2= buf.toString(); |
| 2718 |
|
| 2719 |
buf= new StringBuffer(); |
| 2720 |
buf.append("package test1;\n"); |
| 2721 |
buf.append("public class E {\n"); |
| 2722 |
buf.append(" private int vars[];\n"); |
| 2723 |
buf.append("\n"); |
| 2724 |
buf.append(" public void foo() {\n"); |
| 2725 |
buf.append(" vars = null;\n"); |
| 2726 |
buf.append(" foo();\n"); |
| 2727 |
buf.append(" vars = new int[10];\n"); |
| 2728 |
buf.append(" }\n"); |
| 2729 |
buf.append("}\n"); |
| 2730 |
String ex3= buf.toString(); |
| 2731 |
|
| 2732 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3 }); |
| 2306 |
} |
2733 |
} |
| 2307 |
|
2734 |
|
| 2308 |
public void testJoinDeclaration4() throws Exception { |
2735 |
public void testJoinDeclaration4() throws Exception { |
|
Lines 2345-2352
Link Here
|
| 2345 |
buf.append(" // 3;\n"); |
2772 |
buf.append(" // 3;\n"); |
| 2346 |
buf.append(" }\n"); |
2773 |
buf.append(" }\n"); |
| 2347 |
buf.append("}\n"); |
2774 |
buf.append("}\n"); |
|
|
2775 |
String ex1= buf.toString(); |
| 2776 |
|
| 2777 |
buf= new StringBuffer(); |
| 2778 |
buf.append("package test1;\n"); |
| 2779 |
buf.append("public class E {\n"); |
| 2780 |
buf.append(" private String message;\n"); |
| 2781 |
buf.append("\n"); |
| 2782 |
buf.append(" public void foo() {\n"); |
| 2783 |
buf.append(" // 1;\n"); |
| 2784 |
buf.append(" \n"); |
| 2785 |
buf.append(" \n"); |
| 2786 |
buf.append(" \n"); |
| 2787 |
buf.append(" // 2;\n"); |
| 2788 |
buf.append(" \n"); |
| 2789 |
buf.append(" message = \"\";\n"); |
| 2790 |
buf.append(" \n"); |
| 2791 |
buf.append(" // 3;\n"); |
| 2792 |
buf.append(" }\n"); |
| 2793 |
buf.append("}\n"); |
| 2794 |
String ex2= buf.toString(); |
| 2348 |
|
2795 |
|
| 2349 |
assertExpectedExistInProposals(proposals, new String[] { buf.toString() }); |
2796 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2 }); |
| 2350 |
} |
2797 |
} |
| 2351 |
|
2798 |
|
| 2352 |
public void testJoinDeclaration5() throws Exception { |
2799 |
public void testJoinDeclaration5() throws Exception { |
|
Lines 2390-2397
Link Here
|
| 2390 |
buf.append(" // 3;\n"); |
2837 |
buf.append(" // 3;\n"); |
| 2391 |
buf.append(" }\n"); |
2838 |
buf.append(" }\n"); |
| 2392 |
buf.append("}\n"); |
2839 |
buf.append("}\n"); |
|
|
2840 |
String ex1= buf.toString(); |
| 2841 |
|
| 2842 |
buf= new StringBuffer(); |
| 2843 |
buf.append("package test1;\n"); |
| 2844 |
buf.append("public class E {\n"); |
| 2845 |
buf.append(" public void foo() {\n"); |
| 2846 |
buf.append(" // 1;\n"); |
| 2847 |
buf.append(" \n"); |
| 2848 |
buf.append(" String message;\n"); |
| 2849 |
buf.append(" \n"); |
| 2850 |
buf.append(" // 2;\n"); |
| 2851 |
buf.append(" \n"); |
| 2852 |
buf.append(" String message2 = message;\n"); |
| 2853 |
buf.append(" message = \"\";\n"); |
| 2854 |
buf.append(" \n"); |
| 2855 |
buf.append(" // 3;\n"); |
| 2856 |
buf.append(" }\n"); |
| 2857 |
buf.append("}\n"); |
| 2858 |
String ex2= buf.toString(); |
| 2859 |
|
| 2860 |
buf= new StringBuffer(); |
| 2861 |
buf.append("package test1;\n"); |
| 2862 |
buf.append("public class E {\n"); |
| 2863 |
buf.append(" public void foo() {\n"); |
| 2864 |
buf.append(" // 1;\n"); |
| 2865 |
buf.append(" \n"); |
| 2866 |
buf.append(" String message;\n"); |
| 2867 |
buf.append(" \n"); |
| 2868 |
buf.append(" // 2;\n"); |
| 2869 |
buf.append(" \n"); |
| 2870 |
buf.append(" String message2 = message;\n"); |
| 2871 |
buf.append(" message = \"\";\n"); |
| 2872 |
buf.append(" \n"); |
| 2873 |
buf.append(" // 3;\n"); |
| 2874 |
buf.append(" }\n"); |
| 2875 |
buf.append("}\n"); |
| 2876 |
String ex3= buf.toString(); |
| 2877 |
|
| 2878 |
buf= new StringBuffer(); |
| 2879 |
buf.append("package test1;\n"); |
| 2880 |
buf.append("public class E {\n"); |
| 2881 |
buf.append(" private String message;\n"); |
| 2882 |
buf.append("\n"); |
| 2883 |
buf.append(" public void foo() {\n"); |
| 2884 |
buf.append(" // 1;\n"); |
| 2885 |
buf.append(" \n"); |
| 2886 |
buf.append(" \n"); |
| 2887 |
buf.append(" \n"); |
| 2888 |
buf.append(" // 2;\n"); |
| 2889 |
buf.append(" \n"); |
| 2890 |
buf.append(" message = \"\";\n"); |
| 2891 |
buf.append(" \n"); |
| 2892 |
buf.append(" // 3;\n"); |
| 2893 |
buf.append(" }\n"); |
| 2894 |
buf.append("}\n"); |
| 2895 |
String ex4= buf.toString(); |
| 2393 |
|
2896 |
|
| 2394 |
assertExpectedExistInProposals(proposals, new String[] { buf.toString() }); |
2897 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3, ex4 }); |
| 2395 |
} |
2898 |
} |
| 2396 |
|
2899 |
|
| 2397 |
private static final Class[] FILTER_EQ= { LinkedNamesAssistProposal.class, RenameRefactoringProposal.class, AssignToVariableAssistProposal.class }; |
2900 |
private static final Class[] FILTER_EQ= { LinkedNamesAssistProposal.class, RenameRefactoringProposal.class, AssignToVariableAssistProposal.class }; |
|
Lines 2473-2486
Link Here
|
| 2473 |
buf.append(" \"a\".equals(s);\n"); |
2976 |
buf.append(" \"a\".equals(s);\n"); |
| 2474 |
buf.append(" }\n"); |
2977 |
buf.append(" }\n"); |
| 2475 |
buf.append("}\n"); |
2978 |
buf.append("}\n"); |
| 2476 |
assertExpectedExistInProposals(proposals, new String[] { buf.toString() }); |
2979 |
String ex1= buf.toString(); |
| 2477 |
|
2980 |
|
| 2478 |
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null); |
2981 |
buf= new StringBuffer(); |
|
|
2982 |
buf.append("package test1;\n"); |
| 2983 |
buf.append("public class E {\n"); |
| 2984 |
buf.append(" public void foo() {\n"); |
| 2985 |
buf.append(" String s= \"a\";\n"); |
| 2986 |
buf.append(" boolean equals = s.equals(\"a\");\n"); |
| 2987 |
buf.append(" }\n"); |
| 2988 |
buf.append("}\n"); |
| 2989 |
String ex2= buf.toString(); |
| 2990 |
|
| 2991 |
buf= new StringBuffer(); |
| 2992 |
buf.append("package test1;\n"); |
| 2993 |
buf.append("public class E {\n"); |
| 2994 |
buf.append(" public void foo() {\n"); |
| 2995 |
buf.append(" String s= \"a\";\n"); |
| 2996 |
buf.append(" boolean equals = s.equals(\"a\");\n"); |
| 2997 |
buf.append(" }\n"); |
| 2998 |
buf.append("}\n"); |
| 2999 |
String ex3= buf.toString(); |
| 3000 |
|
| 3001 |
buf= new StringBuffer(); |
| 3002 |
buf.append("package test1;\n"); |
| 3003 |
buf.append("public class E {\n"); |
| 3004 |
buf.append(" public void foo() {\n"); |
| 3005 |
buf.append(" String s= \"a\";\n"); |
| 3006 |
buf.append(" extracted(s);\n"); |
| 3007 |
buf.append(" }\n"); |
| 3008 |
buf.append("\n"); |
| 3009 |
buf.append(" private boolean extracted(String s) {\n"); |
| 3010 |
buf.append(" return s.equals(\"a\");\n"); |
| 3011 |
buf.append(" }\n"); |
| 3012 |
buf.append("}\n"); |
| 3013 |
String ex4= buf.toString(); |
| 3014 |
|
| 3015 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3, ex4 }); |
| 3016 |
|
| 3017 |
cu= pack1.createCompilationUnit("E.java", ex1, true, null); |
| 2479 |
str= "\"a\".equals(s)"; |
3018 |
str= "\"a\".equals(s)"; |
| 2480 |
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); |
3019 |
context= getCorrectionContext(cu, ex1.indexOf(str), 0); |
| 2481 |
proposals= collectAssists(context, FILTER_EQ); |
3020 |
proposals= collectAssists(context, FILTER_EQ); |
| 2482 |
|
3021 |
|
| 2483 |
assertNumberOfProposals(proposals, 5); |
3022 |
assertNumberOfProposals(proposals, 5); |
| 2484 |
assertCorrectLabels(proposals); |
3023 |
assertCorrectLabels(proposals); |
| 2485 |
|
3024 |
|
| 2486 |
buf= new StringBuffer(); |
3025 |
buf= new StringBuffer(); |
|
Lines 2491-2497
Link Here
|
| 2491 |
buf.append(" s.equals(\"a\");\n"); |
3030 |
buf.append(" s.equals(\"a\");\n"); |
| 2492 |
buf.append(" }\n"); |
3031 |
buf.append(" }\n"); |
| 2493 |
buf.append("}\n"); |
3032 |
buf.append("}\n"); |
| 2494 |
assertExpectedExistInProposals(proposals, new String[] { buf.toString() }); |
3033 |
ex1= buf.toString(); |
|
|
3034 |
|
| 3035 |
buf= new StringBuffer(); |
| 3036 |
buf.append("package test1;\n"); |
| 3037 |
buf.append("public class E {\n"); |
| 3038 |
buf.append(" public void foo() {\n"); |
| 3039 |
buf.append(" String string = \"a\";\n"); |
| 3040 |
buf.append(" String s= string;\n"); |
| 3041 |
buf.append(" string.equals(s);\n"); |
| 3042 |
buf.append(" }\n"); |
| 3043 |
buf.append("}\n"); |
| 3044 |
ex2= buf.toString(); |
| 3045 |
|
| 3046 |
buf= new StringBuffer(); |
| 3047 |
buf.append("package test1;\n"); |
| 3048 |
buf.append("public class E {\n"); |
| 3049 |
buf.append(" public void foo() {\n"); |
| 3050 |
buf.append(" String s= \"a\";\n"); |
| 3051 |
buf.append(" String string = \"a\";\n"); |
| 3052 |
buf.append(" string.equals(s);\n"); |
| 3053 |
buf.append(" }\n"); |
| 3054 |
buf.append("}\n"); |
| 3055 |
ex3= buf.toString(); |
| 3056 |
|
| 3057 |
buf= new StringBuffer(); |
| 3058 |
buf.append("package test1;\n"); |
| 3059 |
buf.append("public class E {\n"); |
| 3060 |
buf.append(" private static final String A = \"a\";\n"); |
| 3061 |
buf.append("\n"); |
| 3062 |
buf.append(" public void foo() {\n"); |
| 3063 |
buf.append(" String s= A;\n"); |
| 3064 |
buf.append(" A.equals(s);\n"); |
| 3065 |
buf.append(" }\n"); |
| 3066 |
buf.append("}\n"); |
| 3067 |
ex4= buf.toString(); |
| 3068 |
|
| 3069 |
buf= new StringBuffer(); |
| 3070 |
buf.append("package test1;\n"); |
| 3071 |
buf.append("public class E {\n"); |
| 3072 |
buf.append(" public void foo() {\n"); |
| 3073 |
buf.append(" String s= \"a\";\n"); |
| 3074 |
buf.append(" \"A\".equals(s);\n"); |
| 3075 |
buf.append(" }\n"); |
| 3076 |
buf.append("}\n"); |
| 3077 |
String ex5= buf.toString(); |
| 3078 |
|
| 3079 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2, ex3, ex4, ex5 }); |
| 2495 |
} |
3080 |
} |
| 2496 |
|
3081 |
|
| 2497 |
public void testInvertEquals3() throws Exception { |
3082 |
public void testInvertEquals3() throws Exception { |
|
Lines 2822-2831
Link Here
|
| 2822 |
buf.append(" return \"a\";\n"); |
3407 |
buf.append(" return \"a\";\n"); |
| 2823 |
buf.append(" }\n"); |
3408 |
buf.append(" }\n"); |
| 2824 |
buf.append("}\n"); |
3409 |
buf.append("}\n"); |
| 2825 |
assertEqualString(preview, buf.toString()); |
3410 |
String ex1= buf.toString(); |
|
|
3411 |
assertEqualString(preview, ex1); |
| 2826 |
|
3412 |
|
| 2827 |
cu= pack1.createCompilationUnit("E.java", buf.toString(), true, null); |
3413 |
proposal= (CUCorrectionProposal)proposals.get(1); |
| 2828 |
context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); |
3414 |
preview= getPreviewContent(proposal); |
|
|
3415 |
|
| 3416 |
buf= new StringBuffer(); |
| 3417 |
buf.append("package test1;\n"); |
| 3418 |
buf.append("public class E {\n"); |
| 3419 |
buf.append(" public void foo() {\n"); |
| 3420 |
buf.append(" boolean x = (false && \"a\".equals(get()));\n"); |
| 3421 |
buf.append(" }\n"); |
| 3422 |
buf.append(" String get() {\n"); |
| 3423 |
buf.append(" return \"a\";\n"); |
| 3424 |
buf.append(" }\n"); |
| 3425 |
buf.append("}\n"); |
| 3426 |
String ex2= buf.toString(); |
| 3427 |
assertEqualString(preview, ex2); |
| 3428 |
|
| 3429 |
cu= pack1.createCompilationUnit("E.java", ex1, true, null); |
| 3430 |
context= getCorrectionContext(cu, ex1.indexOf(str), 0); |
| 2829 |
proposals= collectAssists(context, FILTER_EQ); |
3431 |
proposals= collectAssists(context, FILTER_EQ); |
| 2830 |
|
3432 |
|
| 2831 |
assertNumberOfProposals(proposals, 2); |
3433 |
assertNumberOfProposals(proposals, 2); |
|
Lines 2845-2850
Link Here
|
| 2845 |
buf.append(" }\n"); |
3447 |
buf.append(" }\n"); |
| 2846 |
buf.append("}\n"); |
3448 |
buf.append("}\n"); |
| 2847 |
assertEqualString(preview, buf.toString()); |
3449 |
assertEqualString(preview, buf.toString()); |
|
|
3450 |
|
| 3451 |
proposal= (CUCorrectionProposal)proposals.get(1); |
| 3452 |
preview= getPreviewContent(proposal); |
| 3453 |
|
| 3454 |
buf= new StringBuffer(); |
| 3455 |
buf.append("package test1;\n"); |
| 3456 |
buf.append("public class E {\n"); |
| 3457 |
buf.append(" public void foo() {\n"); |
| 3458 |
buf.append(" boolean x = (false && get().equals(\"a\"));\n"); |
| 3459 |
buf.append(" }\n"); |
| 3460 |
buf.append(" String get() {\n"); |
| 3461 |
buf.append(" return \"a\";\n"); |
| 3462 |
buf.append(" }\n"); |
| 3463 |
buf.append("}\n"); |
| 3464 |
assertEqualString(preview, buf.toString()); |
| 2848 |
} |
3465 |
} |
| 2849 |
|
3466 |
|
| 2850 |
public void testInvertEquals9() throws Exception { |
3467 |
public void testInvertEquals9() throws Exception { |
|
Lines 3650-3656
Link Here
|
| 3650 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); |
4267 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); |
| 3651 |
List proposals= collectAssists(context, false); |
4268 |
List proposals= collectAssists(context, false); |
| 3652 |
|
4269 |
|
| 3653 |
assertNumberOfProposals(proposals, 3); |
4270 |
assertNumberOfProposals(proposals, 4); |
| 3654 |
assertCorrectLabels(proposals); |
4271 |
assertCorrectLabels(proposals); |
| 3655 |
|
4272 |
|
| 3656 |
buf= new StringBuffer(); |
4273 |
buf= new StringBuffer(); |
|
Lines 3685-3691
Link Here
|
| 3685 |
buf.append("}\n"); |
4302 |
buf.append("}\n"); |
| 3686 |
String expected3= buf.toString(); |
4303 |
String expected3= buf.toString(); |
| 3687 |
|
4304 |
|
| 3688 |
assertExpectedExistInProposals(proposals, new String[] {expected1, expected2, expected3}); |
4305 |
buf= new StringBuffer(); |
|
|
4306 |
buf.append("package test1;\n"); |
| 4307 |
buf.append("public class E {\n"); |
| 4308 |
buf.append(" public void foo() {\n"); |
| 4309 |
buf.append(" if (false)\n"); |
| 4310 |
buf.append(" return;\n"); |
| 4311 |
buf.append(" ;\n"); |
| 4312 |
buf.append(" }\n"); |
| 4313 |
buf.append("}\n"); |
| 4314 |
String expected4= buf.toString(); |
| 4315 |
|
| 4316 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4 }); |
| 3689 |
} |
4317 |
} |
| 3690 |
|
4318 |
|
| 3691 |
public void testChangeElseStatementToBlock() throws Exception { |
4319 |
public void testChangeElseStatementToBlock() throws Exception { |
|
Lines 4095-4101
Link Here
|
| 4095 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); |
4723 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); |
| 4096 |
List proposals= collectAssists(context, false); |
4724 |
List proposals= collectAssists(context, false); |
| 4097 |
|
4725 |
|
| 4098 |
assertNumberOfProposals(proposals, 3); |
4726 |
assertNumberOfProposals(proposals, 4); |
| 4099 |
assertCorrectLabels(proposals); |
4727 |
assertCorrectLabels(proposals); |
| 4100 |
|
4728 |
|
| 4101 |
buf= new StringBuffer(); |
4729 |
buf= new StringBuffer(); |
|
Lines 4129-4135
Link Here
|
| 4129 |
buf.append("}\n"); |
4757 |
buf.append("}\n"); |
| 4130 |
String expected3= buf.toString(); |
4758 |
String expected3= buf.toString(); |
| 4131 |
|
4759 |
|
| 4132 |
assertExpectedExistInProposals(proposals, new String[] {expected1, expected2, expected3}); |
4760 |
buf= new StringBuffer(); |
|
|
4761 |
buf.append("package test1;\n"); |
| 4762 |
buf.append("public class E {\n"); |
| 4763 |
buf.append(" public void foo() {\n"); |
| 4764 |
buf.append(" if (false)\n"); |
| 4765 |
buf.append(" return;\n"); |
| 4766 |
buf.append(" ;\n"); |
| 4767 |
buf.append(" }\n"); |
| 4768 |
buf.append("}\n"); |
| 4769 |
String expected4= buf.toString(); |
| 4770 |
|
| 4771 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4 }); |
| 4133 |
} |
4772 |
} |
| 4134 |
|
4773 |
|
| 4135 |
public void testRemoveIfBlock02() throws Exception { |
4774 |
public void testRemoveIfBlock02() throws Exception { |
|
Lines 4291-4296
Link Here
|
| 4291 |
AssistContext context= getCorrectionContext(cu, indexOf, 0); |
4930 |
AssistContext context= getCorrectionContext(cu, indexOf, 0); |
| 4292 |
List proposals= collectAssists(context, false); |
4931 |
List proposals= collectAssists(context, false); |
| 4293 |
|
4932 |
|
|
|
4933 |
assertNumberOfProposals(proposals, 4); |
| 4294 |
assertCorrectLabels(proposals); |
4934 |
assertCorrectLabels(proposals); |
| 4295 |
|
4935 |
|
| 4296 |
buf= new StringBuffer(); |
4936 |
buf= new StringBuffer(); |
|
Lines 4305-4311
Link Here
|
| 4305 |
buf.append("}\n"); |
4945 |
buf.append("}\n"); |
| 4306 |
String expected1= buf.toString(); |
4946 |
String expected1= buf.toString(); |
| 4307 |
|
4947 |
|
| 4308 |
assertExpectedExistInProposals(proposals, new String[] {expected1}); |
4948 |
buf= new StringBuffer(); |
|
|
4949 |
buf.append("package test1;\n"); |
| 4950 |
buf.append("public class E {\n"); |
| 4951 |
buf.append(" public int foo() {\n"); |
| 4952 |
buf.append(" if (true) {\n"); |
| 4953 |
buf.append(" return 1; /* comment*/\n"); |
| 4954 |
buf.append(" } else {\n"); |
| 4955 |
buf.append(" return 2;\n"); |
| 4956 |
buf.append(" }\n"); |
| 4957 |
buf.append(" }\n"); |
| 4958 |
buf.append("}\n"); |
| 4959 |
String expected2= buf.toString(); |
| 4960 |
|
| 4961 |
buf= new StringBuffer(); |
| 4962 |
buf.append("package test1;\n"); |
| 4963 |
buf.append("public class E {\n"); |
| 4964 |
buf.append(" public int foo() {\n"); |
| 4965 |
buf.append(" if (false)\n"); |
| 4966 |
buf.append(" return 2;\n"); |
| 4967 |
buf.append(" else\n"); |
| 4968 |
buf.append(" return 1; /* comment*/\n"); |
| 4969 |
buf.append(" }\n"); |
| 4970 |
buf.append("}\n"); |
| 4971 |
String expected3= buf.toString(); |
| 4972 |
|
| 4973 |
buf= new StringBuffer(); |
| 4974 |
buf.append("package test1;\n"); |
| 4975 |
buf.append("public class E {\n"); |
| 4976 |
buf.append(" public int foo() {\n"); |
| 4977 |
buf.append(" return true ? 1 : 2;\n"); |
| 4978 |
buf.append(" }\n"); |
| 4979 |
buf.append("}\n"); |
| 4980 |
String expected4= buf.toString(); |
| 4981 |
|
| 4982 |
assertExpectedExistInProposals(proposals, new String[] {expected1, expected2, expected3, expected4}); |
| 4309 |
} |
4983 |
} |
| 4310 |
|
4984 |
|
| 4311 |
|
4985 |
|
|
Lines 4746-4751
Link Here
|
| 4746 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
5420 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
| 4747 |
List proposals= collectAssists(context, false); |
5421 |
List proposals= collectAssists(context, false); |
| 4748 |
|
5422 |
|
|
|
5423 |
assertNumberOfProposals(proposals, 2); |
| 4749 |
assertCorrectLabels(proposals); |
5424 |
assertCorrectLabels(proposals); |
| 4750 |
|
5425 |
|
| 4751 |
buf= new StringBuffer(); |
5426 |
buf= new StringBuffer(); |
|
Lines 4758-4764
Link Here
|
| 4758 |
buf.append("}\n"); |
5433 |
buf.append("}\n"); |
| 4759 |
String expected1= buf.toString(); |
5434 |
String expected1= buf.toString(); |
| 4760 |
|
5435 |
|
| 4761 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
5436 |
String expected2= null; // Wrap in buf.append() (to clipboard) |
|
|
5437 |
|
| 5438 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2 }); |
| 4762 |
} |
5439 |
} |
| 4763 |
|
5440 |
|
| 4764 |
public void testMakeFinal02() throws Exception { |
5441 |
public void testMakeFinal02() throws Exception { |
|
Lines 4778-4784
Link Here
|
| 4778 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
5455 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
| 4779 |
List proposals= collectAssists(context, false); |
5456 |
List proposals= collectAssists(context, false); |
| 4780 |
|
5457 |
|
|
|
5458 |
assertNumberOfProposals(proposals, 1); |
| 4781 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5459 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
|
|
5460 |
|
| 5461 |
buf= new StringBuffer(); |
| 5462 |
String expected1= null; // Wrap in buf.append() (to clipboard) |
| 5463 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
| 4782 |
} |
5464 |
} |
| 4783 |
|
5465 |
|
| 4784 |
public void testMakeFinal03() throws Exception { |
5466 |
public void testMakeFinal03() throws Exception { |
|
Lines 4797-4803
Link Here
|
| 4797 |
AssistContext context= getCorrectionContext(cu, offset, 1); |
5479 |
AssistContext context= getCorrectionContext(cu, offset, 1); |
| 4798 |
List proposals= collectAssists(context, false); |
5480 |
List proposals= collectAssists(context, false); |
| 4799 |
|
5481 |
|
|
|
5482 |
assertNumberOfProposals(proposals, 1); |
| 4800 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5483 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
|
|
5484 |
|
| 5485 |
buf= new StringBuffer(); |
| 5486 |
buf.append("package test;\n"); |
| 5487 |
buf.append("public class E {\n"); |
| 5488 |
buf.append(" private int i= 0;\n"); |
| 5489 |
buf.append(" private void foo() {\n"); |
| 5490 |
buf.append(" System.out.println(getI());\n"); |
| 5491 |
buf.append(" }\n"); |
| 5492 |
buf.append(" public int getI() {\n"); |
| 5493 |
buf.append(" return i;\n"); |
| 5494 |
buf.append(" }\n"); |
| 5495 |
buf.append(" public void setI(int i) {\n"); |
| 5496 |
buf.append(" this.i = i;\n"); |
| 5497 |
buf.append(" }\n"); |
| 5498 |
buf.append("}\n"); |
| 5499 |
String expected1= buf.toString(); |
| 5500 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
| 4801 |
} |
5501 |
} |
| 4802 |
|
5502 |
|
| 4803 |
public void testMakeFinal04() throws Exception { |
5503 |
public void testMakeFinal04() throws Exception { |
|
Lines 4883-4889
Link Here
|
| 4883 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
5583 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
| 4884 |
List proposals= collectAssists(context, false); |
5584 |
List proposals= collectAssists(context, false); |
| 4885 |
|
5585 |
|
|
|
5586 |
assertNumberOfProposals(proposals, 1); |
| 4886 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5587 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
|
|
5588 |
|
| 5589 |
assertExpectedExistInProposals(proposals, new String[] { null }); // Wrap in buf.append() (to clipboard) |
| 4887 |
} |
5590 |
} |
| 4888 |
|
5591 |
|
| 4889 |
public void testMakeFinal07() throws Exception { |
5592 |
public void testMakeFinal07() throws Exception { |
|
Lines 4906-4911
Link Here
|
| 4906 |
AssistContext context= getCorrectionContext(cu, offset, length); |
5609 |
AssistContext context= getCorrectionContext(cu, offset, length); |
| 4907 |
List proposals= collectAssists(context, false); |
5610 |
List proposals= collectAssists(context, false); |
| 4908 |
|
5611 |
|
|
|
5612 |
assertNumberOfProposals(proposals, 0); |
| 4909 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5613 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
| 4910 |
} |
5614 |
} |
| 4911 |
|
5615 |
|
|
Lines 4929-4935
Link Here
|
| 4929 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
5633 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
| 4930 |
List proposals= collectAssists(context, false); |
5634 |
List proposals= collectAssists(context, false); |
| 4931 |
|
5635 |
|
|
|
5636 |
assertNumberOfProposals(proposals, 1); |
| 4932 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5637 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
|
|
5638 |
|
| 5639 |
assertExpectedExistInProposals(proposals, new String[] { null }); // Wrap in buf.append() (to clipboard) |
| 4933 |
} |
5640 |
} |
| 4934 |
|
5641 |
|
| 4935 |
public void testMakeFinal09() throws Exception { |
5642 |
public void testMakeFinal09() throws Exception { |
|
Lines 4952-4958
Link Here
|
| 4952 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
5659 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
| 4953 |
List proposals= collectAssists(context, false); |
5660 |
List proposals= collectAssists(context, false); |
| 4954 |
|
5661 |
|
|
|
5662 |
assertNumberOfProposals(proposals, 1); |
| 4955 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5663 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
|
|
5664 |
|
| 5665 |
assertExpectedExistInProposals(proposals, new String[] { null }); // Wrap in buf.append() (to clipboard) |
| 4956 |
} |
5666 |
} |
| 4957 |
|
5667 |
|
| 4958 |
public void testMakeFinal10() throws Exception { |
5668 |
public void testMakeFinal10() throws Exception { |
|
Lines 4975-4981
Link Here
|
| 4975 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
5685 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
| 4976 |
List proposals= collectAssists(context, false); |
5686 |
List proposals= collectAssists(context, false); |
| 4977 |
|
5687 |
|
|
|
5688 |
assertNumberOfProposals(proposals, 1); |
| 4978 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5689 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
|
|
5690 |
|
| 5691 |
assertExpectedExistInProposals(proposals, new String[] { null }); // Wrap in buf.append() (to clipboard) |
| 4979 |
} |
5692 |
} |
| 4980 |
|
5693 |
|
| 4981 |
public void testMakeFinal11() throws Exception { |
5694 |
public void testMakeFinal11() throws Exception { |
|
Lines 4996-5002
Link Here
|
| 4996 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
5709 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
| 4997 |
List proposals= collectAssists(context, false); |
5710 |
List proposals= collectAssists(context, false); |
| 4998 |
|
5711 |
|
|
|
5712 |
assertNumberOfProposals(proposals, 1); |
| 4999 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5713 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
|
|
5714 |
|
| 5715 |
assertExpectedExistInProposals(proposals, new String[] { null }); // Wrap in buf.append() (to clipboard) |
| 5000 |
} |
5716 |
} |
| 5001 |
|
5717 |
|
| 5002 |
public void testMakeFinal12() throws Exception { |
5718 |
public void testMakeFinal12() throws Exception { |
|
Lines 5069-5075
Link Here
|
| 5069 |
buf.append(" System.out.println(h);\n"); |
5785 |
buf.append(" System.out.println(h);\n"); |
| 5070 |
buf.append(" }\n"); |
5786 |
buf.append(" }\n"); |
| 5071 |
buf.append("}\n"); |
5787 |
buf.append("}\n"); |
| 5072 |
assertExpectedExistInProposals(proposals, new String[] {buf.toString()}); |
5788 |
String ex1= buf.toString(); |
|
|
5789 |
|
| 5790 |
buf= new StringBuffer(); |
| 5791 |
buf.append("package test;\n"); |
| 5792 |
buf.append("public class E {\n"); |
| 5793 |
buf.append(" public void foo() {\n"); |
| 5794 |
buf.append(" int i= 1, j, h= j + 1;\n"); |
| 5795 |
buf.append(" j = i + 1;\n"); |
| 5796 |
buf.append(" System.out.println(i);\n"); |
| 5797 |
buf.append(" System.out.println(j);\n"); |
| 5798 |
buf.append(" System.out.println(h);\n"); |
| 5799 |
buf.append(" }\n"); |
| 5800 |
buf.append("}\n"); |
| 5801 |
String ex2= buf.toString(); |
| 5802 |
|
| 5803 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2 }); |
| 5073 |
} |
5804 |
} |
| 5074 |
|
5805 |
|
| 5075 |
public void testMakeFinal14() throws Exception { |
5806 |
public void testMakeFinal14() throws Exception { |
|
Lines 5105-5111
Link Here
|
| 5105 |
buf.append(" System.out.println(h);\n"); |
5836 |
buf.append(" System.out.println(h);\n"); |
| 5106 |
buf.append(" }\n"); |
5837 |
buf.append(" }\n"); |
| 5107 |
buf.append("}\n"); |
5838 |
buf.append("}\n"); |
| 5108 |
assertExpectedExistInProposals(proposals, new String[] {buf.toString()}); |
5839 |
String ex1= buf.toString(); |
|
|
5840 |
|
| 5841 |
buf= new StringBuffer(); |
| 5842 |
buf.append("package test;\n"); |
| 5843 |
buf.append("public class E {\n"); |
| 5844 |
buf.append(" public void foo() {\n"); |
| 5845 |
buf.append(" int i= 1, j= i + 1, h;\n"); |
| 5846 |
buf.append(" h = j + 1;\n"); |
| 5847 |
buf.append(" System.out.println(i);\n"); |
| 5848 |
buf.append(" System.out.println(j);\n"); |
| 5849 |
buf.append(" System.out.println(h);\n"); |
| 5850 |
buf.append(" }\n"); |
| 5851 |
buf.append("}\n"); |
| 5852 |
String ex2= buf.toString(); |
| 5853 |
|
| 5854 |
assertExpectedExistInProposals(proposals, new String[] { ex1, ex2 }); |
| 5109 |
} |
5855 |
} |
| 5110 |
|
5856 |
|
| 5111 |
public void testMakeFinal15() throws Exception { |
5857 |
public void testMakeFinal15() throws Exception { |
|
Lines 5132-5137
Link Here
|
| 5132 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
5878 |
AssistContext context= getCorrectionContext(cu, offset1, offset2 - offset1); |
| 5133 |
List proposals= collectAssists(context, false); |
5879 |
List proposals= collectAssists(context, false); |
| 5134 |
|
5880 |
|
|
|
5881 |
assertNumberOfProposals(proposals, 2); |
| 5135 |
assertCorrectLabels(proposals); |
5882 |
assertCorrectLabels(proposals); |
| 5136 |
|
5883 |
|
| 5137 |
buf= new StringBuffer(); |
5884 |
buf= new StringBuffer(); |
|
Lines 5151-5157
Link Here
|
| 5151 |
buf.append("}\n"); |
5898 |
buf.append("}\n"); |
| 5152 |
String expected1= buf.toString(); |
5899 |
String expected1= buf.toString(); |
| 5153 |
|
5900 |
|
| 5154 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
5901 |
String expected2= null; // Wrap in buf.append() (to clipboard) |
|
|
5902 |
|
| 5903 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2 }); |
| 5155 |
} |
5904 |
} |
| 5156 |
|
5905 |
|
| 5157 |
public void testMakeFinal16() throws Exception { |
5906 |
public void testMakeFinal16() throws Exception { |
|
Lines 5171-5176
Link Here
|
| 5171 |
AssistContext context= getCorrectionContext(cu, offset, length); |
5920 |
AssistContext context= getCorrectionContext(cu, offset, length); |
| 5172 |
List proposals= collectAssists(context, false); |
5921 |
List proposals= collectAssists(context, false); |
| 5173 |
|
5922 |
|
|
|
5923 |
assertNumberOfProposals(proposals, 0); |
| 5174 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5924 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
| 5175 |
} |
5925 |
} |
| 5176 |
|
5926 |
|
|
Lines 5189-5196
Link Here
|
| 5189 |
int offset= buf.toString().indexOf("i="); |
5939 |
int offset= buf.toString().indexOf("i="); |
| 5190 |
AssistContext context= getCorrectionContext(cu, offset, 1); |
5940 |
AssistContext context= getCorrectionContext(cu, offset, 1); |
| 5191 |
List proposals= collectAssists(context, false); |
5941 |
List proposals= collectAssists(context, false); |
| 5192 |
|
5942 |
|
|
|
5943 |
assertNumberOfProposals(proposals, 1); |
| 5193 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5944 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
|
|
5945 |
|
| 5946 |
buf= new StringBuffer(); |
| 5947 |
buf.append("package test;\n"); |
| 5948 |
buf.append("public class E {\n"); |
| 5949 |
buf.append(" private int i= 0;\n"); |
| 5950 |
buf.append(" private void foo() {\n"); |
| 5951 |
buf.append(" System.out.println(getI());\n"); |
| 5952 |
buf.append(" }\n"); |
| 5953 |
buf.append(" public int getI() {\n"); |
| 5954 |
buf.append(" return i;\n"); |
| 5955 |
buf.append(" }\n"); |
| 5956 |
buf.append(" public void setI(int i) {\n"); |
| 5957 |
buf.append(" this.i = i;\n"); |
| 5958 |
buf.append(" }\n"); |
| 5959 |
buf.append("}\n"); |
| 5960 |
assertExpectedExistInProposals(proposals, new String[] { buf.toString() }); |
| 5194 |
} |
5961 |
} |
| 5195 |
|
5962 |
|
| 5196 |
public void testMakeFinal18() throws Exception { |
5963 |
public void testMakeFinal18() throws Exception { |
|
Lines 5209-5214
Link Here
|
| 5209 |
AssistContext context= getCorrectionContext(cu, offset, 1); |
5976 |
AssistContext context= getCorrectionContext(cu, offset, 1); |
| 5210 |
List proposals= collectAssists(context, false); |
5977 |
List proposals= collectAssists(context, false); |
| 5211 |
|
5978 |
|
|
|
5979 |
assertNumberOfProposals(proposals, 0); |
| 5212 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
5980 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
| 5213 |
} |
5981 |
} |
| 5214 |
|
5982 |
|
|
Lines 5229-5234
Link Here
|
| 5229 |
AssistContext context= getCorrectionContext(cu, offset, length); |
5997 |
AssistContext context= getCorrectionContext(cu, offset, length); |
| 5230 |
List proposals= collectAssists(context, false); |
5998 |
List proposals= collectAssists(context, false); |
| 5231 |
|
5999 |
|
|
|
6000 |
assertNumberOfProposals(proposals, 0); |
| 5232 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
6001 |
assertProposalDoesNotExist(proposals, CHANGE_MODIFIER_TO_FINAL); |
| 5233 |
} |
6002 |
} |
| 5234 |
|
6003 |
|
|
Lines 5373-5378
Link Here
|
| 5373 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\"+\""), 0); |
6142 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\"+\""), 0); |
| 5374 |
List proposals= collectAssists(context, false); |
6143 |
List proposals= collectAssists(context, false); |
| 5375 |
|
6144 |
|
|
|
6145 |
assertNumberOfProposals(proposals, 7); |
| 5376 |
assertCorrectLabels(proposals); |
6146 |
assertCorrectLabels(proposals); |
| 5377 |
|
6147 |
|
| 5378 |
buf= new StringBuffer(); |
6148 |
buf= new StringBuffer(); |
|
Lines 5387-5395
Link Here
|
| 5387 |
buf.append(" String strX = stringBuilder.toString();\n"); |
6157 |
buf.append(" String strX = stringBuilder.toString();\n"); |
| 5388 |
buf.append(" }\n"); |
6158 |
buf.append(" }\n"); |
| 5389 |
buf.append("}\n"); |
6159 |
buf.append("}\n"); |
| 5390 |
String expected= buf.toString(); |
6160 |
String expected1= buf.toString(); |
| 5391 |
|
6161 |
|
| 5392 |
assertExpectedExistInProposals(proposals, new String[] { expected }); |
6162 |
buf= new StringBuffer(); |
|
|
6163 |
buf.append("package test1;\n"); |
| 6164 |
buf.append("public class A {\n"); |
| 6165 |
buf.append(" public void foo() {\n"); |
| 6166 |
buf.append(" String string = \"foo\";\n"); |
| 6167 |
buf.append(" String strX = string+\"bar\"+\"baz\"+\"biz\";\n"); |
| 6168 |
buf.append(" }\n"); |
| 6169 |
buf.append("}\n"); |
| 6170 |
String expected2= buf.toString(); |
| 6171 |
|
| 6172 |
buf= new StringBuffer(); |
| 6173 |
buf.append("package test1;\n"); |
| 6174 |
buf.append("public class A {\n"); |
| 6175 |
buf.append(" public void foo() {\n"); |
| 6176 |
buf.append(" String string = \"foo\";\n"); |
| 6177 |
buf.append(" String strX = string+\"bar\"+\"baz\"+\"biz\";\n"); |
| 6178 |
buf.append(" }\n"); |
| 6179 |
buf.append("}\n"); |
| 6180 |
String expected3= buf.toString(); |
| 6181 |
|
| 6182 |
buf= new StringBuffer(); |
| 6183 |
buf.append("package test1;\n"); |
| 6184 |
buf.append("public class A {\n"); |
| 6185 |
buf.append(" private static final String FOO = \"foo\";\n"); |
| 6186 |
buf.append("\n"); |
| 6187 |
buf.append(" public void foo() {\n"); |
| 6188 |
buf.append(" String strX = FOO+\"bar\"+\"baz\"+\"biz\";\n"); |
| 6189 |
buf.append(" }\n"); |
| 6190 |
buf.append("}\n"); |
| 6191 |
String expected4= buf.toString(); |
| 6192 |
|
| 6193 |
buf= new StringBuffer(); |
| 6194 |
buf.append("package test1;\n"); |
| 6195 |
buf.append("public class A {\n"); |
| 6196 |
buf.append(" public void foo() {\n"); |
| 6197 |
buf.append(" String strX = (\"foo\"+\"bar\"+\"baz\"+\"biz\");\n"); |
| 6198 |
buf.append(" }\n"); |
| 6199 |
buf.append("}\n"); |
| 6200 |
String expected5= buf.toString(); |
| 6201 |
|
| 6202 |
buf= new StringBuffer(); |
| 6203 |
buf.append("package test1;\n"); |
| 6204 |
buf.append("public class A {\n"); |
| 6205 |
buf.append(" public void foo() {\n"); |
| 6206 |
buf.append(" String strX = \"foobarbazbiz\";\n"); |
| 6207 |
buf.append(" }\n"); |
| 6208 |
buf.append("}\n"); |
| 6209 |
String expected6= buf.toString(); |
| 6210 |
|
| 6211 |
buf= new StringBuffer(); |
| 6212 |
buf.append("package test1;\n"); |
| 6213 |
buf.append("public class A {\n"); |
| 6214 |
buf.append(" public void foo() {\n"); |
| 6215 |
buf.append(" String strX = \"FOO\"+\"bar\"+\"baz\"+\"biz\";\n"); |
| 6216 |
buf.append(" }\n"); |
| 6217 |
buf.append("}\n"); |
| 6218 |
String expected7= buf.toString(); |
| 6219 |
|
| 6220 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5393 |
} |
6221 |
} |
| 5394 |
|
6222 |
|
| 5395 |
public void testConvertToStringBufferStringAndVar() throws Exception { |
6223 |
public void testConvertToStringBufferStringAndVar() throws Exception { |
|
Lines 5408-5413
Link Here
|
| 5408 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
6236 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
| 5409 |
List proposals= collectAssists(context, false); |
6237 |
List proposals= collectAssists(context, false); |
| 5410 |
|
6238 |
|
|
|
6239 |
assertNumberOfProposals(proposals, 5); |
| 5411 |
assertCorrectLabels(proposals); |
6240 |
assertCorrectLabels(proposals); |
| 5412 |
|
6241 |
|
| 5413 |
buf= new StringBuffer(); |
6242 |
buf= new StringBuffer(); |
|
Lines 5423-5431
Link Here
|
| 5423 |
buf.append(" String strX = stringBuilder.toString();\n"); |
6252 |
buf.append(" String strX = stringBuilder.toString();\n"); |
| 5424 |
buf.append(" }\n"); |
6253 |
buf.append(" }\n"); |
| 5425 |
buf.append("}\n"); |
6254 |
buf.append("}\n"); |
| 5426 |
String expected= buf.toString(); |
6255 |
String expected1= buf.toString(); |
| 5427 |
|
6256 |
|
| 5428 |
assertExpectedExistInProposals(proposals, new String[] { expected }); |
6257 |
buf= new StringBuffer(); |
|
|
6258 |
buf.append("package test1;\n"); |
| 6259 |
buf.append("public class A {\n"); |
| 6260 |
buf.append(" public void foo() {\n"); |
| 6261 |
buf.append(" String foo = \"foo\";\n"); |
| 6262 |
buf.append(" String fuu = \"fuu\";\n"); |
| 6263 |
buf.append(" String strX;\n"); |
| 6264 |
buf.append(" strX = foo+\"bar\"+fuu;\n"); |
| 6265 |
buf.append(" }\n"); |
| 6266 |
buf.append("}\n"); |
| 6267 |
String expected2= buf.toString(); |
| 6268 |
|
| 6269 |
buf= new StringBuffer(); |
| 6270 |
buf.append("package test1;\n"); |
| 6271 |
buf.append("public class A {\n"); |
| 6272 |
buf.append(" public void foo() {\n"); |
| 6273 |
buf.append(" String foo = \"foo\";\n"); |
| 6274 |
buf.append(" String fuu = \"fuu\";\n"); |
| 6275 |
buf.append(" }\n"); |
| 6276 |
buf.append("}\n"); |
| 6277 |
String expected3= buf.toString(); |
| 6278 |
|
| 6279 |
buf= new StringBuffer(); |
| 6280 |
buf.append("package test1;\n"); |
| 6281 |
buf.append("public class A {\n"); |
| 6282 |
buf.append(" private String strX;\n"); |
| 6283 |
buf.append("\n"); |
| 6284 |
buf.append(" public void foo() {\n"); |
| 6285 |
buf.append(" String foo = \"foo\";\n"); |
| 6286 |
buf.append(" String fuu = \"fuu\";\n"); |
| 6287 |
buf.append(" strX = foo+\"bar\"+fuu;\n"); |
| 6288 |
buf.append(" }\n"); |
| 6289 |
buf.append("}\n"); |
| 6290 |
String expected4= buf.toString(); |
| 6291 |
|
| 6292 |
buf= new StringBuffer(); |
| 6293 |
buf.append("package test1;\n"); |
| 6294 |
buf.append("\n"); |
| 6295 |
buf.append("import java.text.MessageFormat;\n"); |
| 6296 |
buf.append("\n"); |
| 6297 |
buf.append("public class A {\n"); |
| 6298 |
buf.append(" public void foo() {\n"); |
| 6299 |
buf.append(" String foo = \"foo\";\n"); |
| 6300 |
buf.append(" String fuu = \"fuu\";\n"); |
| 6301 |
buf.append(" String strX = MessageFormat.format(\"{0}bar{1}\", foo, fuu);\n"); |
| 6302 |
buf.append(" }\n"); |
| 6303 |
buf.append("}\n"); |
| 6304 |
String expected5= buf.toString(); |
| 6305 |
|
| 6306 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5 }); |
| 5429 |
} |
6307 |
} |
| 5430 |
|
6308 |
|
| 5431 |
public void testConvertToStringBufferNoFixWithoutString() throws Exception { |
6309 |
public void testConvertToStringBufferNoFixWithoutString() throws Exception { |
|
Lines 5442-5448
Link Here
|
| 5442 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
6320 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
| 5443 |
List proposals= collectAssists(context, false); |
6321 |
List proposals= collectAssists(context, false); |
| 5444 |
|
6322 |
|
|
|
6323 |
assertNumberOfProposals(proposals, 3); |
| 5445 |
assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_STRING_BUFFER_ID); |
6324 |
assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_STRING_BUFFER_ID); |
|
|
6325 |
|
| 6326 |
buf= new StringBuffer(); |
| 6327 |
buf.append("package test1;\n"); |
| 6328 |
buf.append("public class A {\n"); |
| 6329 |
buf.append(" public void foo() {\n"); |
| 6330 |
buf.append(" int strX;\n"); |
| 6331 |
buf.append(" strX = 5+1;\n"); |
| 6332 |
buf.append(" }\n"); |
| 6333 |
buf.append("}\n"); |
| 6334 |
String expected1= buf.toString(); |
| 6335 |
|
| 6336 |
buf= new StringBuffer(); |
| 6337 |
buf.append("package test1;\n"); |
| 6338 |
buf.append("public class A {\n"); |
| 6339 |
buf.append(" public void foo() {\n"); |
| 6340 |
buf.append(" }\n"); |
| 6341 |
buf.append("}\n"); |
| 6342 |
String expected2= buf.toString(); |
| 6343 |
|
| 6344 |
buf= new StringBuffer(); |
| 6345 |
buf.append("package test1;\n"); |
| 6346 |
buf.append("public class A {\n"); |
| 6347 |
buf.append(" private int strX;\n"); |
| 6348 |
buf.append("\n"); |
| 6349 |
buf.append(" public void foo() {\n"); |
| 6350 |
buf.append(" strX = 5+1;\n"); |
| 6351 |
buf.append(" }\n"); |
| 6352 |
buf.append("}\n"); |
| 6353 |
String expected3= buf.toString(); |
| 6354 |
|
| 6355 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3 }); |
| 6356 |
|
| 5446 |
} |
6357 |
} |
| 5447 |
|
6358 |
|
| 5448 |
public void testConvertToStringBufferNoFixWithoutString2() throws Exception { |
6359 |
public void testConvertToStringBufferNoFixWithoutString2() throws Exception { |
|
Lines 5460-5466
Link Here
|
| 5460 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
6371 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
| 5461 |
List proposals= collectAssists(context, false); |
6372 |
List proposals= collectAssists(context, false); |
| 5462 |
|
6373 |
|
|
|
6374 |
assertNumberOfProposals(proposals, 4); |
| 5463 |
assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_STRING_BUFFER_ID); |
6375 |
assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_STRING_BUFFER_ID); |
|
|
6376 |
|
| 6377 |
buf= new StringBuffer(); |
| 6378 |
buf.append("package test1;\n"); |
| 6379 |
buf.append("public class A {\n"); |
| 6380 |
buf.append(" public void foo() {\n"); |
| 6381 |
buf.append(" int strX = 5+1;\n"); |
| 6382 |
buf.append(" }\n"); |
| 6383 |
buf.append("}\n"); |
| 6384 |
String expected1= buf.toString(); |
| 6385 |
|
| 6386 |
buf= new StringBuffer(); |
| 6387 |
buf.append("package test1;\n"); |
| 6388 |
buf.append("public class A {\n"); |
| 6389 |
buf.append(" public void foo() {\n"); |
| 6390 |
buf.append(" int strX;\n"); |
| 6391 |
buf.append(" int strX2 = strX;\n"); |
| 6392 |
buf.append(" strX = 5+1;\n"); |
| 6393 |
buf.append(" }\n"); |
| 6394 |
buf.append("}\n"); |
| 6395 |
String expected2= buf.toString(); |
| 6396 |
|
| 6397 |
buf= new StringBuffer(); |
| 6398 |
buf.append("package test1;\n"); |
| 6399 |
buf.append("public class A {\n"); |
| 6400 |
buf.append(" public void foo() {\n"); |
| 6401 |
buf.append(" int strX;\n"); |
| 6402 |
buf.append(" int strX2 = strX;\n"); |
| 6403 |
buf.append(" strX = 5+1;\n"); |
| 6404 |
buf.append(" }\n"); |
| 6405 |
buf.append("}\n"); |
| 6406 |
String expected3= buf.toString(); |
| 6407 |
|
| 6408 |
buf= new StringBuffer(); |
| 6409 |
buf.append("package test1;\n"); |
| 6410 |
buf.append("public class A {\n"); |
| 6411 |
buf.append(" private int strX;\n"); |
| 6412 |
buf.append("\n"); |
| 6413 |
buf.append(" public void foo() {\n"); |
| 6414 |
buf.append(" strX = 5+1;\n"); |
| 6415 |
buf.append(" }\n"); |
| 6416 |
buf.append("}\n"); |
| 6417 |
String expected4= buf.toString(); |
| 6418 |
|
| 6419 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4 }); |
| 5464 |
} |
6420 |
} |
| 5465 |
|
6421 |
|
| 5466 |
public void testConvertToStringBufferNoFixOutsideMethod() throws Exception { |
6422 |
public void testConvertToStringBufferNoFixOutsideMethod() throws Exception { |
|
Lines 5477-5483
Link Here
|
| 5477 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
6433 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
| 5478 |
List proposals= collectAssists(context, false); |
6434 |
List proposals= collectAssists(context, false); |
| 5479 |
|
6435 |
|
|
|
6436 |
assertNumberOfProposals(proposals, 1); |
| 5480 |
assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_STRING_BUFFER_ID); |
6437 |
assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_STRING_BUFFER_ID); |
|
|
6438 |
|
| 6439 |
buf= new StringBuffer(); |
| 6440 |
buf.append("package test1;\n"); |
| 6441 |
buf.append("public class A {\n"); |
| 6442 |
buf.append(" private String strX = \"foo\"+\"bar\"\n"); |
| 6443 |
buf.append(" public void foo() {\n"); |
| 6444 |
buf.append(" }\n"); |
| 6445 |
buf.append(" public String getStrX() {\n"); |
| 6446 |
buf.append(" return strX;\n"); |
| 6447 |
buf.append(" }\n"); |
| 6448 |
buf.append(" public void setStrX(String strX) {\n"); |
| 6449 |
buf.append(" this.strX = strX;\n"); |
| 6450 |
buf.append(" }\n"); |
| 6451 |
buf.append("}\n"); |
| 6452 |
String expected1= buf.toString(); |
| 6453 |
|
| 6454 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
| 5481 |
} |
6455 |
} |
| 5482 |
|
6456 |
|
| 5483 |
public void testConvertToStringBufferDupVarName() throws Exception { |
6457 |
public void testConvertToStringBufferDupVarName() throws Exception { |
|
Lines 5497-5503
Link Here
|
| 5497 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
6471 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("strX ="), 0); |
| 5498 |
List proposals= collectAssists(context, false); |
6472 |
List proposals= collectAssists(context, false); |
| 5499 |
|
6473 |
|
|
|
6474 |
assertNumberOfProposals(proposals, 4); |
| 5500 |
assertCorrectLabels(proposals); |
6475 |
assertCorrectLabels(proposals); |
|
|
6476 |
|
| 6477 |
buf= new StringBuffer(); |
| 6478 |
buf.append("package test1;\n"); |
| 6479 |
buf.append("public class A {\n"); |
| 6480 |
buf.append(" public void foo() {\n"); |
| 6481 |
buf.append(" int stringBuilder = 5;\n"); |
| 6482 |
buf.append(" String stringBuilder2;\n"); |
| 6483 |
buf.append(" StringBuilder stringBuilder3 = null;\n"); |
| 6484 |
buf.append(" String strX;\n"); |
| 6485 |
buf.append(" strX = \"foo\"+\"bar\";\n"); |
| 6486 |
buf.append(" }\n"); |
| 6487 |
buf.append("}\n"); |
| 6488 |
String expected1= buf.toString(); |
| 6489 |
|
| 6490 |
buf= new StringBuffer(); |
| 6491 |
buf.append("package test1;\n"); |
| 6492 |
buf.append("public class A {\n"); |
| 6493 |
buf.append(" public void foo() {\n"); |
| 6494 |
buf.append(" int stringBuilder = 5;\n"); |
| 6495 |
buf.append(" String stringBuilder2;\n"); |
| 6496 |
buf.append(" StringBuilder stringBuilder3 = null;\n"); |
| 6497 |
buf.append(" }\n"); |
| 6498 |
buf.append("}\n"); |
| 6499 |
String expected2= buf.toString(); |
| 6500 |
|
| 6501 |
buf= new StringBuffer(); |
| 6502 |
buf.append("package test1;\n"); |
| 6503 |
buf.append("public class A {\n"); |
| 6504 |
buf.append(" private String strX;\n"); |
| 6505 |
buf.append("\n"); |
| 6506 |
buf.append(" public void foo() {\n"); |
| 6507 |
buf.append(" int stringBuilder = 5;\n"); |
| 6508 |
buf.append(" String stringBuilder2;\n"); |
| 6509 |
buf.append(" StringBuilder stringBuilder3 = null;\n"); |
| 6510 |
buf.append(" strX = \"foo\"+\"bar\";\n"); |
| 6511 |
buf.append(" }\n"); |
| 6512 |
buf.append("}\n"); |
| 6513 |
String expected3= buf.toString(); |
| 5501 |
|
6514 |
|
| 5502 |
buf= new StringBuffer(); |
6515 |
buf= new StringBuffer(); |
| 5503 |
buf.append("package test1;\n"); |
6516 |
buf.append("package test1;\n"); |
|
Lines 5512-5520
Link Here
|
| 5512 |
buf.append(" String strX = stringBuilder4.toString();\n"); |
6525 |
buf.append(" String strX = stringBuilder4.toString();\n"); |
| 5513 |
buf.append(" }\n"); |
6526 |
buf.append(" }\n"); |
| 5514 |
buf.append("}\n"); |
6527 |
buf.append("}\n"); |
| 5515 |
String expected= buf.toString(); |
6528 |
String expected4= buf.toString(); |
| 5516 |
|
6529 |
|
| 5517 |
assertExpectedExistInProposals(proposals, new String[] { expected }); |
6530 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4 }); |
| 5518 |
} |
6531 |
} |
| 5519 |
|
6532 |
|
| 5520 |
public void testConvertToStringBufferInIfStatement() throws Exception { |
6533 |
public void testConvertToStringBufferInIfStatement() throws Exception { |
|
Lines 5532-5537
Link Here
|
| 5532 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\"+\""), 0); |
6545 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\"+\""), 0); |
| 5533 |
List proposals= collectAssists(context, false); |
6546 |
List proposals= collectAssists(context, false); |
| 5534 |
|
6547 |
|
|
|
6548 |
assertNumberOfProposals(proposals, 7); |
| 5535 |
assertCorrectLabels(proposals); |
6549 |
assertCorrectLabels(proposals); |
| 5536 |
|
6550 |
|
| 5537 |
buf= new StringBuffer(); |
6551 |
buf= new StringBuffer(); |
|
Lines 5547-5555
Link Here
|
| 5547 |
buf.append(" }\n"); |
6561 |
buf.append(" }\n"); |
| 5548 |
buf.append(" }\n"); |
6562 |
buf.append(" }\n"); |
| 5549 |
buf.append("}\n"); |
6563 |
buf.append("}\n"); |
| 5550 |
String expected= buf.toString(); |
6564 |
String expected1= buf.toString(); |
| 5551 |
|
6565 |
|
| 5552 |
assertExpectedExistInProposals(proposals, new String[] { expected }); |
6566 |
buf= new StringBuffer(); |
|
|
6567 |
buf.append("package test1;\n"); |
| 6568 |
buf.append("public class A {\n"); |
| 6569 |
buf.append(" public void foo() {\n"); |
| 6570 |
buf.append(" String strX;\n"); |
| 6571 |
buf.append(" if(true) {\n"); |
| 6572 |
buf.append(" String string = \"foo\";\n"); |
| 6573 |
buf.append(" strX = string+\"bar\";\n"); |
| 6574 |
buf.append(" }\n"); |
| 6575 |
buf.append(" }\n"); |
| 6576 |
buf.append("}\n"); |
| 6577 |
String expected2= buf.toString(); |
| 6578 |
|
| 6579 |
buf= new StringBuffer(); |
| 6580 |
buf.append("package test1;\n"); |
| 6581 |
buf.append("public class A {\n"); |
| 6582 |
buf.append(" private static final String FOO = \"foo\";\n"); |
| 6583 |
buf.append("\n"); |
| 6584 |
buf.append(" public void foo() {\n"); |
| 6585 |
buf.append(" String strX;\n"); |
| 6586 |
buf.append(" if(true) strX = FOO+\"bar\";\n"); |
| 6587 |
buf.append(" }\n"); |
| 6588 |
buf.append("}\n"); |
| 6589 |
String expected3= buf.toString(); |
| 6590 |
|
| 6591 |
buf= new StringBuffer(); |
| 6592 |
buf.append("package test1;\n"); |
| 6593 |
buf.append("public class A {\n"); |
| 6594 |
buf.append(" public void foo() {\n"); |
| 6595 |
buf.append(" String strX;\n"); |
| 6596 |
buf.append(" if(true) {\n"); |
| 6597 |
buf.append(" String string = \"foo\";\n"); |
| 6598 |
buf.append(" strX = string+\"bar\";\n"); |
| 6599 |
buf.append(" }\n"); |
| 6600 |
buf.append(" }\n"); |
| 6601 |
buf.append("}\n"); |
| 6602 |
String expected4= buf.toString(); |
| 6603 |
|
| 6604 |
buf= new StringBuffer(); |
| 6605 |
buf.append("package test1;\n"); |
| 6606 |
buf.append("public class A {\n"); |
| 6607 |
buf.append(" public void foo() {\n"); |
| 6608 |
buf.append(" String strX;\n"); |
| 6609 |
buf.append(" if(true) strX = (\"foo\"+\"bar\");\n"); |
| 6610 |
buf.append(" }\n"); |
| 6611 |
buf.append("}\n"); |
| 6612 |
String expected5= buf.toString(); |
| 6613 |
|
| 6614 |
buf= new StringBuffer(); |
| 6615 |
buf.append("package test1;\n"); |
| 6616 |
buf.append("public class A {\n"); |
| 6617 |
buf.append(" public void foo() {\n"); |
| 6618 |
buf.append(" String strX;\n"); |
| 6619 |
buf.append(" if(true) strX = \"foobar\";\n"); |
| 6620 |
buf.append(" }\n"); |
| 6621 |
buf.append("}\n"); |
| 6622 |
String expected6= buf.toString(); |
| 6623 |
|
| 6624 |
buf= new StringBuffer(); |
| 6625 |
buf.append("package test1;\n"); |
| 6626 |
buf.append("public class A {\n"); |
| 6627 |
buf.append(" public void foo() {\n"); |
| 6628 |
buf.append(" String strX;\n"); |
| 6629 |
buf.append(" if(true) strX = \"FOO\"+\"bar\";\n"); |
| 6630 |
buf.append(" }\n"); |
| 6631 |
buf.append("}\n"); |
| 6632 |
String expected7= buf.toString(); |
| 6633 |
|
| 6634 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5553 |
} |
6635 |
} |
| 5554 |
|
6636 |
|
| 5555 |
public void testConvertToStringBufferAsParamter() throws Exception { |
6637 |
public void testConvertToStringBufferAsParamter() throws Exception { |
|
Lines 5566-5571
Link Here
|
| 5566 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\"+\""), 0); |
6648 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\"+\""), 0); |
| 5567 |
List proposals= collectAssists(context, false); |
6649 |
List proposals= collectAssists(context, false); |
| 5568 |
|
6650 |
|
|
|
6651 |
assertNumberOfProposals(proposals, 7); |
| 5569 |
assertCorrectLabels(proposals); |
6652 |
assertCorrectLabels(proposals); |
| 5570 |
|
6653 |
|
| 5571 |
buf= new StringBuffer(); |
6654 |
buf= new StringBuffer(); |
|
Lines 5580-5586
Link Here
|
| 5580 |
buf.append("}\n"); |
6663 |
buf.append("}\n"); |
| 5581 |
String expected1= buf.toString(); |
6664 |
String expected1= buf.toString(); |
| 5582 |
|
6665 |
|
| 5583 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
6666 |
buf= new StringBuffer(); |
|
|
6667 |
buf.append("package test1;\n"); |
| 6668 |
buf.append("public class A {\n"); |
| 6669 |
buf.append(" public void foo() {\n"); |
| 6670 |
buf.append(" String string = \"foo\";\n"); |
| 6671 |
buf.append(" System.out.println(string+\"bar\");\n"); |
| 6672 |
buf.append(" }\n"); |
| 6673 |
buf.append("}\n"); |
| 6674 |
String expected2= buf.toString(); |
| 6675 |
|
| 6676 |
buf= new StringBuffer(); |
| 6677 |
buf.append("package test1;\n"); |
| 6678 |
buf.append("public class A {\n"); |
| 6679 |
buf.append(" public void foo() {\n"); |
| 6680 |
buf.append(" String string = \"foo\";\n"); |
| 6681 |
buf.append(" System.out.println(string+\"bar\");\n"); |
| 6682 |
buf.append(" }\n"); |
| 6683 |
buf.append("}\n"); |
| 6684 |
String expected3= buf.toString(); |
| 6685 |
|
| 6686 |
buf= new StringBuffer(); |
| 6687 |
buf.append("package test1;\n"); |
| 6688 |
buf.append("public class A {\n"); |
| 6689 |
buf.append(" private static final String FOO = \"foo\";\n"); |
| 6690 |
buf.append("\n"); |
| 6691 |
buf.append(" public void foo() {\n"); |
| 6692 |
buf.append(" System.out.println(FOO+\"bar\");\n"); |
| 6693 |
buf.append(" }\n"); |
| 6694 |
buf.append("}\n"); |
| 6695 |
String expected4= buf.toString(); |
| 6696 |
|
| 6697 |
buf= new StringBuffer(); |
| 6698 |
buf.append("package test1;\n"); |
| 6699 |
buf.append("public class A {\n"); |
| 6700 |
buf.append(" public void foo() {\n"); |
| 6701 |
buf.append(" System.out.println((\"foo\"+\"bar\"));\n"); |
| 6702 |
buf.append(" }\n"); |
| 6703 |
buf.append("}\n"); |
| 6704 |
String expected5= buf.toString(); |
| 6705 |
|
| 6706 |
buf= new StringBuffer(); |
| 6707 |
buf.append("package test1;\n"); |
| 6708 |
buf.append("public class A {\n"); |
| 6709 |
buf.append(" public void foo() {\n"); |
| 6710 |
buf.append(" System.out.println(\"foobar\");\n"); |
| 6711 |
buf.append(" }\n"); |
| 6712 |
buf.append("}\n"); |
| 6713 |
String expected6= buf.toString(); |
| 6714 |
|
| 6715 |
buf= new StringBuffer(); |
| 6716 |
buf.append("package test1;\n"); |
| 6717 |
buf.append("public class A {\n"); |
| 6718 |
buf.append(" public void foo() {\n"); |
| 6719 |
buf.append(" System.out.println(\"FOO\"+\"bar\");\n"); |
| 6720 |
buf.append(" }\n"); |
| 6721 |
buf.append("}\n"); |
| 6722 |
String expected7= buf.toString(); |
| 6723 |
|
| 6724 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5584 |
} |
6725 |
} |
| 5585 |
|
6726 |
|
| 5586 |
public void testConvertToStringBufferJava14() throws Exception { |
6727 |
public void testConvertToStringBufferJava14() throws Exception { |
|
Lines 5604-5609
Link Here
|
| 5604 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\"+\""), 0); |
6745 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\"+\""), 0); |
| 5605 |
List proposals= collectAssists(context, false); |
6746 |
List proposals= collectAssists(context, false); |
| 5606 |
|
6747 |
|
|
|
6748 |
assertNumberOfProposals(proposals, 7); |
| 5607 |
assertCorrectLabels(proposals); |
6749 |
assertCorrectLabels(proposals); |
| 5608 |
|
6750 |
|
| 5609 |
buf= new StringBuffer(); |
6751 |
buf= new StringBuffer(); |
|
Lines 5618-5624
Link Here
|
| 5618 |
buf.append("}\n"); |
6760 |
buf.append("}\n"); |
| 5619 |
String expected1= buf.toString(); |
6761 |
String expected1= buf.toString(); |
| 5620 |
|
6762 |
|
| 5621 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
6763 |
buf= new StringBuffer(); |
|
|
6764 |
buf.append("package test1;\n"); |
| 6765 |
buf.append("public class A {\n"); |
| 6766 |
buf.append(" public void foo() {\n"); |
| 6767 |
buf.append(" String string = \"foo\";\n"); |
| 6768 |
buf.append(" System.out.println(string+\"bar\");\n"); |
| 6769 |
buf.append(" }\n"); |
| 6770 |
buf.append("}\n"); |
| 6771 |
String expected2= buf.toString(); |
| 6772 |
|
| 6773 |
buf= new StringBuffer(); |
| 6774 |
buf.append("package test1;\n"); |
| 6775 |
buf.append("public class A {\n"); |
| 6776 |
buf.append(" public void foo() {\n"); |
| 6777 |
buf.append(" String string = \"foo\";\n"); |
| 6778 |
buf.append(" System.out.println(string+\"bar\");\n"); |
| 6779 |
buf.append(" }\n"); |
| 6780 |
buf.append("}\n"); |
| 6781 |
String expected3= buf.toString(); |
| 6782 |
|
| 6783 |
buf= new StringBuffer(); |
| 6784 |
buf.append("package test1;\n"); |
| 6785 |
buf.append("public class A {\n"); |
| 6786 |
buf.append(" private static final String FOO = \"foo\";\n"); |
| 6787 |
buf.append("\n"); |
| 6788 |
buf.append(" public void foo() {\n"); |
| 6789 |
buf.append(" System.out.println(FOO+\"bar\");\n"); |
| 6790 |
buf.append(" }\n"); |
| 6791 |
buf.append("}\n"); |
| 6792 |
String expected4= buf.toString(); |
| 6793 |
|
| 6794 |
buf= new StringBuffer(); |
| 6795 |
buf.append("package test1;\n"); |
| 6796 |
buf.append("public class A {\n"); |
| 6797 |
buf.append(" public void foo() {\n"); |
| 6798 |
buf.append(" System.out.println((\"foo\"+\"bar\"));\n"); |
| 6799 |
buf.append(" }\n"); |
| 6800 |
buf.append("}\n"); |
| 6801 |
String expected5= buf.toString(); |
| 6802 |
|
| 6803 |
buf= new StringBuffer(); |
| 6804 |
buf.append("package test1;\n"); |
| 6805 |
buf.append("public class A {\n"); |
| 6806 |
buf.append(" public void foo() {\n"); |
| 6807 |
buf.append(" System.out.println(\"foobar\");\n"); |
| 6808 |
buf.append(" }\n"); |
| 6809 |
buf.append("}\n"); |
| 6810 |
String expected6= buf.toString(); |
| 6811 |
|
| 6812 |
buf= new StringBuffer(); |
| 6813 |
buf.append("package test1;\n"); |
| 6814 |
buf.append("public class A {\n"); |
| 6815 |
buf.append(" public void foo() {\n"); |
| 6816 |
buf.append(" System.out.println(\"FOO\"+\"bar\");\n"); |
| 6817 |
buf.append(" }\n"); |
| 6818 |
buf.append("}\n"); |
| 6819 |
String expected7= buf.toString(); |
| 6820 |
|
| 6821 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5622 |
} finally { |
6822 |
} finally { |
| 5623 |
fJProject1.setOptions(oldOptions); |
6823 |
fJProject1.setOptions(oldOptions); |
| 5624 |
} |
6824 |
} |
|
Lines 5639-5644
Link Here
|
| 5639 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + 5"), 0); |
6839 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + 5"), 0); |
| 5640 |
List proposals= collectAssists(context, false); |
6840 |
List proposals= collectAssists(context, false); |
| 5641 |
|
6841 |
|
|
|
6842 |
assertNumberOfProposals(proposals, 9); |
| 5642 |
assertCorrectLabels(proposals); |
6843 |
assertCorrectLabels(proposals); |
| 5643 |
|
6844 |
|
| 5644 |
buf= new StringBuffer(); |
6845 |
buf= new StringBuffer(); |
|
Lines 5652-5658
Link Here
|
| 5652 |
buf.append("}\n"); |
6853 |
buf.append("}\n"); |
| 5653 |
String expected1= buf.toString(); |
6854 |
String expected1= buf.toString(); |
| 5654 |
|
6855 |
|
| 5655 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
6856 |
buf= new StringBuffer(); |
|
|
6857 |
buf.append("package test1;\n"); |
| 6858 |
buf.append("public class A {\n"); |
| 6859 |
buf.append(" public void foo() {\n"); |
| 6860 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 6861 |
buf.append(" StringBuffer append = buf.append(\"high\" + 5);\n"); |
| 6862 |
buf.append(" }\n"); |
| 6863 |
buf.append("}\n"); |
| 6864 |
String expected2= buf.toString(); |
| 6865 |
|
| 6866 |
buf= new StringBuffer(); |
| 6867 |
buf.append("package test1;\n"); |
| 6868 |
buf.append("public class A {\n"); |
| 6869 |
buf.append(" private StringBuffer append;\n"); |
| 6870 |
buf.append("\n"); |
| 6871 |
buf.append(" public void foo() {\n"); |
| 6872 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 6873 |
buf.append(" append = buf.append(\"high\" + 5);\n"); |
| 6874 |
buf.append(" }\n"); |
| 6875 |
buf.append("}\n"); |
| 6876 |
String expected3= buf.toString(); |
| 6877 |
|
| 6878 |
buf= new StringBuffer(); |
| 6879 |
buf.append("package test1;\n"); |
| 6880 |
buf.append("public class A {\n"); |
| 6881 |
buf.append(" public void foo() {\n"); |
| 6882 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 6883 |
buf.append(" String string = \"high\";\n"); |
| 6884 |
buf.append(" buf.append(string + 5);\n"); |
| 6885 |
buf.append(" }\n"); |
| 6886 |
buf.append("}\n"); |
| 6887 |
String expected4= buf.toString(); |
| 6888 |
|
| 6889 |
buf= new StringBuffer(); |
| 6890 |
buf.append("package test1;\n"); |
| 6891 |
buf.append("public class A {\n"); |
| 6892 |
buf.append(" public void foo() {\n"); |
| 6893 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 6894 |
buf.append(" String string = \"high\";\n"); |
| 6895 |
buf.append(" buf.append(string + 5);\n"); |
| 6896 |
buf.append(" }\n"); |
| 6897 |
buf.append("}\n"); |
| 6898 |
String expected5= buf.toString(); |
| 6899 |
|
| 6900 |
buf= new StringBuffer(); |
| 6901 |
buf.append("package test1;\n"); |
| 6902 |
buf.append("public class A {\n"); |
| 6903 |
buf.append(" private static final String HIGH = \"high\";\n"); |
| 6904 |
buf.append("\n"); |
| 6905 |
buf.append(" public void foo() {\n"); |
| 6906 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 6907 |
buf.append(" buf.append(HIGH + 5);\n"); |
| 6908 |
buf.append(" }\n"); |
| 6909 |
buf.append("}\n"); |
| 6910 |
String expected6= buf.toString(); |
| 6911 |
|
| 6912 |
buf= new StringBuffer(); |
| 6913 |
buf.append("package test1;\n"); |
| 6914 |
buf.append("\n"); |
| 6915 |
buf.append("import java.text.MessageFormat;\n"); |
| 6916 |
buf.append("\n"); |
| 6917 |
buf.append("public class A {\n"); |
| 6918 |
buf.append(" public void foo() {\n"); |
| 6919 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 6920 |
buf.append(" buf.append(MessageFormat.format(\"high{0}\", 5));\n"); |
| 6921 |
buf.append(" }\n"); |
| 6922 |
buf.append("}\n"); |
| 6923 |
String expected7= buf.toString(); |
| 6924 |
|
| 6925 |
buf= new StringBuffer(); |
| 6926 |
buf.append("package test1;\n"); |
| 6927 |
buf.append("public class A {\n"); |
| 6928 |
buf.append(" public void foo() {\n"); |
| 6929 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 6930 |
buf.append(" buf.append((\"high\" + 5));\n"); |
| 6931 |
buf.append(" }\n"); |
| 6932 |
buf.append("}\n"); |
| 6933 |
String expected8= buf.toString(); |
| 6934 |
|
| 6935 |
buf= new StringBuffer(); |
| 6936 |
buf.append("package test1;\n"); |
| 6937 |
buf.append("public class A {\n"); |
| 6938 |
buf.append(" public void foo() {\n"); |
| 6939 |
buf.append(" StringBuffer buf= new StringBuffer();\n"); |
| 6940 |
buf.append(" buf.append(\"HIGH\" + 5);\n"); |
| 6941 |
buf.append(" }\n"); |
| 6942 |
buf.append("}\n"); |
| 6943 |
String expected9= buf.toString(); |
| 6944 |
|
| 6945 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7, expected8, expected9 }); |
| 5656 |
} |
6946 |
} |
| 5657 |
|
6947 |
|
| 5658 |
public void testConvertToStringBufferExisting2() throws Exception { |
6948 |
public void testConvertToStringBufferExisting2() throws Exception { |
|
Lines 5670-5675
Link Here
|
| 5670 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + 5"), 0); |
6960 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + 5"), 0); |
| 5671 |
List proposals= collectAssists(context, false); |
6961 |
List proposals= collectAssists(context, false); |
| 5672 |
|
6962 |
|
|
|
6963 |
assertNumberOfProposals(proposals, 9); |
| 5673 |
assertCorrectLabels(proposals); |
6964 |
assertCorrectLabels(proposals); |
| 5674 |
|
6965 |
|
| 5675 |
buf= new StringBuffer(); |
6966 |
buf= new StringBuffer(); |
|
Lines 5684-5690
Link Here
|
| 5684 |
buf.append("}\n"); |
6975 |
buf.append("}\n"); |
| 5685 |
String expected1= buf.toString(); |
6976 |
String expected1= buf.toString(); |
| 5686 |
|
6977 |
|
| 5687 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
6978 |
buf= new StringBuffer(); |
|
|
6979 |
buf.append("package test1;\n"); |
| 6980 |
buf.append("public class A {\n"); |
| 6981 |
buf.append(" public void foo() {\n"); |
| 6982 |
buf.append(" StringBuilder sb= new StringBuilder();\n"); |
| 6983 |
buf.append(" StringBuilder append = sb.append(\"high\" + 5 + \" ho\");\n"); |
| 6984 |
buf.append(" }\n"); |
| 6985 |
buf.append("}\n"); |
| 6986 |
String expected2= buf.toString(); |
| 6987 |
|
| 6988 |
buf= new StringBuffer(); |
| 6989 |
buf.append("package test1;\n"); |
| 6990 |
buf.append("public class A {\n"); |
| 6991 |
buf.append(" private StringBuilder append;\n"); |
| 6992 |
buf.append("\n"); |
| 6993 |
buf.append(" public void foo() {\n"); |
| 6994 |
buf.append(" StringBuilder sb= new StringBuilder();\n"); |
| 6995 |
buf.append(" append = sb.append(\"high\" + 5 + \" ho\");\n"); |
| 6996 |
buf.append(" }\n"); |
| 6997 |
buf.append("}\n"); |
| 6998 |
String expected3= buf.toString(); |
| 6999 |
|
| 7000 |
buf= new StringBuffer(); |
| 7001 |
buf.append("package test1;\n"); |
| 7002 |
buf.append("public class A {\n"); |
| 7003 |
buf.append(" public void foo() {\n"); |
| 7004 |
buf.append(" StringBuilder sb= new StringBuilder();\n"); |
| 7005 |
buf.append(" String string = \"high\";\n"); |
| 7006 |
buf.append(" sb.append(string + 5 + \" ho\");\n"); |
| 7007 |
buf.append(" }\n"); |
| 7008 |
buf.append("}\n"); |
| 7009 |
String expected4= buf.toString(); |
| 7010 |
|
| 7011 |
buf= new StringBuffer(); |
| 7012 |
buf.append("package test1;\n"); |
| 7013 |
buf.append("public class A {\n"); |
| 7014 |
buf.append(" public void foo() {\n"); |
| 7015 |
buf.append(" StringBuilder sb= new StringBuilder();\n"); |
| 7016 |
buf.append(" String string = \"high\";\n"); |
| 7017 |
buf.append(" sb.append(string + 5 + \" ho\");\n"); |
| 7018 |
buf.append(" }\n"); |
| 7019 |
buf.append("}\n"); |
| 7020 |
String expected5= buf.toString(); |
| 7021 |
|
| 7022 |
buf= new StringBuffer(); |
| 7023 |
buf.append("package test1;\n"); |
| 7024 |
buf.append("public class A {\n"); |
| 7025 |
buf.append(" private static final String HIGH = \"high\";\n"); |
| 7026 |
buf.append("\n"); |
| 7027 |
buf.append(" public void foo() {\n"); |
| 7028 |
buf.append(" StringBuilder sb= new StringBuilder();\n"); |
| 7029 |
buf.append(" sb.append(HIGH + 5 + \" ho\");\n"); |
| 7030 |
buf.append(" }\n"); |
| 7031 |
buf.append("}\n"); |
| 7032 |
String expected6= buf.toString(); |
| 7033 |
|
| 7034 |
buf= new StringBuffer(); |
| 7035 |
buf.append("package test1;\n"); |
| 7036 |
buf.append("\n"); |
| 7037 |
buf.append("import java.text.MessageFormat;\n"); |
| 7038 |
buf.append("\n"); |
| 7039 |
buf.append("public class A {\n"); |
| 7040 |
buf.append(" public void foo() {\n"); |
| 7041 |
buf.append(" StringBuilder sb= new StringBuilder();\n"); |
| 7042 |
buf.append(" sb.append(MessageFormat.format(\"high{0} ho\", 5));\n"); |
| 7043 |
buf.append(" }\n"); |
| 7044 |
buf.append("}\n"); |
| 7045 |
String expected7= buf.toString(); |
| 7046 |
|
| 7047 |
buf= new StringBuffer(); |
| 7048 |
buf.append("package test1;\n"); |
| 7049 |
buf.append("public class A {\n"); |
| 7050 |
buf.append(" public void foo() {\n"); |
| 7051 |
buf.append(" StringBuilder sb= new StringBuilder();\n"); |
| 7052 |
buf.append(" sb.append((\"high\" + 5 + \" ho\"));\n"); |
| 7053 |
buf.append(" }\n"); |
| 7054 |
buf.append("}\n"); |
| 7055 |
String expected8= buf.toString(); |
| 7056 |
|
| 7057 |
buf= new StringBuffer(); |
| 7058 |
buf.append("package test1;\n"); |
| 7059 |
buf.append("public class A {\n"); |
| 7060 |
buf.append(" public void foo() {\n"); |
| 7061 |
buf.append(" StringBuilder sb= new StringBuilder();\n"); |
| 7062 |
buf.append(" sb.append(\"HIGH\" + 5 + \" ho\");\n"); |
| 7063 |
buf.append(" }\n"); |
| 7064 |
buf.append("}\n"); |
| 7065 |
String expected9= buf.toString(); |
| 7066 |
|
| 7067 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7, expected8, expected9 }); |
| 5688 |
} |
7068 |
} |
| 5689 |
|
7069 |
|
| 5690 |
public void testConvertToMessageFormat14() throws Exception { |
7070 |
public void testConvertToMessageFormat14() throws Exception { |
|
Lines 5708-5713
Link Here
|
| 5708 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + o1 + \""), 0); |
7088 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + o1 + \""), 0); |
| 5709 |
List proposals= collectAssists(context, false); |
7089 |
List proposals= collectAssists(context, false); |
| 5710 |
|
7090 |
|
|
|
7091 |
assertNumberOfProposals(proposals, 7); |
| 5711 |
assertCorrectLabels(proposals); |
7092 |
assertCorrectLabels(proposals); |
| 5712 |
|
7093 |
|
| 5713 |
buf= new StringBuffer(); |
7094 |
buf= new StringBuffer(); |
|
Lines 5723-5729
Link Here
|
| 5723 |
buf.append("}\n"); |
7104 |
buf.append("}\n"); |
| 5724 |
String expected1= buf.toString(); |
7105 |
String expected1= buf.toString(); |
| 5725 |
|
7106 |
|
| 5726 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
7107 |
buf= new StringBuffer(); |
|
|
7108 |
buf.append("package test1;\n"); |
| 7109 |
buf.append("public class A {\n"); |
| 7110 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7111 |
buf.append(" String string = \"foo\";\n"); |
| 7112 |
buf.append(" System.out.println(string + o1 + \" \\\"bar\\\" \" + o2);\n"); |
| 7113 |
buf.append(" }\n"); |
| 7114 |
buf.append("}\n"); |
| 7115 |
String expected2= buf.toString(); |
| 7116 |
|
| 7117 |
buf= new StringBuffer(); |
| 7118 |
buf.append("package test1;\n"); |
| 7119 |
buf.append("public class A {\n"); |
| 7120 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7121 |
buf.append(" String string = \"foo\";\n"); |
| 7122 |
buf.append(" System.out.println(string + o1 + \" \\\"bar\\\" \" + o2);\n"); |
| 7123 |
buf.append(" }\n"); |
| 7124 |
buf.append("}\n"); |
| 7125 |
String expected3= buf.toString(); |
| 7126 |
|
| 7127 |
buf= new StringBuffer(); |
| 7128 |
buf.append("package test1;\n"); |
| 7129 |
buf.append("public class A {\n"); |
| 7130 |
buf.append(" private static final String FOO = \"foo\";\n"); |
| 7131 |
buf.append("\n"); |
| 7132 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7133 |
buf.append(" System.out.println(FOO + o1 + \" \\\"bar\\\" \" + o2);\n"); |
| 7134 |
buf.append(" }\n"); |
| 7135 |
buf.append("}\n"); |
| 7136 |
String expected4= buf.toString(); |
| 7137 |
|
| 7138 |
buf= new StringBuffer(); |
| 7139 |
buf.append("package test1;\n"); |
| 7140 |
buf.append("public class A {\n"); |
| 7141 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7142 |
buf.append(" StringBuffer stringBuffer = new StringBuffer();\n"); |
| 7143 |
buf.append(" stringBuffer.append(\"foo\");\n"); |
| 7144 |
buf.append(" stringBuffer.append(o1);\n"); |
| 7145 |
buf.append(" stringBuffer.append(\" \\\"bar\\\" \");\n"); |
| 7146 |
buf.append(" stringBuffer.append(o2);\n"); |
| 7147 |
buf.append(" System.out.println(stringBuffer.toString());\n"); |
| 7148 |
buf.append(" }\n"); |
| 7149 |
buf.append("}\n"); |
| 7150 |
String expected5= buf.toString(); |
| 7151 |
|
| 7152 |
buf= new StringBuffer(); |
| 7153 |
buf.append("package test1;\n"); |
| 7154 |
buf.append("public class A {\n"); |
| 7155 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7156 |
buf.append(" System.out.println((\"foo\" + o1 + \" \\\"bar\\\" \" + o2));\n"); |
| 7157 |
buf.append(" }\n"); |
| 7158 |
buf.append("}\n"); |
| 7159 |
String expected6= buf.toString(); |
| 7160 |
|
| 7161 |
buf= new StringBuffer(); |
| 7162 |
buf.append("package test1;\n"); |
| 7163 |
buf.append("public class A {\n"); |
| 7164 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7165 |
buf.append(" System.out.println(\"FOO\" + o1 + \" \\\"bar\\\" \" + o2);\n"); |
| 7166 |
buf.append(" }\n"); |
| 7167 |
buf.append("}\n"); |
| 7168 |
String expected7= buf.toString(); |
| 7169 |
|
| 7170 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5727 |
} finally { |
7171 |
} finally { |
| 5728 |
fJProject1.setOptions(oldOptions); |
7172 |
fJProject1.setOptions(oldOptions); |
| 5729 |
} |
7173 |
} |
|
Lines 5744-5752
Link Here
|
| 5744 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + \"\" + \""), 0); |
7188 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + \"\" + \""), 0); |
| 5745 |
List proposals= collectAssists(context, false); |
7189 |
List proposals= collectAssists(context, false); |
| 5746 |
|
7190 |
|
|
|
7191 |
assertNumberOfProposals(proposals, 7); |
| 5747 |
assertCorrectLabels(proposals); |
7192 |
assertCorrectLabels(proposals); |
| 5748 |
|
7193 |
|
| 5749 |
assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_MESSAGE_FORMAT_ID); |
7194 |
assertCommandIdDoesNotExist(proposals, QuickAssistProcessor.CONVERT_TO_MESSAGE_FORMAT_ID); |
|
|
7195 |
|
| 7196 |
buf= new StringBuffer(); |
| 7197 |
buf.append("package test1;\n"); |
| 7198 |
buf.append("public class A {\n"); |
| 7199 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7200 |
buf.append(" String string = \"foo\";\n"); |
| 7201 |
buf.append(" System.out.println(string + \"\" + \" \\\"bar\\\" \");\n"); |
| 7202 |
buf.append(" }\n"); |
| 7203 |
buf.append("}\n"); |
| 7204 |
String expected1= buf.toString(); |
| 7205 |
|
| 7206 |
buf= new StringBuffer(); |
| 7207 |
buf.append("package test1;\n"); |
| 7208 |
buf.append("public class A {\n"); |
| 7209 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7210 |
buf.append(" String string = \"foo\";\n"); |
| 7211 |
buf.append(" System.out.println(string + \"\" + \" \\\"bar\\\" \");\n"); |
| 7212 |
buf.append(" }\n"); |
| 7213 |
buf.append("}\n"); |
| 7214 |
String expected2= buf.toString(); |
| 7215 |
|
| 7216 |
buf= new StringBuffer(); |
| 7217 |
buf.append("package test1;\n"); |
| 7218 |
buf.append("public class A {\n"); |
| 7219 |
buf.append(" private static final String FOO = \"foo\";\n"); |
| 7220 |
buf.append("\n"); |
| 7221 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7222 |
buf.append(" System.out.println(FOO + \"\" + \" \\\"bar\\\" \");\n"); |
| 7223 |
buf.append(" }\n"); |
| 7224 |
buf.append("}\n"); |
| 7225 |
String expected3= buf.toString(); |
| 7226 |
|
| 7227 |
buf= new StringBuffer(); |
| 7228 |
buf.append("package test1;\n"); |
| 7229 |
buf.append("public class A {\n"); |
| 7230 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7231 |
buf.append(" StringBuilder stringBuilder = new StringBuilder();\n"); |
| 7232 |
buf.append(" stringBuilder.append(\"foo\");\n"); |
| 7233 |
buf.append(" stringBuilder.append(\"\");\n"); |
| 7234 |
buf.append(" stringBuilder.append(\" \\\"bar\\\" \");\n"); |
| 7235 |
buf.append(" System.out.println(stringBuilder.toString());\n"); |
| 7236 |
buf.append(" }\n"); |
| 7237 |
buf.append("}\n"); |
| 7238 |
String expected4= buf.toString(); |
| 7239 |
|
| 7240 |
buf= new StringBuffer(); |
| 7241 |
buf.append("package test1;\n"); |
| 7242 |
buf.append("public class A {\n"); |
| 7243 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7244 |
buf.append(" System.out.println((\"foo\" + \"\" + \" \\\"bar\\\" \"));\n"); |
| 7245 |
buf.append(" }\n"); |
| 7246 |
buf.append("}\n"); |
| 7247 |
String expected5= buf.toString(); |
| 7248 |
|
| 7249 |
buf= new StringBuffer(); |
| 7250 |
buf.append("package test1;\n"); |
| 7251 |
buf.append("public class A {\n"); |
| 7252 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7253 |
buf.append(" System.out.println(\"foo \\\"bar\\\" \");\n"); |
| 7254 |
buf.append(" }\n"); |
| 7255 |
buf.append("}\n"); |
| 7256 |
String expected6= buf.toString(); |
| 7257 |
|
| 7258 |
buf= new StringBuffer(); |
| 7259 |
buf.append("package test1;\n"); |
| 7260 |
buf.append("public class A {\n"); |
| 7261 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7262 |
buf.append(" System.out.println(\"FOO\" + \"\" + \" \\\"bar\\\" \");\n"); |
| 7263 |
buf.append(" }\n"); |
| 7264 |
buf.append("}\n"); |
| 7265 |
String expected7= buf.toString(); |
| 7266 |
|
| 7267 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5750 |
} |
7268 |
} |
| 5751 |
|
7269 |
|
| 5752 |
public void testConvertToMessageFormatStringBoxing14() throws Exception { |
7270 |
public void testConvertToMessageFormatStringBoxing14() throws Exception { |
|
Lines 5769-5774
Link Here
|
| 5769 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("1 + \""), 0); |
7287 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("1 + \""), 0); |
| 5770 |
List proposals= collectAssists(context, false); |
7288 |
List proposals= collectAssists(context, false); |
| 5771 |
|
7289 |
|
|
|
7290 |
assertNumberOfProposals(proposals, 6); |
| 5772 |
assertCorrectLabels(proposals); |
7291 |
assertCorrectLabels(proposals); |
| 5773 |
|
7292 |
|
| 5774 |
buf= new StringBuffer(); |
7293 |
buf= new StringBuffer(); |
|
Lines 5783-5789
Link Here
|
| 5783 |
buf.append("}\n"); |
7302 |
buf.append("}\n"); |
| 5784 |
String expected1= buf.toString(); |
7303 |
String expected1= buf.toString(); |
| 5785 |
|
7304 |
|
| 5786 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
7305 |
buf= new StringBuffer(); |
|
|
7306 |
buf.append("package test1;\n"); |
| 7307 |
buf.append("public class A {\n"); |
| 7308 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7309 |
buf.append(" int i = 1;\n"); |
| 7310 |
buf.append(" System.out.println(\"foo\" + i + \" \\\"bar\\\" \");\n"); |
| 7311 |
buf.append(" }\n"); |
| 7312 |
buf.append("}\n"); |
| 7313 |
String expected2= buf.toString(); |
| 7314 |
|
| 7315 |
buf= new StringBuffer(); |
| 7316 |
buf.append("package test1;\n"); |
| 7317 |
buf.append("public class A {\n"); |
| 7318 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7319 |
buf.append(" int i = 1;\n"); |
| 7320 |
buf.append(" System.out.println(\"foo\" + i + \" \\\"bar\\\" \");\n"); |
| 7321 |
buf.append(" }\n"); |
| 7322 |
buf.append("}\n"); |
| 7323 |
String expected3= buf.toString(); |
| 7324 |
|
| 7325 |
buf= new StringBuffer(); |
| 7326 |
buf.append("package test1;\n"); |
| 7327 |
buf.append("public class A {\n"); |
| 7328 |
buf.append(" private static final int _1 = 1;\n"); |
| 7329 |
buf.append("\n"); |
| 7330 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7331 |
buf.append(" System.out.println(\"foo\" + _1 + \" \\\"bar\\\" \");\n"); |
| 7332 |
buf.append(" }\n"); |
| 7333 |
buf.append("}\n"); |
| 7334 |
String expected4= buf.toString(); |
| 7335 |
|
| 7336 |
buf= new StringBuffer(); |
| 7337 |
buf.append("package test1;\n"); |
| 7338 |
buf.append("public class A {\n"); |
| 7339 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7340 |
buf.append(" StringBuffer stringBuffer = new StringBuffer();\n"); |
| 7341 |
buf.append(" stringBuffer.append(\"foo\");\n"); |
| 7342 |
buf.append(" stringBuffer.append(1);\n"); |
| 7343 |
buf.append(" stringBuffer.append(\" \\\"bar\\\" \");\n"); |
| 7344 |
buf.append(" System.out.println(stringBuffer.toString());\n"); |
| 7345 |
buf.append(" }\n"); |
| 7346 |
buf.append("}\n"); |
| 7347 |
String expected5= buf.toString(); |
| 7348 |
|
| 7349 |
buf= new StringBuffer(); |
| 7350 |
buf.append("package test1;\n"); |
| 7351 |
buf.append("public class A {\n"); |
| 7352 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7353 |
buf.append(" System.out.println((\"foo\" + 1 + \" \\\"bar\\\" \"));\n"); |
| 7354 |
buf.append(" }\n"); |
| 7355 |
buf.append("}\n"); |
| 7356 |
String expected6= buf.toString(); |
| 7357 |
|
| 7358 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6 }); |
| 5787 |
} finally { |
7359 |
} finally { |
| 5788 |
fJProject1.setOptions(oldOptions); |
7360 |
fJProject1.setOptions(oldOptions); |
| 5789 |
} |
7361 |
} |
|
Lines 5803-5808
Link Here
|
| 5803 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + 1 + \""), 0); |
7375 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + 1 + \""), 0); |
| 5804 |
List proposals= collectAssists(context, false); |
7376 |
List proposals= collectAssists(context, false); |
| 5805 |
|
7377 |
|
|
|
7378 |
assertNumberOfProposals(proposals, 7); |
| 5806 |
assertCorrectLabels(proposals); |
7379 |
assertCorrectLabels(proposals); |
| 5807 |
|
7380 |
|
| 5808 |
buf= new StringBuffer(); |
7381 |
buf= new StringBuffer(); |
|
Lines 5817-5823
Link Here
|
| 5817 |
buf.append("}\n"); |
7390 |
buf.append("}\n"); |
| 5818 |
String expected1= buf.toString(); |
7391 |
String expected1= buf.toString(); |
| 5819 |
|
7392 |
|
| 5820 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
7393 |
buf= new StringBuffer(); |
|
|
7394 |
buf.append("package test1;\n"); |
| 7395 |
buf.append("public class A {\n"); |
| 7396 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7397 |
buf.append(" String string = \"foo\";\n"); |
| 7398 |
buf.append(" System.out.println(string + 1 + \" \\\"bar\\\" \");\n"); |
| 7399 |
buf.append(" }\n"); |
| 7400 |
buf.append("}\n"); |
| 7401 |
String expected2= buf.toString(); |
| 7402 |
|
| 7403 |
buf= new StringBuffer(); |
| 7404 |
buf.append("package test1;\n"); |
| 7405 |
buf.append("public class A {\n"); |
| 7406 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7407 |
buf.append(" String string = \"foo\";\n"); |
| 7408 |
buf.append(" System.out.println(string + 1 + \" \\\"bar\\\" \");\n"); |
| 7409 |
buf.append(" }\n"); |
| 7410 |
buf.append("}\n"); |
| 7411 |
String expected3= buf.toString(); |
| 7412 |
|
| 7413 |
buf= new StringBuffer(); |
| 7414 |
buf.append("package test1;\n"); |
| 7415 |
buf.append("public class A {\n"); |
| 7416 |
buf.append(" private static final String FOO = \"foo\";\n"); |
| 7417 |
buf.append("\n"); |
| 7418 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7419 |
buf.append(" System.out.println(FOO + 1 + \" \\\"bar\\\" \");\n"); |
| 7420 |
buf.append(" }\n"); |
| 7421 |
buf.append("}\n"); |
| 7422 |
String expected4= buf.toString(); |
| 7423 |
|
| 7424 |
buf= new StringBuffer(); |
| 7425 |
buf.append("package test1;\n"); |
| 7426 |
buf.append("public class A {\n"); |
| 7427 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7428 |
buf.append(" StringBuilder stringBuilder = new StringBuilder();\n"); |
| 7429 |
buf.append(" stringBuilder.append(\"foo\");\n"); |
| 7430 |
buf.append(" stringBuilder.append(1);\n"); |
| 7431 |
buf.append(" stringBuilder.append(\" \\\"bar\\\" \");\n"); |
| 7432 |
buf.append(" System.out.println(stringBuilder.toString());\n"); |
| 7433 |
buf.append(" }\n"); |
| 7434 |
buf.append("}\n"); |
| 7435 |
String expected5= buf.toString(); |
| 7436 |
|
| 7437 |
buf= new StringBuffer(); |
| 7438 |
buf.append("package test1;\n"); |
| 7439 |
buf.append("public class A {\n"); |
| 7440 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7441 |
buf.append(" System.out.println((\"foo\" + 1 + \" \\\"bar\\\" \"));\n"); |
| 7442 |
buf.append(" }\n"); |
| 7443 |
buf.append("}\n"); |
| 7444 |
String expected6= buf.toString(); |
| 7445 |
|
| 7446 |
buf= new StringBuffer(); |
| 7447 |
buf.append("package test1;\n"); |
| 7448 |
buf.append("public class A {\n"); |
| 7449 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7450 |
buf.append(" System.out.println(\"FOO\" + 1 + \" \\\"bar\\\" \");\n"); |
| 7451 |
buf.append(" }\n"); |
| 7452 |
buf.append("}\n"); |
| 7453 |
String expected7= buf.toString(); |
| 7454 |
|
| 7455 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5821 |
} |
7456 |
} |
| 5822 |
|
7457 |
|
| 5823 |
public void testConvertToMessageFormat15() throws Exception { |
7458 |
public void testConvertToMessageFormat15() throws Exception { |
|
Lines 5835-5840
Link Here
|
| 5835 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + o1 + \""), 0); |
7470 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + o1 + \""), 0); |
| 5836 |
List proposals= collectAssists(context, false); |
7471 |
List proposals= collectAssists(context, false); |
| 5837 |
|
7472 |
|
|
|
7473 |
assertNumberOfProposals(proposals, 7); |
| 5838 |
assertCorrectLabels(proposals); |
7474 |
assertCorrectLabels(proposals); |
| 5839 |
|
7475 |
|
| 5840 |
buf= new StringBuffer(); |
7476 |
buf= new StringBuffer(); |
|
Lines 5849-5855
Link Here
|
| 5849 |
buf.append("}\n"); |
7485 |
buf.append("}\n"); |
| 5850 |
String expected1= buf.toString(); |
7486 |
String expected1= buf.toString(); |
| 5851 |
|
7487 |
|
| 5852 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
7488 |
buf= new StringBuffer(); |
|
|
7489 |
buf.append("package test1;\n"); |
| 7490 |
buf.append("public class A {\n"); |
| 7491 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7492 |
buf.append(" String string = \"foo\";\n"); |
| 7493 |
buf.append(" System.out.println(string + o1 + \" \\\"bar\\\" \" + o2);\n"); |
| 7494 |
buf.append(" }\n"); |
| 7495 |
buf.append("}\n"); |
| 7496 |
String expected2= buf.toString(); |
| 7497 |
|
| 7498 |
buf= new StringBuffer(); |
| 7499 |
buf.append("package test1;\n"); |
| 7500 |
buf.append("public class A {\n"); |
| 7501 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7502 |
buf.append(" String string = \"foo\";\n"); |
| 7503 |
buf.append(" System.out.println(string + o1 + \" \\\"bar\\\" \" + o2);\n"); |
| 7504 |
buf.append(" }\n"); |
| 7505 |
buf.append("}\n"); |
| 7506 |
String expected3= buf.toString(); |
| 7507 |
|
| 7508 |
buf= new StringBuffer(); |
| 7509 |
buf.append("package test1;\n"); |
| 7510 |
buf.append("public class A {\n"); |
| 7511 |
buf.append(" private static final String FOO = \"foo\";\n"); |
| 7512 |
buf.append("\n"); |
| 7513 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7514 |
buf.append(" System.out.println(FOO + o1 + \" \\\"bar\\\" \" + o2);\n"); |
| 7515 |
buf.append(" }\n"); |
| 7516 |
buf.append("}\n"); |
| 7517 |
String expected4= buf.toString(); |
| 7518 |
|
| 7519 |
buf= new StringBuffer(); |
| 7520 |
buf.append("package test1;\n"); |
| 7521 |
buf.append("public class A {\n"); |
| 7522 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7523 |
buf.append(" StringBuilder stringBuilder = new StringBuilder();\n"); |
| 7524 |
buf.append(" stringBuilder.append(\"foo\");\n"); |
| 7525 |
buf.append(" stringBuilder.append(o1);\n"); |
| 7526 |
buf.append(" stringBuilder.append(\" \\\"bar\\\" \");\n"); |
| 7527 |
buf.append(" stringBuilder.append(o2);\n"); |
| 7528 |
buf.append(" System.out.println(stringBuilder.toString());\n"); |
| 7529 |
buf.append(" }\n"); |
| 7530 |
buf.append("}\n"); |
| 7531 |
String expected5= buf.toString(); |
| 7532 |
|
| 7533 |
buf= new StringBuffer(); |
| 7534 |
buf.append("package test1;\n"); |
| 7535 |
buf.append("public class A {\n"); |
| 7536 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7537 |
buf.append(" System.out.println((\"foo\" + o1 + \" \\\"bar\\\" \" + o2));\n"); |
| 7538 |
buf.append(" }\n"); |
| 7539 |
buf.append("}\n"); |
| 7540 |
String expected6= buf.toString(); |
| 7541 |
|
| 7542 |
buf= new StringBuffer(); |
| 7543 |
buf.append("package test1;\n"); |
| 7544 |
buf.append("public class A {\n"); |
| 7545 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7546 |
buf.append(" System.out.println(\"FOO\" + o1 + \" \\\"bar\\\" \" + o2);\n"); |
| 7547 |
buf.append(" }\n"); |
| 7548 |
buf.append("}\n"); |
| 7549 |
String expected7= buf.toString(); |
| 7550 |
|
| 7551 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5853 |
} |
7552 |
} |
| 5854 |
|
7553 |
|
| 5855 |
public void testConvertToMessageFormatApostrophe() throws Exception { |
7554 |
public void testConvertToMessageFormatApostrophe() throws Exception { |
|
Lines 5867-5872
Link Here
|
| 5867 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + o1 + \""), 0); |
7566 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf("\" + o1 + \""), 0); |
| 5868 |
List proposals= collectAssists(context, false); |
7567 |
List proposals= collectAssists(context, false); |
| 5869 |
|
7568 |
|
|
|
7569 |
assertNumberOfProposals(proposals, 7); |
| 5870 |
assertCorrectLabels(proposals); |
7570 |
assertCorrectLabels(proposals); |
| 5871 |
|
7571 |
|
| 5872 |
buf= new StringBuffer(); |
7572 |
buf= new StringBuffer(); |
|
Lines 5881-5887
Link Here
|
| 5881 |
buf.append("}\n"); |
7581 |
buf.append("}\n"); |
| 5882 |
String expected1= buf.toString(); |
7582 |
String expected1= buf.toString(); |
| 5883 |
|
7583 |
|
| 5884 |
assertExpectedExistInProposals(proposals, new String[] { expected1 }); |
7584 |
buf= new StringBuffer(); |
|
|
7585 |
buf.append("package test1;\n"); |
| 7586 |
buf.append("public class A {\n"); |
| 7587 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7588 |
buf.append(" String string = \"foo'\";\n"); |
| 7589 |
buf.append(" System.out.println(string + o1 + \"' \\\"bar\\\" \" + o2);\n"); |
| 7590 |
buf.append(" }\n"); |
| 7591 |
buf.append("}\n"); |
| 7592 |
String expected2= buf.toString(); |
| 7593 |
|
| 7594 |
buf= new StringBuffer(); |
| 7595 |
buf.append("package test1;\n"); |
| 7596 |
buf.append("public class A {\n"); |
| 7597 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7598 |
buf.append(" String string = \"foo'\";\n"); |
| 7599 |
buf.append(" System.out.println(string + o1 + \"' \\\"bar\\\" \" + o2);\n"); |
| 7600 |
buf.append(" }\n"); |
| 7601 |
buf.append("}\n"); |
| 7602 |
String expected3= buf.toString(); |
| 7603 |
|
| 7604 |
buf= new StringBuffer(); |
| 7605 |
buf.append("package test1;\n"); |
| 7606 |
buf.append("public class A {\n"); |
| 7607 |
buf.append(" private static final String FOO = \"foo'\";\n"); |
| 7608 |
buf.append("\n"); |
| 7609 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7610 |
buf.append(" System.out.println(FOO + o1 + \"' \\\"bar\\\" \" + o2);\n"); |
| 7611 |
buf.append(" }\n"); |
| 7612 |
buf.append("}\n"); |
| 7613 |
String expected4= buf.toString(); |
| 7614 |
|
| 7615 |
buf= new StringBuffer(); |
| 7616 |
buf.append("package test1;\n"); |
| 7617 |
buf.append("public class A {\n"); |
| 7618 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7619 |
buf.append(" StringBuilder stringBuilder = new StringBuilder();\n"); |
| 7620 |
buf.append(" stringBuilder.append(\"foo'\");\n"); |
| 7621 |
buf.append(" stringBuilder.append(o1);\n"); |
| 7622 |
buf.append(" stringBuilder.append(\"' \\\"bar\\\" \");\n"); |
| 7623 |
buf.append(" stringBuilder.append(o2);\n"); |
| 7624 |
buf.append(" System.out.println(stringBuilder.toString());\n"); |
| 7625 |
buf.append(" }\n"); |
| 7626 |
buf.append("}\n"); |
| 7627 |
String expected5= buf.toString(); |
| 7628 |
|
| 7629 |
buf= new StringBuffer(); |
| 7630 |
buf.append("package test1;\n"); |
| 7631 |
buf.append("public class A {\n"); |
| 7632 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7633 |
buf.append(" System.out.println((\"foo'\" + o1 + \"' \\\"bar\\\" \" + o2));\n"); |
| 7634 |
buf.append(" }\n"); |
| 7635 |
buf.append("}\n"); |
| 7636 |
String expected6= buf.toString(); |
| 7637 |
|
| 7638 |
buf= new StringBuffer(); |
| 7639 |
buf.append("package test1;\n"); |
| 7640 |
buf.append("public class A {\n"); |
| 7641 |
buf.append(" public void foo(Object o1, Object o2) {\n"); |
| 7642 |
buf.append(" System.out.println(\"FOO'\" + o1 + \"' \\\"bar\\\" \" + o2);\n"); |
| 7643 |
buf.append(" }\n"); |
| 7644 |
buf.append("}\n"); |
| 7645 |
String expected7= buf.toString(); |
| 7646 |
|
| 7647 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7 }); |
| 5885 |
} |
7648 |
} |
| 5886 |
|
7649 |
|
| 5887 |
public void testConvertToMessageFormatExtendedOperands() throws Exception { |
7650 |
public void testConvertToMessageFormatExtendedOperands() throws Exception { |
|
Lines 5898-5903
Link Here
|
| 5898 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(" + "), 0); |
7661 |
AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(" + "), 0); |
| 5899 |
List proposals= collectAssists(context, false); |
7662 |
List proposals= collectAssists(context, false); |
| 5900 |
|
7663 |
|
|
|
7664 |
assertNumberOfProposals(proposals, 8); |
| 5901 |
assertCorrectLabels(proposals); |
7665 |
assertCorrectLabels(proposals); |
| 5902 |
|
7666 |
|
| 5903 |
buf= new StringBuffer(); |
7667 |
buf= new StringBuffer(); |
|
Lines 5930-5936
Link Here
|
| 5930 |
buf.append("}\n"); |
7694 |
buf.append("}\n"); |
| 5931 |
String expected2= buf.toString(); |
7695 |
String expected2= buf.toString(); |
| 5932 |
|
7696 |
|
| 5933 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2 }); |
7697 |
buf= new StringBuffer(); |
|
|
7698 |
buf.append("package test1;\n"); |
| 7699 |
buf.append("public class A {\n"); |
| 7700 |
buf.append(" public void foo() {\n"); |
| 7701 |
buf.append(" String string = \"a\";\n"); |
| 7702 |
buf.append(" String s2= string + \"b\" + 3L + \"c\" + (4-2) + \"d\" + \"e\" + \"f\";\n"); |
| 7703 |
buf.append(" }\n"); |
| 7704 |
buf.append("}\n"); |
| 7705 |
String expected3= buf.toString(); |
| 7706 |
|
| 7707 |
buf= new StringBuffer(); |
| 7708 |
buf.append("package test1;\n"); |
| 7709 |
buf.append("public class A {\n"); |
| 7710 |
buf.append(" private static final String A = \"a\";\n"); |
| 7711 |
buf.append("\n"); |
| 7712 |
buf.append(" public void foo() {\n"); |
| 7713 |
buf.append(" String s2= A + \"b\" + 3L + \"c\" + (4-2) + \"d\" + \"e\" + \"f\";\n"); |
| 7714 |
buf.append(" }\n"); |
| 7715 |
buf.append("}\n"); |
| 7716 |
String expected4= buf.toString(); |
| 7717 |
|
| 7718 |
buf= new StringBuffer(); |
| 7719 |
buf.append("package test1;\n"); |
| 7720 |
buf.append("public class A {\n"); |
| 7721 |
buf.append(" public void foo() {\n"); |
| 7722 |
buf.append(" String s2= (\"a\" + \"b\") + 3L + \"c\" + (4-2) + \"d\" + \"e\" + \"f\";\n"); |
| 7723 |
buf.append(" }\n"); |
| 7724 |
buf.append("}\n"); |
| 7725 |
String expected5= buf.toString(); |
| 7726 |
|
| 7727 |
buf= new StringBuffer(); |
| 7728 |
buf.append("package test1;\n"); |
| 7729 |
buf.append("public class A {\n"); |
| 7730 |
buf.append(" public void foo() {\n"); |
| 7731 |
buf.append(" String s2= \"ab\" + 3L + \"c\" + (4-2) + \"d\" + \"e\" + \"f\";\n"); |
| 7732 |
buf.append(" }\n"); |
| 7733 |
buf.append("}\n"); |
| 7734 |
String expected6= buf.toString(); |
| 7735 |
|
| 7736 |
buf= new StringBuffer(); |
| 7737 |
buf.append("package test1;\n"); |
| 7738 |
buf.append("public class A {\n"); |
| 7739 |
buf.append(" public void foo() {\n"); |
| 7740 |
buf.append(" String string = \"a\";\n"); |
| 7741 |
buf.append(" String s2= string + \"b\" + 3L + \"c\" + (4-2) + \"d\" + \"e\" + \"f\";\n"); |
| 7742 |
buf.append(" }\n"); |
| 7743 |
buf.append("}\n"); |
| 7744 |
String expected7= buf.toString(); |
| 7745 |
|
| 7746 |
buf= new StringBuffer(); |
| 7747 |
buf.append("package test1;\n"); |
| 7748 |
buf.append("public class A {\n"); |
| 7749 |
buf.append(" public void foo() {\n"); |
| 7750 |
buf.append(" String s2= \"A\" + \"b\" + 3L + \"c\" + (4-2) + \"d\" + \"e\" + \"f\";\n"); |
| 7751 |
buf.append(" }\n"); |
| 7752 |
buf.append("}\n"); |
| 7753 |
String expected8= buf.toString(); |
| 7754 |
|
| 7755 |
assertExpectedExistInProposals(proposals, new String[] { expected1, expected2, expected3, expected4, expected5, expected6, expected7, expected8 }); |
| 5934 |
} |
7756 |
} |
| 5935 |
|
7757 |
|
| 5936 |
public void testMissingEnumConstantsInCase1() throws Exception { |
7758 |
public void testMissingEnumConstantsInCase1() throws Exception { |
|
Lines 5957-5963
Link Here
|
| 5957 |
assertCorrectLabels(proposals); |
7779 |
assertCorrectLabels(proposals); |
| 5958 |
assertNumberOfProposals(proposals, 3); |
7780 |
assertNumberOfProposals(proposals, 3); |
| 5959 |
|
7781 |
|
| 5960 |
String[] expected= new String[2]; |
7782 |
String[] expected= new String[3]; |
| 5961 |
buf= new StringBuffer(); |
7783 |
buf= new StringBuffer(); |
| 5962 |
buf.append("package p;\n"); |
7784 |
buf.append("package p;\n"); |
| 5963 |
buf.append("\n"); |
7785 |
buf.append("\n"); |
|
Lines 5999-6004
Link Here
|
| 5999 |
buf.append(" }\n"); |
7821 |
buf.append(" }\n"); |
| 6000 |
buf.append("}\n"); |
7822 |
buf.append("}\n"); |
| 6001 |
expected[1]= buf.toString(); |
7823 |
expected[1]= buf.toString(); |
|
|
7824 |
|
| 7825 |
buf= new StringBuffer(); |
| 7826 |
buf.append("package p;\n"); |
| 7827 |
buf.append("\n"); |
| 7828 |
buf.append("public class E {\n"); |
| 7829 |
buf.append(" enum MyEnum {\n"); |
| 7830 |
buf.append(" X1, X2, X3\n"); |
| 7831 |
buf.append(" }\n"); |
| 7832 |
buf.append(" \n"); |
| 7833 |
buf.append(" public void foo(MyEnum x) {\n"); |
| 7834 |
buf.append(" }\n"); |
| 7835 |
buf.append("}\n"); |
| 7836 |
expected[2]= buf.toString(); |
| 6002 |
|
7837 |
|
| 6003 |
assertExpectedExistInProposals(proposals, expected); |
7838 |
assertExpectedExistInProposals(proposals, expected); |
| 6004 |
} |
7839 |
} |
|
Lines 6029-6035
Link Here
|
| 6029 |
assertCorrectLabels(proposals); |
7864 |
assertCorrectLabels(proposals); |
| 6030 |
assertNumberOfProposals(proposals, 3); |
7865 |
assertNumberOfProposals(proposals, 3); |
| 6031 |
|
7866 |
|
| 6032 |
String[] expected= new String[2]; |
7867 |
String[] expected= new String[3]; |
| 6033 |
buf= new StringBuffer(); |
7868 |
buf= new StringBuffer(); |
| 6034 |
buf.append("package p;\n"); |
7869 |
buf.append("package p;\n"); |
| 6035 |
buf.append("\n"); |
7870 |
buf.append("\n"); |
|
Lines 6073-6078
Link Here
|
| 6073 |
buf.append(" }\n"); |
7908 |
buf.append(" }\n"); |
| 6074 |
buf.append("}\n"); |
7909 |
buf.append("}\n"); |
| 6075 |
expected[1]= buf.toString(); |
7910 |
expected[1]= buf.toString(); |
|
|
7911 |
|
| 7912 |
buf= new StringBuffer(); |
| 7913 |
buf.append("package p;\n"); |
| 7914 |
buf.append("\n"); |
| 7915 |
buf.append("public class E {\n"); |
| 7916 |
buf.append(" enum MyEnum {\n"); |
| 7917 |
buf.append(" X1, X2, X3\n"); |
| 7918 |
buf.append(" }\n"); |
| 7919 |
buf.append(" \n"); |
| 7920 |
buf.append(" public void foo(MyEnum x) {\n"); |
| 7921 |
buf.append(" if (x == MyEnum.X1) {\n"); |
| 7922 |
buf.append(" }\n"); |
| 7923 |
buf.append(" }\n"); |
| 7924 |
buf.append("}\n"); |
| 7925 |
expected[2]= buf.toString(); |
| 6076 |
|
7926 |
|
| 6077 |
assertExpectedExistInProposals(proposals, expected); |
7927 |
assertExpectedExistInProposals(proposals, expected); |
| 6078 |
} |
7928 |
} |
|
Lines 6236-6242
Link Here
|
| 6236 |
assertCorrectLabels(proposals); |
8086 |
assertCorrectLabels(proposals); |
| 6237 |
assertNumberOfProposals(proposals, 2); |
8087 |
assertNumberOfProposals(proposals, 2); |
| 6238 |
|
8088 |
|
| 6239 |
String[] expected= new String[1]; |
8089 |
String[] expected= new String[2]; |
| 6240 |
buf= new StringBuffer(); |
8090 |
buf= new StringBuffer(); |
| 6241 |
buf.append("package p;\n"); |
8091 |
buf.append("package p;\n"); |
| 6242 |
buf.append("\n"); |
8092 |
buf.append("\n"); |
|
Lines 6261-6266
Link Here
|
| 6261 |
buf.append("}\n"); |
8111 |
buf.append("}\n"); |
| 6262 |
expected[0]= buf.toString(); |
8112 |
expected[0]= buf.toString(); |
| 6263 |
|
8113 |
|
|
|
8114 |
buf= new StringBuffer(); |
| 8115 |
buf.append("package p;\n"); |
| 8116 |
buf.append("\n"); |
| 8117 |
buf.append("public class E {\n"); |
| 8118 |
buf.append(" enum MyEnum {\n"); |
| 8119 |
buf.append(" X1, X2, X3\n"); |
| 8120 |
buf.append(" }\n"); |
| 8121 |
buf.append(" \n"); |
| 8122 |
buf.append(" public void foo(MyEnum x) {\n"); |
| 8123 |
buf.append(" if (x == MyEnum.X1) {\n"); |
| 8124 |
buf.append(" } else if (x == MyEnum.X2) {\n"); |
| 8125 |
buf.append(" } else if (x == MyEnum.X3) {\n"); |
| 8126 |
buf.append(" }\n"); |
| 8127 |
buf.append(" }\n"); |
| 8128 |
buf.append("}\n"); |
| 8129 |
expected[1]= buf.toString(); |
| 8130 |
|
| 6264 |
assertExpectedExistInProposals(proposals, expected); |
8131 |
assertExpectedExistInProposals(proposals, expected); |
| 6265 |
} |
8132 |
} |
| 6266 |
|
8133 |
|
|
Lines 6283-6289
Link Here
|
| 6283 |
assertNumberOfProposals(proposals, 3); |
8150 |
assertNumberOfProposals(proposals, 3); |
| 6284 |
assertCorrectLabels(proposals); |
8151 |
assertCorrectLabels(proposals); |
| 6285 |
|
8152 |
|
| 6286 |
String[] expected= new String[1]; |
8153 |
String[] expected= new String[3]; |
| 6287 |
buf= new StringBuffer(); |
8154 |
buf= new StringBuffer(); |
| 6288 |
buf.append("package test1;\n"); |
8155 |
buf.append("package test1;\n"); |
| 6289 |
buf.append("public class E {\n"); |
8156 |
buf.append("public class E {\n"); |
|
Lines 6295-6300
Link Here
|
| 6295 |
buf.append(" }\n"); |
8162 |
buf.append(" }\n"); |
| 6296 |
buf.append("}\n"); |
8163 |
buf.append("}\n"); |
| 6297 |
expected[0]= buf.toString(); |
8164 |
expected[0]= buf.toString(); |
|
|
8165 |
|
| 8166 |
buf= new StringBuffer(); |
| 8167 |
buf.append("package test1;\n"); |
| 8168 |
buf.append("public class E {\n"); |
| 8169 |
buf.append(" public static void main(String... args) {\n"); |
| 8170 |
buf.append(" System.out.print(arg);\n"); |
| 8171 |
buf.append(" }\n"); |
| 8172 |
buf.append("}\n"); |
| 8173 |
expected[1]= buf.toString(); |
| 8174 |
|
| 8175 |
buf= new StringBuffer(); |
| 8176 |
buf.append("package test1;\n"); |
| 8177 |
buf.append("public class E {\n"); |
| 8178 |
buf.append(" public static void main(String... args) {\n"); |
| 8179 |
buf.append(" for (final @Deprecated String arg : args)\n"); |
| 8180 |
buf.append(" System.out.print(arg);\n"); |
| 8181 |
buf.append(" }\n"); |
| 8182 |
buf.append("}\n"); |
| 8183 |
expected[2]= buf.toString(); |
| 6298 |
|
8184 |
|
| 6299 |
assertExpectedExistInProposals(proposals, expected); |
8185 |
assertExpectedExistInProposals(proposals, expected); |
| 6300 |
} |
8186 |
} |
|
Lines 6323-6329
Link Here
|
| 6323 |
assertNumberOfProposals(proposals, 2); |
8209 |
assertNumberOfProposals(proposals, 2); |
| 6324 |
assertCorrectLabels(proposals); |
8210 |
assertCorrectLabels(proposals); |
| 6325 |
|
8211 |
|
| 6326 |
String[] expected= new String[1]; |
8212 |
String[] expected= new String[2]; |
| 6327 |
buf= new StringBuffer(); |
8213 |
buf= new StringBuffer(); |
| 6328 |
buf.append("package test1;\n"); |
8214 |
buf.append("package test1;\n"); |
| 6329 |
buf.append("public class E {\n"); |
8215 |
buf.append("public class E {\n"); |
|
Lines 6341-6346
Link Here
|
| 6341 |
buf.append(" }\n"); |
8227 |
buf.append(" }\n"); |
| 6342 |
buf.append("}\n"); |
8228 |
buf.append("}\n"); |
| 6343 |
expected[0]= buf.toString(); |
8229 |
expected[0]= buf.toString(); |
|
|
8230 |
|
| 8231 |
buf= new StringBuffer(); |
| 8232 |
buf.append("package test1;\n"); |
| 8233 |
buf.append("public class E {\n"); |
| 8234 |
buf.append(" public void foo(int[][][] ints) {\n"); |
| 8235 |
buf.append(" outer: //convert this\n"); |
| 8236 |
buf.append(" for (int i : is) {\n"); |
| 8237 |
buf.append(" System.out.print(i);\n"); |
| 8238 |
buf.append(" System.out.print(\", \");\n"); |
| 8239 |
buf.append(" }\n"); |
| 8240 |
buf.append(" System.out.println();\n"); |
| 8241 |
buf.append(" }\n"); |
| 8242 |
buf.append("}\n"); |
| 8243 |
expected[1]= buf.toString(); |
| 6344 |
|
8244 |
|
| 6345 |
assertExpectedExistInProposals(proposals, expected); |
8245 |
assertExpectedExistInProposals(proposals, expected); |
| 6346 |
} |
8246 |
} |
|
Lines 6369-6375
Link Here
|
| 6369 |
assertNumberOfProposals(proposals, 4); |
8269 |
assertNumberOfProposals(proposals, 4); |
| 6370 |
assertCorrectLabels(proposals); |
8270 |
assertCorrectLabels(proposals); |
| 6371 |
|
8271 |
|
| 6372 |
String[] expected= new String[2]; |
8272 |
String[] expected= new String[4]; |
| 6373 |
buf= new StringBuffer(); |
8273 |
buf= new StringBuffer(); |
| 6374 |
buf.append("package test1;\n"); |
8274 |
buf.append("package test1;\n"); |
| 6375 |
buf.append("import java.util.Arrays;\n"); |
8275 |
buf.append("import java.util.Arrays;\n"); |
|
Lines 6407-6412
Link Here
|
| 6407 |
buf.append("}\n"); |
8307 |
buf.append("}\n"); |
| 6408 |
expected[1]= buf.toString(); |
8308 |
expected[1]= buf.toString(); |
| 6409 |
|
8309 |
|
|
|
8310 |
buf= new StringBuffer(); |
| 8311 |
buf.append("package test1;\n"); |
| 8312 |
buf.append("import java.util.Arrays;\n"); |
| 8313 |
buf.append("import java.util.List;\n"); |
| 8314 |
buf.append("public class E {\n"); |
| 8315 |
buf.append(" void foo() {\n"); |
| 8316 |
buf.append(" System.out.println(number.doubleValue());\n"); |
| 8317 |
buf.append(" }\n"); |
| 8318 |
buf.append(" private List<? extends Number> getNums() {\n"); |
| 8319 |
buf.append(" return Arrays.asList(1, 2.34, 0xFFFF);\n"); |
| 8320 |
buf.append(" }\n"); |
| 8321 |
buf.append("}\n"); |
| 8322 |
expected[2]= buf.toString(); |
| 8323 |
|
| 8324 |
buf= new StringBuffer(); |
| 8325 |
buf.append("package test1;\n"); |
| 8326 |
buf.append("import java.util.Arrays;\n"); |
| 8327 |
buf.append("import java.util.List;\n"); |
| 8328 |
buf.append("public class E {\n"); |
| 8329 |
buf.append(" void foo() {\n"); |
| 8330 |
buf.append(" for (Number number : getNums())\n"); |
| 8331 |
buf.append(" System.out.println(number.doubleValue());\n"); |
| 8332 |
buf.append(" }\n"); |
| 8333 |
buf.append(" private List<? extends Number> getNums() {\n"); |
| 8334 |
buf.append(" return Arrays.asList(1, 2.34, 0xFFFF);\n"); |
| 8335 |
buf.append(" }\n"); |
| 8336 |
buf.append("}\n"); |
| 8337 |
expected[3]= buf.toString(); |
| 8338 |
|
| 6410 |
assertExpectedExistInProposals(proposals, expected); |
8339 |
assertExpectedExistInProposals(proposals, expected); |
| 6411 |
} |
8340 |
} |
| 6412 |
|
8341 |
|
|
Lines 6433-6439
Link Here
|
| 6433 |
assertNumberOfProposals(proposals, 3); |
8362 |
assertNumberOfProposals(proposals, 3); |
| 6434 |
assertCorrectLabels(proposals); |
8363 |
assertCorrectLabels(proposals); |
| 6435 |
|
8364 |
|
| 6436 |
String[] expected= new String[1]; |
8365 |
String[] expected= new String[3]; |
| 6437 |
buf= new StringBuffer(); |
8366 |
buf= new StringBuffer(); |
| 6438 |
buf.append("package test1;\n"); |
8367 |
buf.append("package test1;\n"); |
| 6439 |
buf.append("import java.util.Collection;\n"); |
8368 |
buf.append("import java.util.Collection;\n"); |
|
Lines 6451-6456
Link Here
|
| 6451 |
buf.append(" }\n"); |
8380 |
buf.append(" }\n"); |
| 6452 |
buf.append("}\n"); |
8381 |
buf.append("}\n"); |
| 6453 |
expected[0]= buf.toString(); |
8382 |
expected[0]= buf.toString(); |
|
|
8383 |
|
| 8384 |
buf= new StringBuffer(); |
| 8385 |
buf.append("package test1;\n"); |
| 8386 |
buf.append("import java.util.Collection;\n"); |
| 8387 |
buf.append("import java.util.List;\n"); |
| 8388 |
buf.append("public class E {\n"); |
| 8389 |
buf.append(" void foo(Collection<? extends List<? extends Number>> allNums) {\n"); |
| 8390 |
buf.append(" for (Number number : nums) {\n"); |
| 8391 |
buf.append(" System.out.println(number.doubleValue());\n"); |
| 8392 |
buf.append(" }\n"); |
| 8393 |
buf.append(" }\n"); |
| 8394 |
buf.append("}\n"); |
| 8395 |
expected[1]= buf.toString(); |
| 8396 |
|
| 8397 |
buf= new StringBuffer(); |
| 8398 |
buf.append("package test1;\n"); |
| 8399 |
buf.append("import java.util.Collection;\n"); |
| 8400 |
buf.append("import java.util.List;\n"); |
| 8401 |
buf.append("public class E {\n"); |
| 8402 |
buf.append(" void foo(Collection<? extends List<? extends Number>> allNums) {\n"); |
| 8403 |
buf.append(" for (List<? extends Number> nums : allNums)\n"); |
| 8404 |
buf.append(" for (Number number : nums) {\n"); |
| 8405 |
buf.append(" System.out.println(number.doubleValue());\n"); |
| 8406 |
buf.append(" }\n"); |
| 8407 |
buf.append(" }\n"); |
| 8408 |
buf.append("}\n"); |
| 8409 |
expected[2]= buf.toString(); |
| 6454 |
|
8410 |
|
| 6455 |
assertExpectedExistInProposals(proposals, expected); |
8411 |
assertExpectedExistInProposals(proposals, expected); |
| 6456 |
} |
8412 |
} |