@@ -42,14 +42,14 @@ import Distribution.PackageDescription (GenericPackageDe
42
42
specVersion )
43
43
import Distribution.PackageDescription.Configuration (flattenPackageDescription )
44
44
import Distribution.PackageDescription.Quirks (patchQuirks )
45
- import Distribution.Pretty ( pretty )
45
+ import qualified Distribution.Pretty as Pretty
46
46
import Distribution.Simple.BuildTarget (BuildTarget ,
47
47
buildTargetComponentName ,
48
48
readBuildTargets )
49
49
import Distribution.Simple.Utils (safeHead )
50
50
import Distribution.Verbosity (silent ,
51
51
verboseNoStderr )
52
- import qualified Ide.Logger as Logger
52
+ import Ide. Logger
53
53
import Ide.Plugin.Cabal.Completion.Types (ParseCabalFields (.. ),
54
54
ParseCabalFile (.. ))
55
55
import Ide.Plugin.Cabal.Orphans ()
@@ -91,12 +91,12 @@ data Log
91
91
| LogExecutedCommand
92
92
deriving (Show )
93
93
94
- instance Logger. Pretty Log where
94
+ instance Pretty Log where
95
95
pretty = \ case
96
- LogFoundResponsibleCabalFile fp -> " Located the responsible cabal file at " Logger. <+> Logger. pretty fp
96
+ LogFoundResponsibleCabalFile fp -> " Located the responsible cabal file at " <+> pretty fp
97
97
LogCalledCabalAddCodeAction -> " The CabalAdd CodeAction is called"
98
- LogCalledCabalAddCommand params -> " Called CabalAdd command with:\n " Logger. <+> Logger. pretty params
99
- LogCreatedEdit edit -> " Created inplace edit:\n " Logger. <+> Logger. pretty edit
98
+ LogCalledCabalAddCommand params -> " Called CabalAdd command with:\n " <+> pretty params
99
+ LogCreatedEdit edit -> " Created inplace edit:\n " <+> pretty edit
100
100
LogExecutedCommand -> " Executed CabalAdd command"
101
101
102
102
cabalAddCommand :: IsString p => p
@@ -112,13 +112,13 @@ data CabalAddCommandParams =
112
112
deriving (Generic , Show )
113
113
deriving anyclass (FromJSON , ToJSON )
114
114
115
- instance Logger. Pretty CabalAddCommandParams where
115
+ instance Pretty CabalAddCommandParams where
116
116
pretty CabalAddCommandParams {.. } =
117
- " CabalAdd parameters:" Logger. <+> Logger. vcat
118
- [ " cabal path:" Logger. <+> Logger. pretty cabalPath
119
- , " target:" Logger. <+> Logger. pretty buildTarget
120
- , " dependendency:" Logger. <+> Logger. pretty dependency
121
- , " version:" Logger. <+> Logger. pretty version
117
+ " CabalAdd parameters:" <+> vcat
118
+ [ " cabal path:" <+> pretty cabalPath
119
+ , " target:" <+> pretty buildTarget
120
+ , " dependendency:" <+> pretty dependency
121
+ , " version:" <+> pretty version
122
122
]
123
123
124
124
-- | Creates a code action that calls the `cabalAddCommand`,
@@ -133,7 +133,7 @@ instance Logger.Pretty CabalAddCommandParams where
133
133
-- build target, but if there will be a way to get all build targets from a file
134
134
-- it will be possible to support addition to a build target of choice.
135
135
addDependencySuggestCodeAction
136
- :: Logger. Recorder (Logger. WithPriority Log )
136
+ :: Recorder (WithPriority Log )
137
137
-> PluginId
138
138
-> VersionedTextDocumentIdentifier -- ^ Cabal's versioned text identifier
139
139
-> [(T. Text , T. Text )] -- ^ A dependency-version suggestion pairs
@@ -143,7 +143,7 @@ addDependencySuggestCodeAction
143
143
-> IO [CodeAction ]
144
144
addDependencySuggestCodeAction recorder plId verTxtDocId suggestions haskellFilePath cabalFilePath gpd = do
145
145
buildTargets <- liftIO $ getBuildTargets gpd cabalFilePath haskellFilePath
146
- Logger. logWith recorder Logger. Info LogCalledCabalAddCodeAction
146
+ logWith recorder Info LogCalledCabalAddCodeAction
147
147
case buildTargets of
148
148
[] -> pure $ mkCodeAction cabalFilePath Nothing <$> suggestions
149
149
targets -> pure $ concat [mkCodeAction cabalFilePath (Just $ buildTargetToStringRepr target) <$>
@@ -152,7 +152,7 @@ addDependencySuggestCodeAction recorder plId verTxtDocId suggestions haskellFile
152
152
-- | Note the use of `pretty` funciton.
153
153
-- It converts the `BuildTarget` to an acceptable string representation.
154
154
-- It will be used in as the input for `cabal-add`'s `executeConfig`.
155
- buildTargetToStringRepr target = render $ pretty $ buildTargetComponentName target
155
+ buildTargetToStringRepr target = render $ Pretty. pretty $ buildTargetComponentName target
156
156
157
157
-- | Gives the build targets that are used in the `CabalAdd`.
158
158
-- Note the unorthodox usage of `readBuildTargets`:
@@ -199,25 +199,25 @@ hiddenPackageSuggestion maxCompletions diag = take maxCompletions $ getMatch (ms
199
199
getMatch (_, _, _, [dependency, _, cleanVersion]) = [(dependency, cleanVersion)]
200
200
getMatch (_, _, _, _) = error " Impossible pattern matching case"
201
201
202
- command :: Logger. Recorder (Logger. WithPriority Log ) -> CommandFunction IdeState CabalAddCommandParams
202
+ command :: Recorder (WithPriority Log ) -> CommandFunction IdeState CabalAddCommandParams
203
203
command recorder state _ params@ (CabalAddCommandParams {cabalPath = path, verTxtDocId = verTxtDocId, buildTarget = target, dependency = dep, version = mbVer}) = do
204
- Logger. logWith recorder Logger. Debug $ LogCalledCabalAddCommand params
204
+ logWith recorder Debug $ LogCalledCabalAddCommand params
205
205
let specifiedDep = case mbVer of
206
206
Nothing -> dep
207
207
Just ver -> dep <> " ^>=" <> ver
208
208
caps <- lift pluginGetClientCapabilities
209
209
let env = (state, caps, verTxtDocId)
210
210
edit <- getDependencyEdit recorder env path target (fromList [T. unpack specifiedDep])
211
211
void $ lift $ pluginSendRequest SMethod_WorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing edit) (\ _ -> pure () )
212
- Logger. logWith recorder Logger. Debug LogExecutedCommand
212
+ logWith recorder Debug LogExecutedCommand
213
213
pure $ InR Null
214
214
215
215
-- | Constructs prerequisites for the @executeConfig@
216
216
-- and runs it, given path to the cabal file and a dependency message.
217
217
-- Given the new contents of the cabal file constructs and returns the @edit@.
218
218
-- Inspired by @main@ in cabal-add,
219
219
-- Distribution.Client.Main
220
- getDependencyEdit :: MonadIO m => Logger. Recorder (Logger. WithPriority Log ) -> (IdeState , ClientCapabilities , VersionedTextDocumentIdentifier ) ->
220
+ getDependencyEdit :: MonadIO m => Recorder (WithPriority Log ) -> (IdeState , ClientCapabilities , VersionedTextDocumentIdentifier ) ->
221
221
FilePath -> Maybe String -> NonEmpty String -> ExceptT PluginError m WorkspaceEdit
222
222
getDependencyEdit recorder env cabalFilePath buildTarget dependency = do
223
223
let (state, caps, verTxtDocId) = env
@@ -260,7 +260,7 @@ getDependencyEdit recorder env cabalFilePath buildTarget dependency = do
260
260
Nothing -> throwE $ PluginInternalError $ T. pack $ " Cannot extend build-depends in " ++ cabalFilePath
261
261
Just newContents -> do
262
262
let edit = diffText caps (verTxtDocId, T. decodeUtf8 cnfOrigContents) (T. decodeUtf8 newContents) SkipDeletions
263
- Logger. logWith recorder Logger. Debug $ LogCreatedEdit edit
263
+ logWith recorder Debug $ LogCreatedEdit edit
264
264
pure edit
265
265
266
266
-- | Given a path to a haskell file, returns the closest cabal file.
0 commit comments