Skip to content

Commit 65614f1

Browse files
committed
Actually use new lib resolution
1 parent 57c68f1 commit 65614f1

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

src/Server/Model/Monad.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import Agda.Utils.FileId (File, getIdFile)
5555
#endif
5656
#if MIN_VERSION_Agda(2,7,0)
5757
import Agda.Interaction.Response (Response_boot(Resp_HighlightingInfo))
58+
import Server.AgdaLibResolver (findAgdaLib)
5859
#else
5960
import Agda.Interaction.Response (Response(Resp_HighlightingInfo))
6061
#endif
@@ -233,9 +234,7 @@ type WithAgdaLibM = WithAgdaLibT ServerM
233234

234235
runWithAgdaLib :: LSP.Uri -> WithAgdaLibM a -> ServerM a
235236
runWithAgdaLib uri x = do
236-
let normUri = LSP.toNormalizedUri uri
237-
model <- askModel
238-
agdaLib <- Model.getAgdaLib normUri model
237+
agdaLib <- findAgdaLib uri
239238
runWithAgdaLibT agdaLib x
240239

241240
instance (MonadIO m) => MonadAgdaLib (WithAgdaLibT m) where

test/Test/AgdaLibResolution.hs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Monad (runServerT)
1515
import Server.AgdaLibResolver (findAgdaLib)
1616
import qualified Server.Filesystem as FS
1717
import Server.Model.AgdaLib (AgdaLibOrigin (FromFile), agdaLibIncludes, agdaLibName, agdaLibOrigin)
18-
import Server.Model.Monad (MonadAgdaLib, askAgdaLib, runWithAgdaLib)
18+
import Server.Model.Monad (MonadAgdaLib, askAgdaLib, runWithAgdaLib, runWithAgdaLibT)
1919
import System.Directory (makeAbsolute)
2020
import Test.Tasty (TestTree, testGroup)
2121
import Test.Tasty.HUnit (testCase, (@?=))
@@ -31,17 +31,7 @@ tests :: TestTree
3131
tests =
3232
testGroup
3333
"Agda lib resolution"
34-
[ testCase "Module without imports in lib without dependencies" $ do
35-
model <- TestData.getModel
36-
37-
LSP.runLspT undefined $ do
38-
env <- TestData.getServerEnv model
39-
runServerT env $ do
40-
runWithAgdaLib (LSP.filePathToUri natPath) $ do
41-
natSrc <- TestData.parseSourceFromPath natPath
42-
_ <- indexFile natSrc
43-
return (),
44-
testCase "Module with imports in lib without lib dependencies" $ do
34+
[ testCase "Explicit" $ do
4535
model <- TestData.getModel
4636

4737
absConstPath <- makeAbsolute constPath
@@ -59,5 +49,25 @@ tests =
5949
liftIO $ lib ^. agdaLibName @?= "no-deps"
6050
#endif
6151
liftIO $ lib ^. agdaLibOrigin @?= FromFile (FS.LocalFilePath absAgdaLibPath)
62-
liftIO $ lib ^. agdaLibIncludes @?= [FS.LocalFilePath absSrcPath]
52+
liftIO $ lib ^. agdaLibIncludes @?= [FS.LocalFilePath absSrcPath],
53+
testCase "Module without imports in lib without dependencies" $ do
54+
model <- TestData.getModel
55+
56+
LSP.runLspT undefined $ do
57+
env <- TestData.getServerEnv model
58+
runServerT env $ do
59+
runWithAgdaLib (LSP.filePathToUri natPath) $ do
60+
natSrc <- TestData.parseSourceFromPath natPath
61+
_ <- indexFile natSrc
62+
return (),
63+
testCase "Module with imports in lib without lib dependencies" $ do
64+
model <- TestData.getModel
65+
66+
LSP.runLspT undefined $ do
67+
env <- TestData.getServerEnv model
68+
runServerT env $ do
69+
runWithAgdaLib (LSP.filePathToUri constPath) $ do
70+
constSrc <- TestData.parseSourceFromPath constPath
71+
_ <- indexFile constSrc
72+
return ()
6373
]

0 commit comments

Comments
 (0)