Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
Add back plugin/command names and descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukel97 committed Dec 24, 2019
1 parent 6a7c076 commit 56ed108
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 14 deletions.
7 changes: 5 additions & 2 deletions hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ instance IsString PluginId where

data PluginDescriptor =
PluginDescriptor { pluginId :: PluginId
, pluginName :: T.Text
, pluginDesc :: T.Text
, pluginCommands :: [PluginCommand]
, pluginCodeActionProvider :: Maybe CodeActionProvider
, pluginDiagnosticProvider :: Maybe DiagnosticProvider
Expand All @@ -277,7 +279,7 @@ data PluginDescriptor =
} deriving (Generic)

instance Show PluginCommand where
show (PluginCommand i _) = "PluginCommand { name = " ++ show i ++ " }"
show (PluginCommand i _ _) = "PluginCommand { name = " ++ show i ++ " }"

newtype CommandId = CommandId T.Text
deriving (Show, Read, Eq, Ord)
Expand All @@ -286,6 +288,7 @@ instance IsString CommandId where

data PluginCommand = forall a b. (FromJSON a, ToJSON b, Typeable b) =>
PluginCommand { commandId :: CommandId
, commandDesc :: T.Text
, commandFunc :: a -> IdeGhcM (IdeResult b)
}

Expand Down Expand Up @@ -317,7 +320,7 @@ runPluginCommand p com arg = do
Just PluginDescriptor { pluginCommands = xs } -> case List.find ((com ==) . commandId) xs of
Nothing -> return $ IdeResultFail $
IdeError UnknownCommand ("Command " <> com' <> " isn't defined for plugin " <> p' <> ". Legal commands are: " <> T.pack(show $ map commandId xs)) Null
Just (PluginCommand _ f) -> case fromJSON arg of
Just (PluginCommand _ _ f) -> case fromJSON arg of
Error err -> return $ IdeResultFail $
IdeError ParameterError ("error while parsing args for " <> com' <> " in plugin " <> p' <> ": " <> T.pack err) Null
Success a -> do
Expand Down
6 changes: 4 additions & 2 deletions src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ type HintTitle = T.Text
applyRefactDescriptor :: PluginId -> PluginDescriptor
applyRefactDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "ApplyRefact"
, pluginDesc = "apply-refact applies refactorings specified by the refact package. It is currently integrated into hlint to enable the automatic application of suggestions."
, pluginCommands =
[ PluginCommand "applyOne" applyOneCmd
, PluginCommand "applyAll" applyAllCmd
[ PluginCommand "applyOne" "Apply a single hint" applyOneCmd
, PluginCommand "applyAll" "Apply all hints to the file" applyAllCmd
]
, pluginCodeActionProvider = Just codeActionProvider
, pluginDiagnosticProvider = Nothing
Expand Down
2 changes: 2 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/Brittany.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import Data.Maybe (maybeToList)
brittanyDescriptor :: PluginId -> PluginDescriptor
brittanyDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "Brittany"
, pluginDesc = "Brittany is a tool to format source code."
, pluginCommands = []
, pluginCodeActionProvider = Nothing
, pluginDiagnosticProvider = Nothing
Expand Down
8 changes: 5 additions & 3 deletions src/Haskell/Ide/Engine/Plugin/Example2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import qualified Language.Haskell.LSP.Types.Lens as J
example2Descriptor :: PluginId -> PluginDescriptor
example2Descriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "Hello World"
, pluginDesc = "An example of writing an HIE plugin"
, pluginCommands =
[ PluginCommand "sayHello" sayHelloCmd
, PluginCommand "sayHelloTo" sayHelloToCmd
, PluginCommand "todo" todoCmd
[ PluginCommand "sayHello" "Say hello" sayHelloCmd
, PluginCommand "sayHelloTo" "Say hello to the passed in param" sayHelloToCmd
, PluginCommand "todo" "Add a TODO marker" todoCmd
]
, pluginCodeActionProvider = Just codeActionProvider
, pluginDiagnosticProvider
Expand Down
2 changes: 2 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/Floskell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import Haskell.Ide.Engine.PluginUtils
floskellDescriptor :: PluginId -> PluginDescriptor
floskellDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "Floskell"
, pluginDesc = "A flexible Haskell source code pretty printer."
, pluginCommands = []
, pluginCodeActionProvider = Nothing
, pluginDiagnosticProvider = Nothing
Expand Down
4 changes: 3 additions & 1 deletion src/Haskell/Ide/Engine/Plugin/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ import PprTyThing
genericDescriptor :: PluginId -> PluginDescriptor
genericDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginCommands = [PluginCommand "type" typeCmd]
, pluginName = "generic"
, pluginDesc = "Generic actions which require a typechecked module."
, pluginCommands = [PluginCommand "type" "Get the type of the expression under (LINE,COL)" typeCmd]
, pluginCodeActionProvider = Just codeActionProvider
, pluginDiagnosticProvider = Nothing
, pluginHoverProvider = Just hoverProvider
Expand Down
2 changes: 2 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import Documentation.Haddock.Types
haddockDescriptor :: PluginId -> PluginDescriptor
haddockDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "Haddock"
, pluginDesc = "Fishy documentation."
, pluginCommands = []
, pluginCodeActionProvider = Nothing
, pluginDiagnosticProvider = Nothing
Expand Down
4 changes: 3 additions & 1 deletion src/Haskell/Ide/Engine/Plugin/HfaAlign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import qualified Safe
hfaAlignDescriptor :: PluginId -> PluginDescriptor
hfaAlignDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "Align Equals"
, pluginDesc = "An example of writing an HIE plugin\nbased on http://www.haskellforall.com/2018/10/detailed-walkthrough-for-beginner.html"
, pluginCommands =
[ PluginCommand "align" alignCmd
[ PluginCommand "align" "Align = in active range" alignCmd
]
, pluginCodeActionProvider = Just codeActionProvider
, pluginDiagnosticProvider = Nothing
Expand Down
4 changes: 3 additions & 1 deletion src/Haskell/Ide/Engine/Plugin/HsImport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ import qualified Safe as S
hsimportDescriptor :: PluginId -> PluginDescriptor
hsimportDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginCommands = [PluginCommand "import" importModule]
, pluginName = "HsImport"
, pluginDesc = "A tool for extending the import list of a Haskell source file."
, pluginCommands = [PluginCommand "import" "Import a module" importModule]
, pluginCodeActionProvider = Just codeActionProvider
, pluginDiagnosticProvider = Nothing
, pluginHoverProvider = Nothing
Expand Down
2 changes: 2 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/Liquid.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import Text.Parsec.Text
liquidDescriptor :: PluginId -> PluginDescriptor
liquidDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "Liquid Haskell"
, pluginDesc = "Integration with Liquid Haskell"
, pluginCommands = []
, pluginCodeActionProvider = Nothing
, pluginDiagnosticProvider = Just (DiagnosticProvider
Expand Down
4 changes: 3 additions & 1 deletion src/Haskell/Ide/Engine/Plugin/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ import qualified Data.Yaml as Y
packageDescriptor :: PluginId -> PluginDescriptor
packageDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginCommands = [PluginCommand "add" addCmd]
, pluginName = "package"
, pluginDesc = "Tools for editing .cabal and package.yaml files."
, pluginCommands = [PluginCommand "add" "Add a packge" addCmd]
, pluginCodeActionProvider = Just codeActionProvider
, pluginDiagnosticProvider = Nothing
, pluginHoverProvider = Nothing
Expand Down
4 changes: 3 additions & 1 deletion src/Haskell/Ide/Engine/Plugin/Pragmas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import qualified Language.Haskell.LSP.Types.Lens as J
pragmasDescriptor :: PluginId -> PluginDescriptor
pragmasDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "Add Missing Pragmas"
, pluginDesc = "Provide code actions to add missing pragmas when GHC suggests this"
, pluginCommands =
[ PluginCommand "addPragma" addPragmaCmd
[ PluginCommand "addPragma" "add the given pragma" addPragmaCmd
]
, pluginCodeActionProvider = Just codeActionProvider
, pluginDiagnosticProvider = Nothing
Expand Down
6 changes: 4 additions & 2 deletions test/unit/ExtensibleStateSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ testPlugins = pluginDescToIdePlugins [testDescriptor "test"]
testDescriptor :: PluginId -> PluginDescriptor
testDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "testDescriptor"
, pluginDesc = "PluginDescriptor for testing Dispatcher"
, pluginCommands = [
PluginCommand "cmd1" cmd1
, PluginCommand "cmd2" cmd2
PluginCommand "cmd1" "description" cmd1
, PluginCommand "cmd2" "description" cmd2
]
, pluginCodeActionProvider = Nothing
, pluginDiagnosticProvider = Nothing
Expand Down

0 comments on commit 56ed108

Please sign in to comment.