11{-# LANGUAGE OverloadedStrings #-}
22{-# LANGUAGE ScopedTypeVariables #-}
3+ {-# LANGUAGE CPP #-}
34
45module PackagePluginSpec where
56
@@ -62,26 +63,47 @@ packageSpec = do
6263 uri = filePathToUri $ fp </> " add-package-test.cabal"
6364 args = AddParams fp (fp </> " AddPackage.hs" ) " text"
6465 act = addCmd' args
65- textEdits = List
66- [ TextEdit (Range (Position 0 0 ) (Position 7 27 )) $ T. concat
67- [ " cabal-version: >=1.10\n "
68- , " name: add-package-test\n "
69- , " version: 0.1.0.0\n "
70- , " license: BSD3\n "
71- ,
" maintainer: [email protected] \n " 72- , " author: Luke Lau\n "
73- , " build-type: Simple\n "
74- , " extra-source-files:\n "
75- , " ChangeLog.md"
66+ textEdits =
67+ #if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,4,0,0)))
68+ List
69+ [ TextEdit (Range (Position 0 0 ) (Position 7 27 )) $ T. concat
70+ [ " cabal-version: >=1.10\n "
71+ , " name: add-package-test\n "
72+ , " version: 0.1.0.0\n "
73+ , " license: BSD3\n "
74+ ,
" maintainer: [email protected] \n " 75+ , " author: Luke Lau\n "
76+ , " build-type: Simple\n "
77+ , " extra-source-files:\n "
78+ , " ChangeLog.md"
79+ ]
80+ , TextEdit (Range (Position 10 0 ) (Position 13 34 )) $ T. concat
81+ [ " main-is: AddPackage.hs\n "
82+ , " default-language: Haskell2010\n "
83+ , " build-depends:\n "
84+ , " base >=4.7 && <5,\n "
85+ , " text -any"
86+ ]
7687 ]
77- , TextEdit (Range (Position 10 0 ) (Position 13 34 )) $ T. concat
78- [ " main-is: AddPackage.hs\n "
79- , " default-language: Haskell2010\n "
80- , " build-depends:\n "
81- , " base >=4.7 && <5,\n "
82- , " text -any"
88+ #else
89+ List -- TODO: this seems to indicate that the command does nothing
90+ [ TextEdit (Range (Position 0 0 ) (Position 7 27 )) $ T. concat
91+ [ " name: add-package-test\n "
92+ , " version: 0.1.0.0\n "
93+ , " cabal-version: >=1.10\n "
94+ , " build-type: Simple\n "
95+ , " license: BSD3"
96+ ,
" maintainer: [email protected] \n " 97+ , " author: Luke Lau\n "
98+ , " extra-source-files:\n "
99+ , " ChangeLog.md"
100+ ]
101+ , TextEdit (Range (Position 9 0 ) (Position 13 34 ))
102+ [ " executable AddPackage\n "
103+ , " main-is: AddPackage.hs"
104+ ]
83105 ]
84- ]
106+ #endif
85107 res = IdeResultOk
86108 $ WorkspaceEdit (Just $ H. singleton uri textEdits) Nothing
87109 testCommand testPlugins act " package" " add" args res
@@ -94,31 +116,57 @@ packageSpec = do
94116 uri = filePathToUri $ fp </> " add-package-test.cabal"
95117 args = AddParams fp (fp </> " AddPackage.hs" ) " text"
96118 act = addCmd' args
97- textEdits = List
98- [ TextEdit (Range (Position 0 0 ) (Position 7 27 )) $ T. concat
99- [ " cabal-version: >=1.10\n "
100- , " name: add-package-test\n "
101- , " version: 0.1.0.0\n "
102- , " license: BSD3\n "
103- ,
" maintainer: [email protected] \n " 104- , " author: Luke Lau\n "
105- , " build-type: Simple\n "
106- , " extra-source-files:\n "
107- , " ChangeLog.md"
119+ textEdits =
120+ #if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,4,0,0)))
121+ List
122+ [ TextEdit (Range (Position 0 0 ) (Position 7 27 )) $ T. concat
123+ [ " cabal-version: >=1.10\n "
124+ , " name: add-package-test\n "
125+ , " version: 0.1.0.0\n "
126+ , " license: BSD3\n "
127+ ,
" maintainer: [email protected] \n " 128+ , " author: Luke Lau\n "
129+ , " build-type: Simple\n "
130+ , " extra-source-files:\n "
131+ , " ChangeLog.md"
132+ ]
133+ , TextEdit (Range (Position 10 0 ) (Position 13 34 )) $ T. concat
134+ [ " exposed-modules:\n "
135+ , " AddPackage\n "
136+ , " default-language: Haskell2010\n "
137+ , " build-depends:\n "
138+ , " base >=4.7 && <5,\n "
139+ , " text -any"
140+ ]
108141 ]
109- , TextEdit (Range (Position 10 0 ) (Position 13 34 )) $ T. concat
110- [ " exposed-modules:\n "
111- , " AddPackage\n "
112- , " default-language: Haskell2010\n "
113- , " build-depends:\n "
114- , " base >=4.7 && <5,\n "
115- , " text -any"
142+ #else
143+ List
144+ [ TextEdit (Range (Position 0 0 ) (Position 7 27 )) $ T. concat
145+ [ " name: add-package-test\n "
146+ , " version: 0.1.0.0\n "
147+ , " cabal-version: >=1.10\n "
148+ , " build-type: Simple\n "
149+ , " license: BSD3\n "
150+ ,
" maintainer: [email protected] \n " 151+ , " author: Luke Lau\n "
152+ , " extra-source-files:\n "
153+ , " ChangeLog.md\n "
154+ ]
155+ , TextEdit (Range (Position 10 0 ) (Position 13 34 )) $ T. concat
156+ [ " exposed-modules:\n "
157+ , " AddPackage\n "
158+ , " build-depends:\n "
159+ , " base >=4.7 && <5,\n "
160+ , " text -any\n "
161+ , " default-language: Haskell2010\n "
162+ ]
116163 ]
117- ]
164+ #endif
118165 res = IdeResultOk
119166 $ WorkspaceEdit (Just $ H. singleton uri textEdits) Nothing
120167 testCommand testPlugins act " package" " add" args res
121168
169+
122170 it " Add package to package.yaml to executable component"
123171 $ withCurrentDirectory (testdata </> " hpack-exe" )
124172 $ do
@@ -169,26 +217,27 @@ packageSpec = do
169217 act = addCmd' args
170218 res = IdeResultOk
171219 $ WorkspaceEdit (Just $ H. singleton uri textEdits) Nothing
172- textEdits = List
173- [ TextEdit (Range (Position 0 0 ) (Position 25 0 )) $ T. concat
174- [ " library:\n "
175- , " source-dirs: app\n "
176- , " dependencies:\n "
177- , " - zlib\n "
178- , " - base >= 4.7 && < 5\n "
179- , " copyright: 2018 Author name here\n "
180- ,
" maintainer: [email protected] \n " 181- , " name: asdf\n "
182- , " version: 0.1.0.0\n "
183- , " extra-source-files:\n "
184- , " - README.md\n "
185- , " - ChangeLog.md\n "
186- , " author: Author name here\n "
187- , " github: githubuser/asdf\n "
188- , " license: BSD3\n "
189- , " description: Please see the README on GitHub at <https://github.com/githubuser/asdf#readme>\n "
190- ]
191- ]
220+ textEdits =
221+ List
222+ [ TextEdit (Range (Position 0 0 ) (Position 25 0 )) $ T. concat
223+ [ " library:\n "
224+ , " source-dirs: app\n "
225+ , " dependencies:\n "
226+ , " - zlib\n "
227+ , " - base >= 4.7 && < 5\n "
228+ , " copyright: 2018 Author name here\n "
229+ ,
" maintainer: [email protected] \n " 230+ , " name: asdf\n "
231+ , " version: 0.1.0.0\n "
232+ , " extra-source-files:\n "
233+ , " - README.md\n "
234+ , " - ChangeLog.md\n "
235+ , " author: Author name here\n "
236+ , " github: githubuser/asdf\n "
237+ , " license: BSD3\n "
238+ , " description: Please see the README on GitHub at <https://github.com/githubuser/asdf#readme>\n "
239+ ]
240+ ]
192241 testCommand testPlugins act " package" " add" args res
193242 it
194243 " Add package to package.yaml in hpack project with generated cabal to executable component"
0 commit comments