@@ -1513,7 +1513,108 @@ extendImportTests = testGroup "extend import actions"
1513
1513
]
1514
1514
where
1515
1515
tests overrideCheckProject =
1516
- [ testSession " extend single line import with value" $ template
1516
+ [ testSession " extend all constructors for record field" $ template
1517
+ [(" ModuleA.hs" , T. unlines
1518
+ [ " module ModuleA where"
1519
+ , " data A = B { a :: Int }"
1520
+ ])]
1521
+ (" ModuleB.hs" , T. unlines
1522
+ [ " module ModuleB where"
1523
+ , " import ModuleA (A(B))"
1524
+ , " f = a"
1525
+ ])
1526
+ (Range (Position 2 4 ) (Position 2 5 ))
1527
+ [ " Add A(..) to the import list of ModuleA"
1528
+ , " Add A(a) to the import list of ModuleA"
1529
+ , " Add a to the import list of ModuleA"
1530
+ ]
1531
+ (T. unlines
1532
+ [ " module ModuleB where"
1533
+ , " import ModuleA (A(..))"
1534
+ , " f = a"
1535
+ ])
1536
+ , testSession " extend all constructors with sibling" $ template
1537
+ [(" ModuleA.hs" , T. unlines
1538
+ [ " module ModuleA where"
1539
+ , " data Foo"
1540
+ , " data Bar"
1541
+ , " data A = B | C"
1542
+ ])]
1543
+ (" ModuleB.hs" , T. unlines
1544
+ [ " module ModuleB where"
1545
+ , " import ModuleA ( Foo, A (C) , Bar ) "
1546
+ , " f = B"
1547
+ ])
1548
+ (Range (Position 2 4 ) (Position 2 5 ))
1549
+ [ " Add A(..) to the import list of ModuleA"
1550
+ , " Add A(B) to the import list of ModuleA"
1551
+ ]
1552
+ (T. unlines
1553
+ [ " module ModuleB where"
1554
+ , " import ModuleA ( Foo, A (..) , Bar ) "
1555
+ , " f = B"
1556
+ ])
1557
+ , testSession " extend all constructors with comment" $ template
1558
+ [(" ModuleA.hs" , T. unlines
1559
+ [ " module ModuleA where"
1560
+ , " data Foo"
1561
+ , " data Bar"
1562
+ , " data A = B | C"
1563
+ ])]
1564
+ (" ModuleB.hs" , T. unlines
1565
+ [ " module ModuleB where"
1566
+ , " import ModuleA ( Foo, A (C{-comment--}) , Bar ) "
1567
+ , " f = B"
1568
+ ])
1569
+ (Range (Position 2 4 ) (Position 2 5 ))
1570
+ [ " Add A(..) to the import list of ModuleA"
1571
+ , " Add A(B) to the import list of ModuleA"
1572
+ ]
1573
+ (T. unlines
1574
+ [ " module ModuleB where"
1575
+ , " import ModuleA ( Foo, A (..{-comment--}) , Bar ) "
1576
+ , " f = B"
1577
+ ])
1578
+ , testSession " extend all constructors for type operator" $ template
1579
+ []
1580
+ (" ModuleA.hs" , T. unlines
1581
+ [ " module ModuleA where"
1582
+ , " import Data.Type.Equality ((:~:))"
1583
+ , " x :: (:~:) [] []"
1584
+ , " x = Refl"
1585
+ ])
1586
+ (Range (Position 3 17 ) (Position 3 18 ))
1587
+ [ " Add (:~:)(..) to the import list of Data.Type.Equality"
1588
+ , " Add type (:~:)(Refl) to the import list of Data.Type.Equality" ]
1589
+ (T. unlines
1590
+ [ " module ModuleA where"
1591
+ , " import Data.Type.Equality ((:~:) (..))"
1592
+ , " x :: (:~:) [] []"
1593
+ , " x = Refl"
1594
+ ])
1595
+ , testSession " extend all constructors for class" $ template
1596
+ [(" ModuleA.hs" , T. unlines
1597
+ [ " module ModuleA where"
1598
+ , " class C a where"
1599
+ , " m1 :: a -> a"
1600
+ , " m2 :: a -> a"
1601
+ ])]
1602
+ (" ModuleB.hs" , T. unlines
1603
+ [ " module ModuleB where"
1604
+ , " import ModuleA (C(m1))"
1605
+ , " b = m2"
1606
+ ])
1607
+ (Range (Position 2 5 ) (Position 2 5 ))
1608
+ [ " Add C(..) to the import list of ModuleA"
1609
+ , " Add C(m2) to the import list of ModuleA"
1610
+ , " Add m2 to the import list of ModuleA"
1611
+ ]
1612
+ (T. unlines
1613
+ [ " module ModuleB where"
1614
+ , " import ModuleA (C(..))"
1615
+ , " b = m2"
1616
+ ])
1617
+ , testSession " extend single line import with value" $ template
1517
1618
[(" ModuleA.hs" , T. unlines
1518
1619
[ " module ModuleA where"
1519
1620
, " stuffA :: Double"
@@ -1561,7 +1662,9 @@ extendImportTests = testGroup "extend import actions"
1561
1662
, " main = case (fromList []) of _ :| _ -> pure ()"
1562
1663
])
1563
1664
(Range (Position 2 5 ) (Position 2 6 ))
1564
- [" Add NonEmpty((:|)) to the import list of Data.List.NonEmpty" ]
1665
+ [ " Add NonEmpty((:|)) to the import list of Data.List.NonEmpty"
1666
+ , " Add NonEmpty(..) to the import list of Data.List.NonEmpty"
1667
+ ]
1565
1668
(T. unlines
1566
1669
[ " module ModuleB where"
1567
1670
, " import Data.List.NonEmpty (fromList, NonEmpty ((:|)))"
@@ -1576,7 +1679,9 @@ extendImportTests = testGroup "extend import actions"
1576
1679
, " x = Just 10"
1577
1680
])
1578
1681
(Range (Position 3 5 ) (Position 2 6 ))
1579
- [" Add Maybe(Just) to the import list of Data.Maybe" ]
1682
+ [ " Add Maybe(Just) to the import list of Data.Maybe"
1683
+ , " Add Maybe(..) to the import list of Data.Maybe"
1684
+ ]
1580
1685
(T. unlines
1581
1686
[ " module ModuleB where"
1582
1687
, " import Prelude hiding (Maybe(..))"
@@ -1614,7 +1719,9 @@ extendImportTests = testGroup "extend import actions"
1614
1719
, " b = Constructor"
1615
1720
])
1616
1721
(Range (Position 3 5 ) (Position 3 5 ))
1617
- [" Add A(Constructor) to the import list of ModuleA" ]
1722
+ [ " Add A(Constructor) to the import list of ModuleA"
1723
+ , " Add A(..) to the import list of ModuleA"
1724
+ ]
1618
1725
(T. unlines
1619
1726
[ " module ModuleB where"
1620
1727
, " import ModuleA (A (Constructor))"
@@ -1633,7 +1740,9 @@ extendImportTests = testGroup "extend import actions"
1633
1740
, " b = Constructor"
1634
1741
])
1635
1742
(Range (Position 3 5 ) (Position 3 5 ))
1636
- [" Add A(Constructor) to the import list of ModuleA" ]
1743
+ [ " Add A(Constructor) to the import list of ModuleA"
1744
+ , " Add A(..) to the import list of ModuleA"
1745
+ ]
1637
1746
(T. unlines
1638
1747
[ " module ModuleB where"
1639
1748
, " import ModuleA (A (Constructor{-Constructor-}))"
@@ -1653,7 +1762,9 @@ extendImportTests = testGroup "extend import actions"
1653
1762
, " b = ConstructorFoo"
1654
1763
])
1655
1764
(Range (Position 3 5 ) (Position 3 5 ))
1656
- [" Add A(ConstructorFoo) to the import list of ModuleA" ]
1765
+ [ " Add A(ConstructorFoo) to the import list of ModuleA"
1766
+ , " Add A(..) to the import list of ModuleA"
1767
+ ]
1657
1768
(T. unlines
1658
1769
[ " module ModuleB where"
1659
1770
, " import ModuleA (A (ConstructorBar, ConstructorFoo), a)"
@@ -1715,8 +1826,10 @@ extendImportTests = testGroup "extend import actions"
1715
1826
, " b = m2"
1716
1827
])
1717
1828
(Range (Position 2 5 ) (Position 2 5 ))
1718
- [" Add C(m2) to the import list of ModuleA" ,
1719
- " Add m2 to the import list of ModuleA" ]
1829
+ [ " Add C(m2) to the import list of ModuleA"
1830
+ , " Add m2 to the import list of ModuleA"
1831
+ , " Add C(..) to the import list of ModuleA"
1832
+ ]
1720
1833
(T. unlines
1721
1834
[ " module ModuleB where"
1722
1835
, " import ModuleA (C(m1, m2))"
@@ -1735,8 +1848,10 @@ extendImportTests = testGroup "extend import actions"
1735
1848
, " b = m2"
1736
1849
])
1737
1850
(Range (Position 2 5 ) (Position 2 5 ))
1738
- [" Add m2 to the import list of ModuleA" ,
1739
- " Add C(m2) to the import list of ModuleA" ]
1851
+ [ " Add m2 to the import list of ModuleA"
1852
+ , " Add C(m2) to the import list of ModuleA"
1853
+ , " Add C(..) to the import list of ModuleA"
1854
+ ]
1740
1855
(T. unlines
1741
1856
[ " module ModuleB where"
1742
1857
, " import ModuleA (C(m1), m2)"
@@ -1777,7 +1892,8 @@ extendImportTests = testGroup "extend import actions"
1777
1892
, " x = Refl"
1778
1893
])
1779
1894
(Range (Position 3 17 ) (Position 3 18 ))
1780
- [" Add type (:~:)(Refl) to the import list of Data.Type.Equality" ]
1895
+ [ " Add type (:~:)(Refl) to the import list of Data.Type.Equality"
1896
+ , " Add (:~:)(..) to the import list of Data.Type.Equality" ]
1781
1897
(T. unlines
1782
1898
[ " module ModuleA where"
1783
1899
, " import Data.Type.Equality ((:~:) (Refl))"
@@ -2046,6 +2162,8 @@ suggestImportTests = testGroup "suggest import actions"
2046
2162
, " qualified Data.Functor as T"
2047
2163
, " qualified Data.Data as T"
2048
2164
] " f = T.putStrLn" [] " import qualified Data.Text.IO as T"
2165
+ , test True [] " f = (.|.)" [] " import Data.Bits (Bits(..))"
2166
+ , test True [] " f = empty" [] " import Control.Applicative (Alternative(..))"
2049
2167
]
2050
2168
, expectFailBecause " importing pattern synonyms is unsupported" $ test True [] " k (Some x) = x" [] " import B (pattern Some)"
2051
2169
]
0 commit comments