@@ -69,7 +69,7 @@ data AddParams = AddParams
69
69
-- library/executable/test-suite you want to
70
70
-- add the package to. May be a realtive oir
71
71
-- absolute path, thus, must be normalised.
72
- , packageParam :: T. Text -- ^ The name of the package to add.
72
+ , packageParam :: Package -- ^ The name of the package to add.
73
73
}
74
74
deriving (Eq , Show , Read , Generic , ToJSON , FromJSON )
75
75
@@ -296,7 +296,7 @@ codeActionProvider plId docId _ context = do
296
296
concatPkgs = concatMap (\ (d, ts) -> map (d,) ts)
297
297
298
298
-- | Create the Add Package Action with the given diagnostics and the found package name.
299
- mkAddPackageAction :: Maybe FilePath -> J. Diagnostic -> T. Text -> IdeM (Maybe J. CodeAction )
299
+ mkAddPackageAction :: Maybe FilePath -> J. Diagnostic -> Package -> IdeM (Maybe J. CodeAction )
300
300
mkAddPackageAction mRootDir diag pkgName = case (mRootDir, J. uriToFilePath (docId ^. J. uri)) of
301
301
(Just rootDir, Just docFp) -> do
302
302
let title = " Add " <> pkgName <> " as a dependency"
@@ -305,12 +305,12 @@ codeActionProvider plId docId _ context = do
305
305
return $ Just (J. CodeAction title (Just J. CodeActionQuickFix ) (Just (J. List [diag])) Nothing (Just cmd))
306
306
_ -> return Nothing
307
307
308
- getAddablePackages :: J. Diagnostic -> Maybe (J. Diagnostic , T. Text )
308
+ getAddablePackages :: J. Diagnostic -> Maybe (J. Diagnostic , Package )
309
309
getAddablePackages diag@ (J. Diagnostic _ _ _ (Just " ghcmod" ) msg _) = (diag,) <$> extractModuleName msg
310
310
getAddablePackages _ = Nothing
311
311
312
312
-- | Extract a module name from an error message.
313
- extractModuleName :: T. Text -> Maybe T. Text
313
+ extractModuleName :: T. Text -> Maybe Package
314
314
extractModuleName msg
315
315
| T. isPrefixOf " Could not find module " msg = Just $ T. tail $ T. init nameAndQuotes
316
316
| T. isPrefixOf " Could not load module " msg = Just $ T. tail $ T. init nameAndQuotes
0 commit comments