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

Remove JSON transport #1489

Merged
merged 5 commits into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 6 additions & 14 deletions app/MainHie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import Haskell.Ide.Engine.MonadFunctions
import Haskell.Ide.Engine.MonadTypes
import Haskell.Ide.Engine.Options
import Haskell.Ide.Engine.Scheduler
import Haskell.Ide.Engine.Transport.LspStdio
import Haskell.Ide.Engine.Transport.JsonStdio
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 @@ -24,14 +24,12 @@ 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
-- import Haskell.Ide.Engine.Plugin.HaRe
import Haskell.Ide.Engine.Plugin.Haddock
import Haskell.Ide.Engine.Plugin.HfaAlign
import Haskell.Ide.Engine.Plugin.Hoogle
import Haskell.Ide.Engine.Plugin.HsImport
import Haskell.Ide.Engine.Plugin.Liquid
import Haskell.Ide.Engine.Plugin.Package
Expand All @@ -50,11 +48,9 @@ plugins includeExamples = pluginDescToIdePlugins allPlugins
else basePlugins
basePlugins =
[ applyRefactDescriptor "applyrefact"
, baseDescriptor "base"
, brittanyDescriptor "brittany"
, haddockDescriptor "haddock"
-- , hareDescriptor "hare"
, hoogleDescriptor "hoogle"
, hsimportDescriptor "hsimport"
, liquidDescriptor "liquid"
, packageDescriptor "package"
Expand Down Expand Up @@ -88,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 @@ -114,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 All @@ -132,9 +128,5 @@ run opts = do
let plugins' = plugins (optExamplePlugin opts)

-- launch the dispatcher.
if optJson opts then do
scheduler <- newScheduler plugins' initOpts
jsonStdioTransport scheduler
else do
scheduler <- newScheduler plugins' initOpts
lspStdioTransport scheduler origDir plugins' (optCaptureFile opts)
scheduler <- newScheduler plugins' initOpts
server scheduler origDir plugins' (optCaptureFile opts)
13 changes: 6 additions & 7 deletions haskell-ide-engine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ flag pedantic
library
hs-source-dirs: src
exposed-modules: Haskell.Ide.Engine.Channel
Haskell.Ide.Engine.LSP.CodeActions
Haskell.Ide.Engine.LSP.Completions
Haskell.Ide.Engine.Plugin.Base
Haskell.Ide.Engine.LSP.Reactor
Haskell.Ide.Engine.CodeActions
Haskell.Ide.Engine.Completions
Haskell.Ide.Engine.Reactor
Haskell.Ide.Engine.Options
Haskell.Ide.Engine.Plugin.ApplyRefact
Haskell.Ide.Engine.Plugin.Brittany
Expand All @@ -33,7 +32,6 @@ library
-- Haskell.Ide.Engine.Plugin.HaRe
Haskell.Ide.Engine.Plugin.Haddock
Haskell.Ide.Engine.Plugin.HfaAlign
Haskell.Ide.Engine.Plugin.Hoogle
Haskell.Ide.Engine.Plugin.HsImport
Haskell.Ide.Engine.Plugin.Liquid
Haskell.Ide.Engine.Plugin.Package
Expand All @@ -42,11 +40,12 @@ library
Haskell.Ide.Engine.Plugin.Generic
Haskell.Ide.Engine.Scheduler
Haskell.Ide.Engine.Support.FromHaRe
Haskell.Ide.Engine.Support.Hoogle
Haskell.Ide.Engine.Support.Fuzzy
Haskell.Ide.Engine.Support.HieExtras
Haskell.Ide.Engine.Transport.JsonStdio
Haskell.Ide.Engine.Transport.LspStdio
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
module Haskell.Ide.Engine.LSP.CodeActions where
module Haskell.Ide.Engine.CodeActions where

import Control.Lens
import Control.Monad.Reader
import qualified Data.Aeson as J
import Data.Maybe
import Data.Foldable
import qualified GHC.Generics as G
import Haskell.Ide.Engine.LSP.Reactor
import Haskell.Ide.Engine.Reactor
import Haskell.Ide.Engine.Types
import qualified Language.Haskell.LSP.Core as Core
import qualified Language.Haskell.LSP.Types as J
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
module Haskell.Ide.Engine.LSP.Completions
module Haskell.Ide.Engine.Completions
( WithSnippets(..)
, getCompletions
, resolveCompletion
Expand Down Expand Up @@ -48,7 +48,7 @@ import qualified Language.Haskell.LSP.Types.Lens
as J
import qualified Haskell.Ide.Engine.Support.Fuzzy
as Fuzzy
import qualified Haskell.Ide.Engine.Plugin.Hoogle
import qualified Haskell.Ide.Engine.Support.Hoogle
as Hoogle
import qualified Language.Haskell.LSP.VFS as VFS

Expand Down Expand Up @@ -102,7 +102,7 @@ resolveCompletion :: WithSnippets -> J.CompletionItem -> IdeM J.CompletionItem
resolveCompletion withSnippets origCompl =
case fromJSON <$> origCompl ^. J.xdata of
Just (J.Success compdata) -> do
mdocs <- Hoogle.infoCmd' $ hoogleQuery compdata
mdocs <- Hoogle.info $ hoogleQuery compdata
let docText = case mdocs of
Right x -> Just x
_ -> Nothing
Expand Down
8 changes: 0 additions & 8 deletions src/Haskell/Ide/Engine/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import Options.Applicative.Simple
data GlobalOpts = GlobalOpts
{ optDebugOn :: Bool
, optLogFile :: Maybe String
, optLsp :: Bool
, optJson :: Bool
, projectRoot :: Maybe String
, optBiosVerbose :: Bool
, optCaptureFile :: Maybe FilePath
Expand All @@ -27,12 +25,6 @@ globalOptsParser = GlobalOpts
<> metavar "LOGFILE"
<> help "File to log to, defaults to stdout"
))
<*> flag True True
( long "lsp"
<> help "Enable the Language Server Protocol transport on STDIO (default)")
<*> switch
( long "json"
<> help "Enable JSON transport on STDIO")
<*> optional (strOption
( long "project-root"
<> short 'r'
Expand Down
2 changes: 1 addition & 1 deletion src/Haskell/Ide/Engine/Plugin/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import GHC
import GhcMonad
import Haskell.Ide.Engine.MonadFunctions
import Haskell.Ide.Engine.MonadTypes
import qualified Haskell.Ide.Engine.Plugin.Hoogle as Hoogle
import qualified Haskell.Ide.Engine.Support.Hoogle as Hoogle
import Haskell.Ide.Engine.PluginUtils
import Haskell.Ide.Engine.Support.HieExtras
import HscTypes
Expand Down
2 changes: 1 addition & 1 deletion src/Haskell/Ide/Engine/Plugin/HsImport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import qualified Haskell.Ide.Engine.Support.HieExtras as Hie
import qualified Language.Haskell.LSP.Types as J
import qualified Language.Haskell.LSP.Types.Lens as J
import Haskell.Ide.Engine.PluginUtils
import qualified Haskell.Ide.Engine.Plugin.Hoogle
import qualified Haskell.Ide.Engine.Support.Hoogle
as Hoogle
import System.Directory
import System.IO
Expand Down
23 changes: 1 addition & 22 deletions src/Haskell/Ide/Engine/Plugin/Liquid.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ liquidDescriptor plId = PluginDescriptor
{ pluginId = plId
, pluginName = "Liquid Haskell"
, pluginDesc = "Integration with Liquid Haskell"
, pluginCommands =
[ PluginCommand "sayHello" "say hello" sayHelloCmd
, PluginCommand "sayHelloTo" "say hello to the passed in param" sayHelloToCmd
]
, pluginCommands = []
, pluginCodeActionProvider = Nothing
, pluginDiagnosticProvider = Just (DiagnosticProvider
(S.singleton DiagnosticOnSave)
Expand All @@ -50,24 +47,6 @@ liquidDescriptor plId = PluginDescriptor

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

sayHelloCmd :: CommandFunc () T.Text
sayHelloCmd = CmdSync $ \_ -> return (IdeResultOk sayHello)

sayHelloToCmd :: CommandFunc T.Text T.Text
sayHelloToCmd = CmdSync $ \n -> do
r <- liftIO $ sayHelloTo n
return $ IdeResultOk r

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

sayHello :: T.Text
sayHello = "hello from ExamplePlugin2"

sayHelloTo :: T.Text -> IO T.Text
sayHelloTo n = return $ "hello " <> n <> " from ExamplePlugin2"

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

data LiquidJson
= LJ
{ status :: T.Text
Expand Down
2 changes: 1 addition & 1 deletion src/Haskell/Ide/Engine/Plugin/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module Haskell.Ide.Engine.Plugin.Package where

import Haskell.Ide.Engine.MonadTypes
import qualified Haskell.Ide.Engine.Plugin.Hoogle as Hoogle
import qualified Haskell.Ide.Engine.Support.Hoogle as Hoogle
import Haskell.Ide.Engine.PluginUtils
import Haskell.Ide.Engine.Support.HieExtras as Hie
import GHC.Generics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
module Haskell.Ide.Engine.LSP.Reactor
module Haskell.Ide.Engine.Reactor
( R
, runReactor
, reactorSend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PartialTypeSignatures #-}

module Haskell.Ide.Engine.Transport.LspStdio
module Haskell.Ide.Engine.Server
(
lspStdioTransport
server
) where

import Control.Concurrent
Expand Down Expand Up @@ -41,20 +41,20 @@ import qualified Data.Yaml as Yaml
import Haskell.Ide.Engine.Cradle (findLocalCradle, cradleDisplay)
import Haskell.Ide.Engine.Config
import qualified Haskell.Ide.Engine.Ghc as HIE
import Haskell.Ide.Engine.LSP.CodeActions
import qualified Haskell.Ide.Engine.LSP.Completions as Completions
import Haskell.Ide.Engine.LSP.Reactor
import Haskell.Ide.Engine.CodeActions
import qualified Haskell.Ide.Engine.Completions as Completions
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.Plugin.Hoogle as Hoogle
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 All @@ -76,13 +76,13 @@ import GHC.Conc
{-# ANN module ("hlint: ignore Use tuple-section" :: String) #-}
-- ---------------------------------------------------------------------

lspStdioTransport
server
:: Scheduler.Scheduler R
-> FilePath
-> IdePlugins
-> Maybe FilePath
-> IO ()
lspStdioTransport scheduler origDir plugins captureFp = do
server scheduler origDir plugins captureFp = do
run scheduler origDir plugins captureFp >>= \case
0 -> exitSuccess
c -> exitWith . ExitFailure $ c
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
Loading