Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion hie-plugin-api/Haskell/Ide/Engine/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,17 @@ partOfComponent fp' comp
| otherwise
= False
where
-- Check if the FilePath is in an executable or setup's main-is field
inMainIs :: FilePath -> Bool
inMainIs fp
| ChExeEntrypoint mainIs _ <- ciEntrypoints comp = mainIs == fp
| ChSetupEntrypoint mainIs <- ciEntrypoints comp = mainIs == fp
| otherwise = False

inTargets :: [FilePath] -> FilePath -> [String] -> Bool
inTargets sourceDirs fp targets
| Just relative <- relativeTo fp sourceDirs
= any (`elem` targets) [getModuleName relative, fp]
= any (`elem` targets) [getModuleName relative, fp] || inMainIs relative
| otherwise
= False

Expand Down
6 changes: 5 additions & 1 deletion test/functional/HieBiosSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import Test.Hspec
import TestUtils

spec :: Spec
spec = describe "hie-bios" $
spec = describe "hie-bios" $ do
it "loads modules inside main-is" $ runSession hieCommand fullCaps "test/testdata/hieBiosMainIs" $ do
_ <- openDoc "Main.hs" "haskell"
_ <- count 2 waitForDiagnostics
return ()
it "reports errors in hie.yaml" $ runSession hieCommand fullCaps "test/testdata/hieBiosError" $ do
_ <- openDoc "Foo.hs" "haskell"
_ <- skipManyTill loggingNotification (satisfy isMessage)
Expand Down
4 changes: 4 additions & 0 deletions test/testdata/hieBiosMainIs/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main where

main :: IO ()
main = putStrLn "Hello, Haskell!"
2 changes: 2 additions & 0 deletions test/testdata/hieBiosMainIs/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
8 changes: 8 additions & 0 deletions test/testdata/hieBiosMainIs/hieBiosMainIs.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cabal-version: >=1.10
name: hieBiosMainIs
version: 0.1.0.0
build-type: Simple
executable hieBiosMainIs
main-is: Main.hs
build-depends: base >=4.12 && <4.13
default-language: Haskell2010