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

Commit

Permalink
Remove Base plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
lukel97 committed Dec 21, 2019
1 parent d3bce65 commit aa0f0c5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 90 deletions.
6 changes: 3 additions & 3 deletions app/HieWrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import HIE.Bios
import Haskell.Ide.Engine.MonadFunctions
import Haskell.Ide.Engine.Cradle (findLocalCradle)
import Haskell.Ide.Engine.Options
import Haskell.Ide.Engine.Plugin.Base
import Haskell.Ide.Engine.Version
import qualified Language.Haskell.LSP.Core as Core
import Options.Applicative.Simple
import qualified Paths_haskell_ide_engine as Meta
Expand Down Expand Up @@ -44,7 +44,7 @@ main = do
-- Parse the options and run
(global, ()) <-
simpleOptions
version
hieVersion
"hie-wrapper - Launch the appropriate haskell-ide-engine for a given project"
""
(numericVersion <*> compiler <*> globalOptsParser)
Expand All @@ -68,7 +68,7 @@ run opts = do


progName <- getProgName
logm $ "run entered for hie-wrapper(" ++ progName ++ ") " ++ version
logm $ "run entered for hie-wrapper(" ++ progName ++ ") " ++ hieVersion
d <- getCurrentDirectory
logm $ "Current directory:" ++ d
logm $ "Operating system:" ++ os
Expand Down
7 changes: 3 additions & 4 deletions app/MainHie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Haskell.Ide.Engine.MonadTypes
import Haskell.Ide.Engine.Options
import Haskell.Ide.Engine.Scheduler
import Haskell.Ide.Engine.Server
import Haskell.Ide.Engine.Version
import qualified Language.Haskell.LSP.Core as Core
import Options.Applicative.Simple
import qualified Paths_haskell_ide_engine as Meta
Expand All @@ -23,7 +24,6 @@ import System.IO
-- plugins

