on master help sign in
Merge pull request #39 from ollef/master
f455375Moritz Kiefer
src/Development/IDE/Import/FindImports.hs+6
@@ -68,6 +68,12 @@ locateModule
68 -> m (Either [FileDiagnostic] Import)
68 -> m (Either [FileDiagnostic] Import)
69locateModule dflags exts doesExist modName mbPkgName isSource = do
69locateModule dflags exts doesExist modName mbPkgName isSource = do
70 case mbPkgName of
70 case mbPkgName of
71+ -- "this" means that we should only look in the current package
72+ Just "this" -> do
73+ mbFile <- locateModuleFile dflags exts doesExist isSource $ unLoc modName
74+ case mbFile of
75+ Nothing -> return $ Left $ notFoundErr dflags modName $ LookupNotFound []
76+ Just file -> return $ Right $ FileImport file
71 -- if a package name is given we only go look for a package
77 -- if a package name is given we only go look for a package
72 Just _pkgName -> lookupInPackageDB dflags
78 Just _pkgName -> lookupInPackageDB dflags
73 Nothing -> do
79 Nothing -> do
test/exe/Main.hs+24
@@ -182,6 +182,30 @@ diagnosticTests = testGroup "diagnostics"
182 , [(DsWarning, (2, 0), "The import of 'ModuleA' is redundant")]
182 , [(DsWarning, (2, 0), "The import of 'ModuleA' is redundant")]
183 )
183 )
184 ]
184 ]
185+ , testSession "package imports" $ do
186+ let thisDataListContent = T.unlines
187+ [ "module Data.List where"
188+ , "x = 123"
189+ ]
190+ let mainContent = T.unlines
191+ [ "{-# LANGUAGE PackageImports #-}"
192+ , "module Main where"
193+ , "import qualified \"this\" Data.List as ThisList"
194+ , "import qualified \"base\" Data.List as BaseList"
195+ , "useThis = ThisList.x"
196+ , "useBase = BaseList.map"
197+ , "wrong1 = ThisList.map"
198+ , "wrong2 = BaseList.x"
199+ ]
200+ _ <- openDoc' "Data/List.hs" "haskell" thisDataListContent
201+ _ <- openDoc' "Main.hs" "haskell" mainContent
202+ expectDiagnostics
203+ [ ( "Main.hs"
204+ , [(DsError, (6, 9), "Not in scope: \8216ThisList.map\8217")
205+ ,(DsError, (7, 9), "Not in scope: \8216BaseList.x\8217")
206+ ]
207+ )
208+ ]
185 ]
209 ]
186
210
187codeActionTests :: TestTree
211codeActionTests :: TestTree