Skip to content

Commit 8e82300

Browse files
fendorAvi-D-coder
authored andcommitted
Look for stack.yaml before selecting .cabal location as project root (haskell#1531)
1 parent 1046c12 commit 8e82300

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

hie-plugin-api/Haskell/Ide/Engine/Cradle.hs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ Just (Ex (ProjLocV2File { plProjectDirV2 = "/Foo/"}))
201201
202202
In the given example, it is not guaranteed which project type is found,
203203
it is only guaranteed that it will not identify the project
204-
as a cabal v1-project.
204+
as a cabal v1-project. Note that with cabal-helper version (1.0),
205+
by default a *.cabal file is identified as a 'ProjLocV2Dir' project.
206+
The same issue as before exists and we look for a 'ProjLocV2File' or
207+
'ProjLocStackYaml' before deciding that 'ProjLocV2Dir' marks the project root.
205208
206209
Note that this will not return any project types for which the corresponding
207210
build tool is not on the PATH. This is "stack" and "cabal" for stack and cabal
@@ -219,13 +222,13 @@ findCabalHelperEntryPoint fp = do
219222
let supportedProjs = filter (\x -> supported x isStackInstalled isCabalInstalled) allProjs
220223
debugm $ "These projects have the build tools installed: " ++ show (map (\(Ex x) -> show x) supportedProjs)
221224

222-
case filter (\p -> isCabalNewProject p || isStackProject p) supportedProjs of
225+
case filter (\p -> isCabalV2FileProject p || isStackProject p) supportedProjs of
223226
(x:_) -> return $ Just x
224-
[] -> case filter isCabalOldProject supportedProjs of
227+
[] -> case filter isCabalProject supportedProjs of
225228
(x:_) -> return $ Just x
226229
[] -> return Nothing
227230
where
228-
supported :: (Ex ProjLoc) -> Bool -> Bool -> Bool
231+
supported :: Ex ProjLoc -> Bool -> Bool -> Bool
229232
supported (Ex ProjLocStackYaml {}) stackInstalled _ = stackInstalled
230233
supported (Ex ProjLocV2Dir {}) _ cabalInstalled = cabalInstalled
231234
supported (Ex ProjLocV2File {}) _ cabalInstalled = cabalInstalled
@@ -235,13 +238,14 @@ findCabalHelperEntryPoint fp = do
235238
isStackProject (Ex ProjLocStackYaml {}) = True
236239
isStackProject _ = False
237240

238-
isCabalNewProject (Ex ProjLocV2Dir {}) = True
239-
isCabalNewProject (Ex ProjLocV2File {}) = True
240-
isCabalNewProject _ = False
241+
isCabalV2FileProject (Ex ProjLocV2File {}) = True
242+
isCabalV2FileProject _ = False
241243

242-
isCabalOldProject (Ex ProjLocV1Dir {}) = True
243-
isCabalOldProject (Ex ProjLocV1CabalFile {}) = True
244-
isCabalOldProject _ = False
244+
isCabalProject (Ex ProjLocV1CabalFile {}) = True
245+
isCabalProject (Ex ProjLocV1Dir {}) = True
246+
isCabalProject (Ex ProjLocV2File {}) = True
247+
isCabalProject (Ex ProjLocV2Dir {}) = True
248+
isCabalProject _ = False
245249

246250
{- | Given a FilePath, find the cradle the FilePath belongs to.
247251

0 commit comments

Comments
 (0)