Safe Haskell | None |
---|---|
Language | GHC2021 |
Ide.Plugin.Cabal.CabalAdd
Synopsis
- findResponsibleCabalFile :: FilePath -> IO (Maybe FilePath)
- addDependencySuggestCodeAction :: PluginId -> VersionedTextDocumentIdentifier -> [(Text, Text)] -> FilePath -> FilePath -> GenericPackageDescription -> IO [CodeAction]
- hiddenPackageSuggestion :: Diagnostic -> [(Text, Text)]
- cabalAddCommand :: IsString p => p
- command :: Recorder (WithPriority Log) -> CommandFunction IdeState CabalAddCommandParams
- data Log
Documentation
findResponsibleCabalFile :: FilePath -> IO (Maybe FilePath) Source #
Given a path to a haskell file, returns the closest cabal file. If a package.yaml is present in same directory as the .cabal file, returns nothing, because adding a dependency to a generated cabal file will break propagation of changes from package.yaml to cabal files in stack projects. If cabal file wasn't found, gives Nothing.
addDependencySuggestCodeAction Source #
Arguments
:: PluginId | |
-> VersionedTextDocumentIdentifier | Cabal's versioned text identifier |
-> [(Text, Text)] | A dependency-version suggestion pairs |
-> FilePath | Path to the haskell file (source of diagnostics) |
-> FilePath | Path to the cabal file (that will be edited) |
-> GenericPackageDescription | |
-> IO [CodeAction] |
Creates a code action that calls the cabalAddCommand
,
using dependency-version suggestion pairs as input.
Returns disabled action if no cabal files given.
Takes haskell file and cabal file paths to create a relative path
to the haskell file, which is used to get a BuildTarget
.
In current implementation the dependency is being added to the main found build target, but if there will be a way to get all build targets from a file it will be possible to support addition to a build target of choice.
Diagnostic -> [(Text, Text)] Source #
::Gives a mentioned number of (dependency, version)
pairs
found in the "hidden package" diagnostic message.
For example, if a ghc error looks like this:
"Could not load module ‘Data.List.Split’ It is a member of the hidden package ‘split-0.2.5’. Perhaps you need to add ‘split’ to the build-depends in your .cabal file."
or this if PackageImports extension is used:
"Could not find module ‘Data.List.Split’ Perhaps you meant Data.List.Split (needs flag -package-id split-0.2.5)"
It extracts mentioned package names and version numbers.
In this example, it will be [("split", "0.2.5")]
Also supports messages without a version.
"Perhaps you need to add ‘split’ to the build-depends in your .cabal file."
Will turn into [("split", "")]
cabalAddCommand :: IsString p => p Source #
command :: Recorder (WithPriority Log) -> CommandFunction IdeState CabalAddCommandParams Source #