Skip to content

Commit 6a950f1

Browse files
committed
Add cabal-add source repository
We need to depend on a newer commit of cabal-add since the newest release does not yet allow us to add modules to a cabal-file. Once there is a new release of cabal-add we can revert this commit.
1 parent 242f2af commit 6a950f1

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

cabal.project

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ packages:
66
./ghcide
77
./hls-plugin-api
88
./hls-test-utils
9-
../cabal-add
109

11-
12-
index-state: 2025-06-07T14:57:40Z
10+
index-state: 2025-06-17T00:00:00Z
1311

1412
tests: True
1513
test-show-details: direct

haskell-language-server.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ library hls-cabal-plugin
288288
, transformers
289289
, unordered-containers >=0.2.10.0
290290
, containers
291-
, cabal-add
291+
, cabal-add ^>=0.2
292292
, aeson
293293
, Cabal
294294
, pretty

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/CabalAdd/Command.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ getModuleEdit recorder env cabalFilePath stanza targetFieldStr modulePath =
9999
cabalFilePath
100100
mkConfig
101101
where
102-
mkConfig :: (ByteString -> [Field Position] -> GenericPackageDescription -> ExceptT PluginError m Config)
102+
mkConfig :: (ByteString -> [Field Position] -> GenericPackageDescription -> ExceptT PluginError m AddConfig)
103103
mkConfig cnfOrigContents fields packDescr = do
104104
let compName =
105105
case Add.resolveComponent cabalFilePath (fields, packDescr) $ Just $ CabalPretty.prettyShow stanza of
106106
Right x -> x
107107
Left _ -> error ""
108108
pure $
109-
Config
109+
AddConfig
110110
{ cnfOrigContents = cnfOrigContents
111111
, cnfFields = fields
112112
, cnfComponent = compName
@@ -149,7 +149,7 @@ getDependencyEdit ::
149149
getDependencyEdit recorder env cabalFilePath buildTarget dependency =
150150
mkCabalAddConfig recorder env cabalFilePath mkConfig
151151
where
152-
mkConfig :: (ByteString -> [Field Position] -> GenericPackageDescription -> ExceptT PluginError m Config)
152+
mkConfig :: (ByteString -> [Field Position] -> GenericPackageDescription -> ExceptT PluginError m AddConfig)
153153
mkConfig cnfOrigContents fields packDescr = do
154154
let specVer = specVersion $ packageDescription packDescr
155155
(deps, compName) <-
@@ -158,7 +158,7 @@ getDependencyEdit recorder env cabalFilePath buildTarget dependency =
158158
compName <- resolveComponent cabalFilePath (fields, packDescr) buildTarget
159159
pure (deps, compName)
160160
pure $
161-
Config
161+
AddConfig
162162
{ cnfOrigContents = cnfOrigContents
163163
, cnfFields = fields
164164
, cnfComponent = compName
@@ -180,7 +180,7 @@ mkCabalAddConfig ::
180180
( ByteString ->
181181
[Field Position] ->
182182
GenericPackageDescription ->
183-
ExceptT PluginError m Config
183+
ExceptT PluginError m AddConfig
184184
) ->
185185
ExceptT PluginError m WorkspaceEdit
186186
mkCabalAddConfig recorder env cabalFilePath mkConfig = do
@@ -211,7 +211,7 @@ mkCabalAddConfig recorder env cabalFilePath mkConfig = do
211211

212212
cabalAddConfig <- mkConfig cnfOrigContents fields packDescr
213213

214-
case executeConfig (validateChanges packDescr) cabalAddConfig of
214+
case executeAddConfig (validateChanges packDescr) cabalAddConfig of
215215
Nothing ->
216216
throwE $
217217
PluginInternalError $

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/CabalAdd/Types.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ import Ide.Plugin.Cabal.Orphans ()
1919
import Language.LSP.Protocol.Types
2020

2121
data Log
22-
= LogFoundResponsibleCabalFile FilePath
23-
| LogCalledCabalAddPackageCommand CabalAddPackageCommandParams
22+
= LogCalledCabalAddPackageCommand CabalAddPackageCommandParams
2423
| LogCalledCabalAddModuleCommand ModuleInsertionConfig
2524
| LogCreatedEdit WorkspaceEdit
2625
| LogExecutedCommand
2726
deriving (Show)
2827

2928
instance Pretty Log where
3029
pretty = \case
31-
LogFoundResponsibleCabalFile fp -> "Located the responsible cabal file at " <+> pretty fp
3230
LogCalledCabalAddPackageCommand params -> "Called CabalAddPackage command with:\n" <+> pretty params
3331
LogCalledCabalAddModuleCommand params -> "Called CabalAddModule command with:\n" <+> pretty params
3432
LogCreatedEdit edit -> "Created inplace edit:\n" <+> pretty edit

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Rules.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ data Log
3535
= LogModificationTime NormalizedFilePath FileVersion
3636
| LogShake Shake.Log
3737
| LogOfInterest OfInterest.Log
38-
| LogDocSaved Uri
3938
deriving (Show)
4039

4140
instance Pretty Log where
@@ -44,8 +43,6 @@ instance Pretty Log where
4443
LogOfInterest log' -> pretty log'
4544
LogModificationTime nfp modTime ->
4645
"Modified:" <+> pretty (fromNormalizedFilePath nfp) <+> pretty (show modTime)
47-
LogDocSaved uri ->
48-
"Saved text document:" <+> pretty (getUri uri)
4946

5047
cabalRules :: Recorder (WithPriority Log) -> PluginId -> Rules ()
5148
cabalRules recorder plId = do

0 commit comments

Comments
 (0)