mirror of
https://github.com/haskell/haskell-ide-engine.git
synced 2024-08-15 22:10:31 +03:00
Detect files in main-is of components
For cabal-helper cradle
This commit is contained in:
parent
c2e4bfc548
commit
f0f2a967e5
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
4
test/testdata/hieBiosMainIs/Main.hs
vendored
Normal file
4
test/testdata/hieBiosMainIs/Main.hs
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
module Main where
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Hello, Haskell!"
|
2
test/testdata/hieBiosMainIs/Setup.hs
vendored
Normal file
2
test/testdata/hieBiosMainIs/Setup.hs
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
8
test/testdata/hieBiosMainIs/hieBiosMainIs.cabal
vendored
Normal file
8
test/testdata/hieBiosMainIs/hieBiosMainIs.cabal
vendored
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user