import Haskell.Ide.Engine.Plugin.ApplyRefact
import Haskell.Ide.Engine.Plugin.Base
import Haskell.Ide.Engine.Plugin.Brittany
import Haskell.Ide.Engine.Plugin.Example2
import Haskell.Ide.Engine.Plugin.Bios
Expand All @@ -48,7 +48,6 @@ plugins includeExamples = pluginDescToIdePlugins allPlugins
else basePlugins
basePlugins =
[ applyRefactDescriptor "applyrefact"
, baseDescriptor "base"
, brittanyDescriptor "brittany"
, haddockDescriptor "haddock"
-- , hareDescriptor "hare"
Expand Down Expand Up @@ -85,7 +84,7 @@ main = do
-- Parse the options and run
(global, ()) <-
simpleOptions
version
hieVersion
"haskell-ide-engine - Provide a common engine to power any Haskell IDE"
""
(numericVersion <*> compiler <*> globalOptsParser)
Expand All @@ -111,7 +110,7 @@ run opts = do
maybe (pure ()) setCurrentDirectory $ projectRoot opts

progName <- getProgName
logm $ "Run entered for HIE(" ++ progName ++ ") " ++ version
logm $ "Run entered for HIE(" ++ progName ++ ") " ++ hieVersion
logm $ "Current directory:" ++ origDir
args <- getArgs
logm $ "args:" ++ show args
Expand Down
2 changes: 1 addition & 1 deletion haskell-ide-engine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ library
exposed-modules: Haskell.Ide.Engine.Channel
Haskell.Ide.Engine.CodeActions
Haskell.Ide.Engine.Completions
Haskell.Ide.Engine.Plugin.Base
Haskell.Ide.Engine.Reactor
Haskell.Ide.Engine.Options
Haskell.Ide.Engine.Plugin.ApplyRefact
Expand All @@ -46,6 +45,7 @@ library
Haskell.Ide.Engine.Support.HieExtras
Haskell.Ide.Engine.Server
Haskell.Ide.Engine.Types
Haskell.Ide.Engine.Version
other-modules: Paths_haskell_ide_engine
build-depends: Cabal >= 1.22
, Diff
Expand Down
4 changes: 2 additions & 2 deletions src/Haskell/Ide/Engine/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ import Haskell.Ide.Engine.Reactor
import Haskell.Ide.Engine.MonadFunctions
import Haskell.Ide.Engine.MonadTypes
import qualified Haskell.Ide.Engine.Plugin.ApplyRefact as ApplyRefact
import Haskell.Ide.Engine.Plugin.Base
-- import qualified Haskell.Ide.Engine.Plugin.HaRe as HaRe
import qualified Haskell.Ide.Engine.Support.Hoogle as Hoogle
import Haskell.Ide.Engine.PluginUtils
import qualified Haskell.Ide.Engine.Scheduler as Scheduler
import qualified Haskell.Ide.Engine.Support.HieExtras as Hie
import Haskell.Ide.Engine.Types
import qualified Haskell.Ide.Engine.Plugin.Bios as BIOS
import Haskell.Ide.Engine.Version
import qualified Language.Haskell.LSP.Control as CTRL
import qualified Language.Haskell.LSP.Core as Core
import Language.Haskell.LSP.Diagnostics
Expand Down Expand Up @@ -395,7 +395,7 @@ reactor inp diagIn = do
reactorSend $ ReqRegisterCapability $ fmServerRegisterCapabilityRequest rid registrations

reactorSend $ NotLogMessage $
fmServerLogMessageNotification J.MtLog $ "Using hie version: " <> T.pack version
fmServerLogMessageNotification J.MtLog $ "Using hie version: " <> T.pack hieVersion

lspRootDir <- asksLspFuncs Core.rootPath
currentDir <- liftIO getCurrentDirectory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,93 +1,26 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TemplateHaskell #-}
module Haskell.Ide.Engine.Plugin.Base where
{-# LANGUAGE CPP, TemplateHaskell, OverloadedStrings #-}
-- | Information and display strings for HIE's version
-- and the current project's version
module Haskell.Ide.Engine.Version where

import Control.Exception
import Data.Aeson
import Data.Foldable
import qualified Data.Map as Map
import Data.Maybe
import qualified Data.Text as T
import qualified Data.Versions as V
import Development.GitRev (gitCommitCount)
import Distribution.System (buildArch)
import Distribution.Text (display)
import Haskell.Ide.Engine.MonadTypes
import Options.Applicative.Simple (simpleVersion)
import Haskell.Ide.Engine.Cradle (isStackCradle)
import qualified HIE.Bios.Types as BIOS
import Options.Applicative.Simple (simpleVersion)
import qualified Paths_haskell_ide_engine as Meta

import qualified System.Log.Logger as L
import qualified Data.Text as T
import qualified Data.Versions as V
import System.Directory
import System.Info
import System.Process
import qualified System.Log.Logger as L

-- ---------------------------------------------------------------------

baseDescriptor :: PluginId -> PluginDescriptor
baseDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "HIE Base"
, pluginDesc = "Commands for HIE itself"
, pluginCommands =
[ PluginCommand "version" "return HIE version" versionCmd
, PluginCommand "plugins" "list available plugins" pluginsCmd
, PluginCommand "commands" "list available commands for a given plugin" commandsCmd
, PluginCommand "commandDetail" "list parameters required for a given command" commandDetailCmd
]
, pluginCodeActionProvider = Nothing
, pluginDiagnosticProvider = Nothing
, pluginHoverProvider = Nothing
, pluginSymbolProvider = Nothing
, pluginFormattingProvider = Nothing
}

-- ---------------------------------------------------------------------

versionCmd :: CommandFunc () T.Text
versionCmd = CmdSync $ \_ -> return $ IdeResultOk (T.pack version)

pluginsCmd :: CommandFunc () IdePlugins
pluginsCmd = CmdSync $ \_ ->
IdeResultOk <$> getPlugins

commandsCmd :: CommandFunc T.Text [CommandName]
commandsCmd = CmdSync $ \p -> do
IdePlugins plugins <- getPlugins
case Map.lookup p plugins of
Nothing -> return $ IdeResultFail $ IdeError
{ ideCode = UnknownPlugin
, ideMessage = "Can't find plugin:" <> p
, ideInfo = toJSON p
}
Just pl -> return $ IdeResultOk $ map commandName $ pluginCommands pl

commandDetailCmd :: CommandFunc (T.Text, T.Text) T.Text
commandDetailCmd = CmdSync $ \(p,command) -> do
IdePlugins plugins <- getPlugins
case Map.lookup p plugins of
Nothing -> return $ IdeResultFail $ IdeError
{ ideCode = UnknownPlugin
, ideMessage = "Can't find plugin:" <> p
, ideInfo = toJSON p
}
Just pl -> case find (\cmd -> command == commandName cmd) (pluginCommands pl) of
Nothing -> return $ IdeResultFail $ IdeError
{ ideCode = UnknownCommand
, ideMessage = "Can't find command:" <> command
, ideInfo = toJSON command
}
Just detail -> return $ IdeResultOk (commandDesc detail)

-- ---------------------------------------------------------------------

version :: String
version =
hieVersion :: String
hieVersion =
let commitCount = $gitCommitCount
in concat $ concat
[ [$(simpleVersion Meta.version)]
Expand Down
2 changes: 0 additions & 2 deletions test/dispatcher/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import System.IO
-- plugins

import Haskell.Ide.Engine.Plugin.ApplyRefact
import Haskell.Ide.Engine.Plugin.Base
import Haskell.Ide.Engine.Plugin.Example2
-- import Haskell.Ide.Engine.Plugin.HaRe
import Haskell.Ide.Engine.Plugin.Bios
Expand Down Expand Up @@ -66,7 +65,6 @@ plugins = pluginDescToIdePlugins
[applyRefactDescriptor "applyrefact"
,example2Descriptor "eg2"
,biosDescriptor "bios"
,baseDescriptor "base"
]

startServer :: IO (Scheduler IO, TChan LogVal, ThreadId)
Expand Down
2 changes: 1 addition & 1 deletion test/wrapper/HieWrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Main where

import Control.Monad.IO.Class (liftIO)
import Haskell.Ide.Engine.Cradle (findLocalCradle)
import Haskell.Ide.Engine.Plugin.Base
import Haskell.Ide.Engine.Version
import Test.Hspec
import System.Directory
import System.FilePath
Expand Down

0 comments on commit aa0f0c5

Please sign in to comment.