Skip to content

Commit d5e8ab9

Browse files
committed
Commit new tests + refactor
1 parent 0026002 commit d5e8ab9

File tree

4 files changed

+322
-24
lines changed

4 files changed

+322
-24
lines changed

src/Hie/Cabal/Parser.hs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ parsePackage =
3636
<|> (skipToNextLine >> parsePackage)
3737
<|> pure (Package "" [])
3838

39-
component :: Indent -> Text -> Parser Name
40-
component i t = do
39+
componentHeader :: Indent -> Text -> Parser Name
40+
componentHeader i t = do
4141
indent i
4242
_ <- asciiCI t
4343
skipMany tabOrSpace
@@ -47,14 +47,20 @@ component i t = do
4747

4848
parseComponent :: Indent -> Parser Component
4949
parseComponent i =
50-
parseLib i
51-
<|> parseExe i
52-
<|> parseNamed i "test-suite" Test
50+
parseExe i
51+
<|> parseLib i
52+
<|> parseTestSuite i
5353

5454
parseLib :: Indent -> Parser Component
55-
parseLib i = do
56-
n <- component i "library"
57-
Lib n <$> extractPath (i + 1)
55+
parseLib i = parseSec i "library" Lib
56+
57+
parseTestSuite :: Indent -> Parser Component
58+
parseTestSuite i = parseSec i "test-suite" Test
59+
60+
parseExe :: Indent -> Parser Component
61+
parseExe i = do
62+
n <- componentHeader i "executable"
63+
Exe n <$> pathMain (i + 1) "." ""
5864

5965
parseQuoted :: Parser Text
6066
parseQuoted = do
@@ -64,28 +70,17 @@ parseQuoted = do
6470
parseString :: Parser Name
6571
parseString = parseQuoted <|> takeWhile1 (not . (\c -> isSpace c || c == ','))
6672

67-
parseExe :: Indent -> Parser Component
68-
parseExe i = do
69-
n <- component i "executable"
70-
Exe n <$> pathMain (i + 1) "." ""
71-
7273
pathMain :: Indent -> Text -> Text -> Parser Text
7374
pathMain i p m =
7475
(field i "hs-source-dirs" >>= (\p' -> pathMain i p' m))
7576
<|> (field i "main-is" >>= pathMain i p)
7677
<|> (skipBlockLine i >> pathMain i p m)
7778
<|> pure (p <> "/" <> m)
7879

79-
parseNamed :: Indent -> Text -> (Name -> Path -> Component) -> Parser Component
80-
parseNamed i compType compCon =
81-
do
82-
indent i
83-
_ <- asciiCI compType <?> "asciiCI " <> T.unpack compType
84-
skipMany tabOrSpace
85-
n <- parseString <?> "N"
86-
skipToNextLine
87-
compCon n <$> extractPath (i + 1)
88-
<?> T.unpack ("parseNamed " <> compType)
80+
parseSec :: Indent -> Text -> (Name -> Path -> Component) -> Parser Component
81+
parseSec i compType compCon = do
82+
n <- componentHeader i compType
83+
compCon n <$> extractPath (i + 1)
8984

9085
skipToNextLine :: Parser ()
9186
skipToNextLine = skipWhile (not . isEndOfLine) >> endOfLine

test/Spec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec = do
2020
`shouldParse` Exe "implicit-hie-exe" "app/Main.hs"
2121
describe "Should Succeed"
2222
$ it "successfully parses test section"
23-
$ testSection ~> parseNamed 0 "test-suite" Test
23+
$ testSection ~> parseTestSuite 0
2424
`shouldParse` Test "implicit-hie-test" "test"
2525
describe "Should Succeed"
2626
$ it "successfully parses library section"

