@@ -1546,11 +1546,65 @@ class A {
1546
1546
assertSuggestKeywords (statementStartOutsideClass);
1547
1547
}
1548
1548
1549
- @failingTest
1550
- Future <void > test_ifElement_noElse_last () async {
1549
+ Future <void > test_ifElement_list_hasElse_notLast () async {
1551
1550
addTestSource ('''
1552
- void f() {
1553
- [if (true) 1 ^];
1551
+ void f(int i) {
1552
+ [if (true) 1 else 2 e^, i, i];
1553
+ }
1554
+ ''' );
1555
+ await computeSuggestions ();
1556
+ assertSuggestKeywords ([
1557
+ ...COLLECTION_ELEMENT_START ,
1558
+ ...EXPRESSION_START_NO_INSTANCE ,
1559
+ ]);
1560
+ }
1561
+
1562
+ Future <void > test_ifElement_list_noElse_insideForElement () async {
1563
+ addTestSource ('''
1564
+ void f(int i) {
1565
+ [for (var e in []) if (true) i ^];
1566
+ }
1567
+ ''' );
1568
+ await computeSuggestions ();
1569
+ assertSuggestKeywords ([
1570
+ ...COLLECTION_ELEMENT_START ,
1571
+ ...EXPRESSION_START_NO_INSTANCE ,
1572
+ Keyword .ELSE
1573
+ ]);
1574
+ }
1575
+
1576
+ Future <void > test_ifElement_list_noElse_insideIfElement_else () async {
1577
+ addTestSource ('''
1578
+ void f(int i) {
1579
+ [if (false) i else if (true) i ^];
1580
+ }
1581
+ ''' );
1582
+ await computeSuggestions ();
1583
+ assertSuggestKeywords ([
1584
+ ...COLLECTION_ELEMENT_START ,
1585
+ ...EXPRESSION_START_NO_INSTANCE ,
1586
+ Keyword .ELSE
1587
+ ]);
1588
+ }
1589
+
1590
+ Future <void > test_ifElement_list_noElse_insideIfElement_then () async {
1591
+ addTestSource ('''
1592
+ void f(int i) {
1593
+ [if (false) if (true) i ^];
1594
+ }
1595
+ ''' );
1596
+ await computeSuggestions ();
1597
+ assertSuggestKeywords ([
1598
+ ...COLLECTION_ELEMENT_START ,
1599
+ ...EXPRESSION_START_NO_INSTANCE ,
1600
+ Keyword .ELSE
1601
+ ]);
1602
+ }
1603
+
1604
+ Future <void > test_ifElement_list_noElse_last () async {
1605
+ addTestSource ('''
1606
+ void f(int i) {
1607
+ [if (true) i ^];
1554
1608
}
1555
1609
''' );
1556
1610
await computeSuggestions ();
@@ -1561,7 +1615,7 @@ void f() {
1561
1615
]);
1562
1616
}
1563
1617
1564
- Future <void > test_ifElement_noElse_notInElement () async {
1618
+ Future <void > test_ifElement_list_noElse_notInElement () async {
1565
1619
addTestSource ('''
1566
1620
void f() {
1567
1621
[if (true) 1, ^];
@@ -1572,11 +1626,17 @@ void f() {
1572
1626
[...COLLECTION_ELEMENT_START , ...EXPRESSION_START_NO_INSTANCE ]);
1573
1627
}
1574
1628
1575
- @failingTest
1576
- Future <void > test_ifElement_noElse_notLast () async {
1629
+ @FailingTest (
1630
+ issue: 'https://github.com/dart-lang/sdk/issues/48837' ,
1631
+ reason:
1632
+ 'The CompletionTarget for this test is determined to be "j", which '
1633
+ 'prevents us from suggesting "else". This CompletionTarget bug seems '
1634
+ 'to stem from the current state of `ListLiteralImpl.childEntities` '
1635
+ 'not including comma tokens.' )
1636
+ Future <void > test_ifElement_list_noElse_notLast () async {
1577
1637
addTestSource ('''
1578
- void f(int i) {
1579
- [if (true) 1 ^, i ];
1638
+ void f(int i, int j ) {
1639
+ [if (true) i ^, j ];
1580
1640
}
1581
1641
''' );
1582
1642
await computeSuggestions ();
@@ -1587,8 +1647,7 @@ void f(int i) {
1587
1647
]);
1588
1648
}
1589
1649
1590
- @failingTest
1591
- Future <void > test_ifElement_partialElse_last () async {
1650
+ Future <void > test_ifElement_list_partialElse_last () async {
1592
1651
addTestSource ('''
1593
1652
void f() {
1594
1653
[if (true) 1 e^];
@@ -1602,8 +1661,7 @@ void f() {
1602
1661
]);
1603
1662
}
1604
1663
1605
- @failingTest
1606
- Future <void > test_ifElement_partialElse_notLast () async {
1664
+ Future <void > test_ifElement_list_partialElse_notLast () async {
1607
1665
addTestSource ('''
1608
1666
void f(int i) {
1609
1667
[if (true) 1 e^, i];
@@ -1617,28 +1675,46 @@ void f(int i) {
1617
1675
]);
1618
1676
}
1619
1677
1620
- Future <void > test_ifOrForElement_forElement () async {
1678
+ Future <void > test_ifElement_list_partialElse_thenIsForElement () async {
1621
1679
addTestSource ('''
1622
- f() => [for (var e in c) ^];
1680
+ void f(int i) {
1681
+ [if (b) for (var e in c) e e^];
1682
+ }
1623
1683
''' );
1624
1684
await computeSuggestions ();
1625
- assertSuggestKeywords (COLLECTION_ELEMENT_START );
1685
+ assertSuggestKeywords ([
1686
+ ...COLLECTION_ELEMENT_START ,
1687
+ ...EXPRESSION_START_NO_INSTANCE ,
1688
+ Keyword .ELSE
1689
+ ]);
1626
1690
}
1627
1691
1628
- Future <void > test_ifOrForElement_ifElement_else () async {
1692
+ Future <void > test_ifElement_map_partialElse_notLast () async {
1629
1693
addTestSource ('''
1630
- f() => [if (true) 1 else ^];
1694
+ void f(int i) {
1695
+ <int, int>{if (true) 1: 1 e^, 2: i};
1696
+ }
1631
1697
''' );
1632
1698
await computeSuggestions ();
1633
- assertSuggestKeywords (COLLECTION_ELEMENT_START );
1699
+ assertSuggestKeywords ([
1700
+ ...COLLECTION_ELEMENT_START ,
1701
+ ...EXPRESSION_START_NO_INSTANCE ,
1702
+ Keyword .ELSE
1703
+ ]);
1634
1704
}
1635
1705
1636
- Future <void > test_ifOrForElement_ifElement_then () async {
1706
+ Future <void > test_ifElement_set_partialElse_notLast () async {
1637
1707
addTestSource ('''
1638
- f() => [if (true) ^];
1708
+ void f(int i) {
1709
+ <int>{if (true) 1 e^, i};
1710
+ }
1639
1711
''' );
1640
1712
await computeSuggestions ();
1641
- assertSuggestKeywords (COLLECTION_ELEMENT_START );
1713
+ assertSuggestKeywords ([
1714
+ ...COLLECTION_ELEMENT_START ,
1715
+ ...EXPRESSION_START_NO_INSTANCE ,
1716
+ Keyword .ELSE
1717
+ ]);
1642
1718
}
1643
1719
1644
1720
Future <void > test_ifOrForElement_list_empty () async {
@@ -1657,6 +1733,30 @@ f() => [^1, 2];
1657
1733
assertSuggestKeywords (COLLECTION_ELEMENT_START );
1658
1734
}
1659
1735
1736
+ Future <void > test_ifOrForElement_list_forElement () async {
1737
+ addTestSource ('''
1738
+ f() => [for (var e in c) ^];
1739
+ ''' );
1740
+ await computeSuggestions ();
1741
+ assertSuggestKeywords (COLLECTION_ELEMENT_START );
1742
+ }
1743
+
1744
+ Future <void > test_ifOrForElement_list_ifElement_else () async {
1745
+ addTestSource ('''
1746
+ f() => [if (true) 1 else ^];
1747
+ ''' );
1748
+ await computeSuggestions ();
1749
+ assertSuggestKeywords (COLLECTION_ELEMENT_START );
1750
+ }
1751
+
1752
+ Future <void > test_ifOrForElement_list_ifElement_then () async {
1753
+ addTestSource ('''
1754
+ f() => [if (true) ^];
1755
+ ''' );
1756
+ await computeSuggestions ();
1757
+ assertSuggestKeywords (COLLECTION_ELEMENT_START );
1758
+ }
1759
+
1660
1760
Future <void > test_ifOrForElement_list_last () async {
1661
1761
addTestSource ('''
1662
1762
f() => [1, 2, ^];
0 commit comments