haskell-language-server-2.12.0.0: LSP server for GHC
Safe HaskellNone
LanguageGHC2021

Ide.Plugin.Cabal.CabalAdd.CodeAction

Synopsis

Documentation

collectModuleInsertionOptions Source #

Arguments

:: forall (m :: Type -> Type). MonadIO m 
=> Recorder (WithPriority Log) 
-> PluginId 
-> VersionedTextDocumentIdentifier 
-> Diagnostic 
-> FilePath

The file path of the cabal file to insert the new module into

-> GenericPackageDescription

The generic package description of the cabal file to insert the new module into.

-> Uri

The URI of the unknown haskell file/new module to insert into the cabal file.

-> ExceptT PluginError m [CodeAction] 

Takes a path to a cabal file, a module path in exposed module syntax and the contents of the cabal file and generates all possible code actions for inserting the module into the cabal file with the given contents.

buildInfoToHsSourceDirs :: BuildInfo -> [FilePath] Source #

Takes a buildInfo of a cabal file component as defined in the generic package description, and translates it to filepaths of the component's hsSourceDirs, to be processed for adding modules to exposed-, or other-modules fields in a cabal file.

mkModuleInsertionConfig :: VersionedTextDocumentIdentifier -> FilePath -> FilePath -> StanzaItem -> [ModuleInsertionConfig] Source #

Takes the path to the cabal file to insert the module into, the module path to be inserted, and a stanza representation.

Returns a list of module insertion configs, where each config represents a possible place to insert the module.

mkRelativeModulePathM :: [FilePath] -> FilePath -> FilePath -> Maybe Text Source #

Takes a list of source subdirectories, a cabal source path and a haskell filepath and returns a path to the module in exposed module syntax. The path will be relative to one of the subdirectories, in case the module is contained within one of them.

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 and cabal file paths to create a relative path to the haskell file, which is used to get a BuildTarget.

hiddenPackageSuggestion :: 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", "")]