test/haskell-language-server-cabal

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
cabal-version: 2.2
2+
category: Development
3+
name: haskell-language-server
4+
version: 0.1.0.0
5+
synopsis: LSP server for GHC
6+
description: Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
7+
homepage: https://github.com/haskell/haskell-language-server#readme
8+
bug-reports: https://github.com/haskell/haskell-language-server/issues
9+
author: Alan Zimmerman
10+
maintainer: [email protected]
11+
copyright: Alan Zimmerman
12+
license: Apache-2.0
13+
license-file: LICENSE
14+
build-type: Simple
15+
extra-source-files:
16+
README.md
17+
ChangeLog.md
18+
19+
flag agpl
20+
Description: Enable AGPL dependencies
21+
Default: True
22+
Manual: False
23+
24+
flag pedantic
25+
Description: Enable -Werror
26+
Default: False
27+
Manual: True
28+
29+
source-repository head
30+
type: git
31+
location: https://github.com/haskell/haskell-language-server
32+
33+
common agpl
34+
if flag(agpl)
35+
cpp-options:
36+
-DAGPL
37+
38+
library
39+
import: agpl
40+
exposed-modules:
41+
Ide.Cradle
42+
Ide.Logger
43+
Ide.Plugin
44+
Ide.Plugin.Config
45+
Ide.Plugin.Example
46+
Ide.Plugin.Example2
47+
Ide.Plugin.GhcIde
48+
Ide.Plugin.Ormolu
49+
Ide.Plugin.Pragmas
50+
Ide.Plugin.Floskell
51+
Ide.Plugin.Formatter
52+
Ide.PluginUtils
53+
Ide.Types
54+
Ide.Version
55+
other-modules:
56+
Paths_haskell_language_server
57+
hs-source-dirs:
58+
src
59+
build-depends:
60+
base >=4.12 && <5
61+
, aeson
62+
, binary
63+
, bytestring
64+
, Cabal
65+
, cabal-helper >= 1.1
66+
, containers
67+
, data-default
68+
, deepseq
69+
, Diff
70+
, directory
71+
, extra
72+
, filepath
73+
, floskell == 0.10.*
74+
, ghc
75+
, ghcide >= 0.1
76+
, gitrev
77+
, hashable
78+
, haskell-lsp == 0.21.*
79+
, hie-bios >= 0.4
80+
, hslogger
81+
, lens
82+
, ormolu ^>= 0.0.5.0
83+
, optparse-simple
84+
, process
85+
, regex-tdfa >= 1.3.1.0
86+
, shake >= 0.17.5
87+
, text
88+
, transformers
89+
, unordered-containers
90+
if os(windows)
91+
build-depends: Win32
92+
else
93+
build-depends: unix
94+
if flag(agpl)
95+
build-depends:
96+
brittany
97+
exposed-modules:
98+
Ide.Plugin.Brittany
99+
100+
ghc-options:
101+
-Wall
102+
-Wredundant-constraints
103+
-Wno-name-shadowing
104+
if flag(pedantic)
105+
ghc-options: -Werror
106+
107+
default-language: Haskell2010
108+
109+
executable haskell-language-server
110+
import: agpl
111+
main-is: Main.hs
112+
hs-source-dirs:
113+
exe
114+
other-modules:
115+
Arguments
116+
Paths_haskell_language_server
117+
autogen-modules:
118+
Paths_haskell_language_server
119+
ghc-options:
120+
-threaded
121+
-Wall
122+
-Wno-name-shadowing
123+
-Wredundant-constraints
124+
-- allow user RTS overrides
125+
-rtsopts
126+
-- disable idle GC
127+
-- disable parallel GC
128+
-- increase nursery size
129+
"-with-rtsopts=-I0 -qg -A128M"
130+
if flag(pedantic)
131+
ghc-options: -Werror
132+
133+
build-depends:
134+
base >=4.7 && <5
135+
, aeson
136+
, async
137+
, base16-bytestring
138+
, binary
139+
, bytestring
140+
, cryptohash-sha1
141+
, containers
142+
, data-default
143+
, deepseq
144+
, directory
145+
, extra
146+
, filepath
147+
--------------------------------------------------------------
148+
-- The MIN_GHC_API_VERSION macro relies on MIN_VERSION pragmas
149+
-- which require depending on ghc. So the tests need to depend
150+
-- on ghc if they need to use MIN_GHC_API_VERSION. Maybe a
151+
-- better solution can be found, but this is a quick solution
152+
-- which works for now.
153+
, ghc
154+
--------------------------------------------------------------
155+
, ghc-check ^>= 0.1
156+
, ghc-paths
157+
, ghcide
158+
, gitrev
159+
, hashable
160+
, haskell-lsp
161+
, hie-bios >= 0.4
162+
, haskell-language-server
163+
, hslogger
164+
, optparse-applicative
165+
, shake >= 0.17.5
166+
, text
167+
, time
168+
, unordered-containers
169+
default-language: Haskell2010
170+
171+
executable haskell-language-server-wrapper
172+
import: agpl
173+
main-is: Wrapper.hs
174+
hs-source-dirs:
175+
exe
176+
other-modules:
177+
Arguments
178+
Paths_haskell_language_server
179+
autogen-modules:
180+
Paths_haskell_language_server
181+
ghc-options:
182+
-threaded
183+
-Wall
184+
-Wno-name-shadowing
185+
-Wredundant-constraints
186+
-- allow user RTS overrides
187+
-rtsopts
188+
-- disable idle GC
189+
-- disable parallel GC
190+
-- increase nursery size
191+
"-with-rtsopts=-I0 -qg -A128M"
192+
if flag(pedantic)
193+
ghc-options: -Werror
194+
build-depends:
195+
base
196+
, directory
197+
, extra
198+
, filepath
199+
, gitrev
200+
, ghc
201+
, ghc-paths
202+
, hie-bios
203+
, haskell-language-server
204+
, optparse-applicative
205+
, process
206+
default-language: Haskell2010
207+
208+
209+
test-suite func-test
210+
import: agpl
211+
type: exitcode-stdio-1.0
212+
default-language: Haskell2010
213+
build-tool-depends: hspec-discover:hspec-discover
214+
, haskell-language-server:haskell-language-server
215+
, cabal-helper:cabal-helper-main
216+
, ghcide:ghcide-test-preprocessor
217+
218+
build-depends:
219+
base >=4.7 && <5
220+
, aeson
221+
, data-default
222+
, haskell-lsp-types
223+
, hls-test-utils
224+
, hspec
225+
, lens
226+
, lsp-test >= 0.10.0.0
227+
, text
228+
, unordered-containers
229+
other-modules:
230+
-- CompletionSpec
231+
-- , CommandSpec
232+
-- , DeferredSpec
233+
-- , DefinitionSpec
234+
-- , DiagnosticsSpec
235+
FormatSpec
236+
-- , FunctionalBadProjectSpec
237+
-- , FunctionalCodeActionsSpec
238+
-- , FunctionalLiquidSpec
239+
, FunctionalSpec
240+
-- , HaReSpec
241+
-- , HieBiosSpec
242+
-- , HighlightSpec
243+
-- , HoverSpec
244+
, PluginSpec
245+
-- , ProgressSpec
246+
-- , ReferencesSpec
247+
-- , RenameSpec
248+
-- , SymbolsSpec
249+
-- , TypeDefinitionSpec
250+
, Utils
251+
, Paths_haskell_language_server
252+
253+
hs-source-dirs:
254+
test/functional
255+
ghc-options:
256+
-Wall
257+
-Wredundant-constraints
258+
-Wno-name-shadowing
259+
-threaded -rtsopts -with-rtsopts=-N
260+
if flag(pedantic)
261+
ghc-options: -Werror
262+
main-is: Main.hs
263+
-- other-modules:
264+
-- Development.IDE.Test
265+
-- Development.IDE.Test.Runfiles
266+
267+
library hls-test-utils
268+
import: agpl
269+
hs-source-dirs: test/utils
270+
exposed-modules: TestUtils
271+
build-depends: base
272+
, haskell-language-server
273+
, haskell-lsp
274+
, hie-bios
275+
, aeson
276+
, blaze-markup
277+
, containers
278+
, data-default
279+
, directory
280+
, filepath
281+
, hslogger
282+
, hspec
283+
, hspec-core
284+
, stm
285+
, text
286+
, unordered-containers
287+
, yaml
288+
ghc-options: -Wall -Wredundant-constraints
289+
if flag(pedantic)
290+
ghc-options: -Werror
291+
default-language: Haskell2010

test/hie.yaml.cbl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cradle:
2+
cabal:
3+
- path: "src"
4+
component: "lib:haskell-language-server"
5+
- path: "exe/Main.hs"
6+
component: "haskell-language-server:exe:haskell-language-server"
7+
- path: "exe/Wrapper.hs"
8+
component: "haskell-language-server:exe:haskell-language-server-wrapper"
9+
- path: "test/functional"
10+
component: "haskell-language-server:test:func-test"
11+
- path: "test/utils"
12+
component: "lib:haskell-language-server:hls-test-utils"

0 commit comments

Comments
 (0)