Skip to content

Commit 4df66fc

Browse files
committed
imports
1 parent 217aeb0 commit 4df66fc

File tree

1 file changed

+20
-20
lines changed
  • plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal

1 file changed

+20
-20
lines changed

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ import Distribution.PackageDescription (GenericPackageDe
4242
specVersion)
4343
import Distribution.PackageDescription.Configuration (flattenPackageDescription)
4444
import Distribution.PackageDescription.Quirks (patchQuirks)
45-
import Distribution.Pretty (pretty)
45+
import qualified Distribution.Pretty as Pretty
4646
import Distribution.Simple.BuildTarget (BuildTarget,
4747
buildTargetComponentName,
4848
readBuildTargets)
4949
import Distribution.Simple.Utils (safeHead)
5050
import Distribution.Verbosity (silent,
5151
verboseNoStderr)
52-
import qualified Ide.Logger as Logger
52+
import Ide.Logger
5353
import Ide.Plugin.Cabal.Completion.Types (ParseCabalFields (..),
5454
ParseCabalFile (..))
5555
import Ide.Plugin.Cabal.Orphans ()
@@ -91,12 +91,12 @@ data Log
9191
| LogExecutedCommand
9292
deriving (Show)
9393

94-
instance Logger.Pretty Log where
94+
instance Pretty Log where
9595
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
9797
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
100100
LogExecutedCommand -> "Executed CabalAdd command"
101101

102102
cabalAddCommand :: IsString p => p
@@ -112,13 +112,13 @@ data CabalAddCommandParams =
112112
deriving (Generic, Show)
113113
deriving anyclass (FromJSON, ToJSON)
114114

115-
instance Logger.Pretty CabalAddCommandParams where
115+
instance Pretty CabalAddCommandParams where
116116
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
122122
]
123123

124124
-- | Creates a code action that calls the `cabalAddCommand`,
@@ -133,7 +133,7 @@ instance Logger.Pretty CabalAddCommandParams where
133133
-- build target, but if there will be a way to get all build targets from a file
134134
-- it will be possible to support addition to a build target of choice.
135135
addDependencySuggestCodeAction
136-
:: Logger.Recorder (Logger.WithPriority Log)
136+
:: Recorder (WithPriority Log)
137137
-> PluginId
138138
-> VersionedTextDocumentIdentifier -- ^ Cabal's versioned text identifier
139139
-> [(T.Text, T.Text)] -- ^ A dependency-version suggestion pairs
@@ -143,7 +143,7 @@ addDependencySuggestCodeAction
143143
-> IO [CodeAction]
144144
addDependencySuggestCodeAction recorder plId verTxtDocId suggestions haskellFilePath cabalFilePath gpd = do
145145
buildTargets <- liftIO $ getBuildTargets gpd cabalFilePath haskellFilePath
146-
Logger.logWith recorder Logger.Info LogCalledCabalAddCodeAction
146+
logWith recorder Info LogCalledCabalAddCodeAction
147147
case buildTargets of
148148
[] -> pure $ mkCodeAction cabalFilePath Nothing <$> suggestions
149149
targets -> pure $ concat [mkCodeAction cabalFilePath (Just $ buildTargetToStringRepr target) <$>
@@ -152,7 +152,7 @@ addDependencySuggestCodeAction recorder plId verTxtDocId suggestions haskellFile
152152
-- | Note the use of `pretty` funciton.
153153
-- It converts the `BuildTarget` to an acceptable string representation.
154154
-- 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
156156

157157
-- | Gives the build targets that are used in the `CabalAdd`.
158158
-- Note the unorthodox usage of `readBuildTargets`:
@@ -199,25 +199,25 @@ hiddenPackageSuggestion maxCompletions diag = take maxCompletions $ getMatch (ms
199199
getMatch (_, _, _, [dependency, _, cleanVersion]) = [(dependency, cleanVersion)]
200200
getMatch (_, _, _, _) = error "Impossible pattern matching case"
201201

202-
command :: Logger.Recorder (Logger.WithPriority Log) -> CommandFunction IdeState CabalAddCommandParams
202+
command :: Recorder (WithPriority Log) -> CommandFunction IdeState CabalAddCommandParams
203203
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
205205
let specifiedDep = case mbVer of
206206
Nothing -> dep
207207
Just ver -> dep <> " ^>=" <> ver
208208
caps <- lift pluginGetClientCapabilities
209209
let env = (state, caps, verTxtDocId)
210210
edit <- getDependencyEdit recorder env path target (fromList [T.unpack specifiedDep])
211211
void $ lift $ pluginSendRequest SMethod_WorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing edit) (\_ -> pure ())
212-
Logger.logWith recorder Logger.Debug LogExecutedCommand
212+
logWith recorder Debug LogExecutedCommand
213213
pure $ InR Null
214214

215215
-- | Constructs prerequisites for the @executeConfig@
216216
-- and runs it, given path to the cabal file and a dependency message.
217217
-- Given the new contents of the cabal file constructs and returns the @edit@.
218218
-- Inspired by @main@ in cabal-add,
219219
-- 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) ->
221221
FilePath -> Maybe String -> NonEmpty String -> ExceptT PluginError m WorkspaceEdit
222222
getDependencyEdit recorder env cabalFilePath buildTarget dependency = do
223223
let (state, caps, verTxtDocId) = env
@@ -260,7 +260,7 @@ getDependencyEdit recorder env cabalFilePath buildTarget dependency = do
260260
Nothing -> throwE $ PluginInternalError $ T.pack $ "Cannot extend build-depends in " ++ cabalFilePath
261261
Just newContents -> do
262262
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
264264
pure edit
265265

266266
-- | Given a path to a haskell file, returns the closest cabal file.

0 commit comments

Comments
 (0)