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

Commit 23892ca

Browse files
authored
Merge pull request #1489 from haskell/remove-json-stdio-2
Remove JSON transport
2 parents 2c0d891 + c38fff5 commit 23892ca

18 files changed

+64
-334
lines changed

app/HieWrapper.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import HIE.Bios
1313
import Haskell.Ide.Engine.MonadFunctions
1414
import Haskell.Ide.Engine.Cradle (findLocalCradle)
1515
import Haskell.Ide.Engine.Options
16-
import Haskell.Ide.Engine.Plugin.Base
16+
import Haskell.Ide.Engine.Version
1717
import qualified Language.Haskell.LSP.Core as Core
1818
import Options.Applicative.Simple
1919
import qualified Paths_haskell_ide_engine as Meta
@@ -44,7 +44,7 @@ main = do
4444
-- Parse the options and run
4545
(global, ()) <-
4646
simpleOptions
47-
version
47+
hieVersion
4848
"hie-wrapper - Launch the appropriate haskell-ide-engine for a given project"
4949
""
5050
(numericVersion <*> compiler <*> globalOptsParser)
@@ -68,7 +68,7 @@ run opts = do
6868

6969

7070
progName <- getProgName
71-
logm $ "run entered for hie-wrapper(" ++ progName ++ ") " ++ version
71+
logm $ "run entered for hie-wrapper(" ++ progName ++ ") " ++ hieVersion
7272
d <- getCurrentDirectory
7373
logm $ "Current directory:" ++ d
7474
logm $ "Operating system:" ++ os

app/MainHie.hs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import Haskell.Ide.Engine.MonadFunctions
99
import Haskell.Ide.Engine.MonadTypes
1010
import Haskell.Ide.Engine.Options
1111
import Haskell.Ide.Engine.Scheduler
12-
import Haskell.Ide.Engine.Transport.LspStdio
13-
import Haskell.Ide.Engine.Transport.JsonStdio
12+
import Haskell.Ide.Engine.Server
13+
import Haskell.Ide.Engine.Version
1414
import qualified Language.Haskell.LSP.Core as Core
1515
import Options.Applicative.Simple
1616
import qualified Paths_haskell_ide_engine as Meta
@@ -24,14 +24,12 @@ import System.IO
2424
-- plugins
2525

2626
import Haskell.Ide.Engine.Plugin.ApplyRefact
27-
import Haskell.Ide.Engine.Plugin.Base
2827
import Haskell.Ide.Engine.Plugin.Brittany
2928
import Haskell.Ide.Engine.Plugin.Example2
3029
import Haskell.Ide.Engine.Plugin.Bios
3130
-- import Haskell.Ide.Engine.Plugin.HaRe
3231
import Haskell.Ide.Engine.Plugin.Haddock
3332
import Haskell.Ide.Engine.Plugin.HfaAlign
34-
import Haskell.Ide.Engine.Plugin.Hoogle
3533
import Haskell.Ide.Engine.Plugin.HsImport
3634
import Haskell.Ide.Engine.Plugin.Liquid
3735
import Haskell.Ide.Engine.Plugin.Package
@@ -50,11 +48,9 @@ plugins includeExamples = pluginDescToIdePlugins allPlugins
5048
else basePlugins
5149
basePlugins =
5250
[ applyRefactDescriptor "applyrefact"
53-
, baseDescriptor "base"
5451
, brittanyDescriptor "brittany"
5552
, haddockDescriptor "haddock"
5653
-- , hareDescriptor "hare"
57-
, hoogleDescriptor "hoogle"
5854
, hsimportDescriptor "hsimport"
5955
, liquidDescriptor "liquid"
6056
, packageDescriptor "package"
@@ -88,7 +84,7 @@ main = do
8884
-- Parse the options and run
8985
(global, ()) <-
9086
simpleOptions
91-
version
87+
hieVersion
9288
"haskell-ide-engine - Provide a common engine to power any Haskell IDE"
9389
""
9490
(numericVersion <*> compiler <*> globalOptsParser)
@@ -114,7 +110,7 @@ run opts = do
114110
maybe (pure ()) setCurrentDirectory $ projectRoot opts
115111

116112
progName <- getProgName
117-
logm $ "Run entered for HIE(" ++ progName ++ ") " ++ version
113+
logm $ "Run entered for HIE(" ++ progName ++ ") " ++ hieVersion
118114
logm $ "Current directory:" ++ origDir
119115
args <- getArgs
120116
logm $ "args:" ++ show args
@@ -132,9 +128,5 @@ run opts = do
132128
let plugins' = plugins (optExamplePlugin opts)
133129

134130
-- launch the dispatcher.
135-
if optJson opts then do
136-
scheduler <- newScheduler plugins' initOpts
137-
jsonStdioTransport scheduler
138-
else do
139-
scheduler <- newScheduler plugins' initOpts
140-
lspStdioTransport scheduler origDir plugins' (optCaptureFile opts)
131+
scheduler <- newScheduler plugins' initOpts
132+
server scheduler origDir plugins' (optCaptureFile opts)

haskell-ide-engine.cabal

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ flag pedantic
2020
library
2121
hs-source-dirs: src
2222
exposed-modules: Haskell.Ide.Engine.Channel
23-
Haskell.Ide.Engine.LSP.CodeActions
24-
Haskell.Ide.Engine.LSP.Completions
25-
Haskell.Ide.Engine.Plugin.Base
26-
Haskell.Ide.Engine.LSP.Reactor
23+
Haskell.Ide.Engine.CodeActions
24+
Haskell.Ide.Engine.Completions
25+
Haskell.Ide.Engine.Reactor
2726
Haskell.Ide.Engine.Options
2827
Haskell.Ide.Engine.Plugin.ApplyRefact
2928
Haskell.Ide.Engine.Plugin.Brittany
@@ -33,7 +32,6 @@ library
3332
-- Haskell.Ide.Engine.Plugin.HaRe
3433
Haskell.Ide.Engine.Plugin.Haddock
3534
Haskell.Ide.Engine.Plugin.HfaAlign
36-
Haskell.Ide.Engine.Plugin.Hoogle
3735
Haskell.Ide.Engine.Plugin.HsImport
3836
Haskell.Ide.Engine.Plugin.Liquid
3937
Haskell.Ide.Engine.Plugin.Package
@@ -42,11 +40,12 @@ library
4240
Haskell.Ide.Engine.Plugin.Generic
4341
Haskell.Ide.Engine.Scheduler
4442
Haskell.Ide.Engine.Support.FromHaRe
43+
Haskell.Ide.Engine.Support.Hoogle
4544
Haskell.Ide.Engine.Support.Fuzzy
4645
Haskell.Ide.Engine.Support.HieExtras
47-
Haskell.Ide.Engine.Transport.JsonStdio
48-
Haskell.Ide.Engine.Transport.LspStdio
46+
Haskell.Ide.Engine.Server
4947
Haskell.Ide.Engine.Types
48+
Haskell.Ide.Engine.Version
5049
other-modules: Paths_haskell_ide_engine
5150
build-depends: Cabal >= 1.22
5251
, Diff

src/Haskell/Ide/Engine/LSP/CodeActions.hs renamed to src/Haskell/Ide/Engine/CodeActions.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
{-# LANGUAGE DuplicateRecordFields #-}
44
{-# LANGUAGE OverloadedStrings #-}
55
{-# LANGUAGE FlexibleContexts #-}
6-
module Haskell.Ide.Engine.LSP.CodeActions where
6+
module Haskell.Ide.Engine.CodeActions where
77

88
import Control.Lens
99
import Control.Monad.Reader
1010
import qualified Data.Aeson as J
1111
import Data.Maybe
1212
import Data.Foldable
1313
import qualified GHC.Generics as G
14-
import Haskell.Ide.Engine.LSP.Reactor
14+
import Haskell.Ide.Engine.Reactor
1515
import Haskell.Ide.Engine.Types
1616
import qualified Language.Haskell.LSP.Core as Core
1717
import qualified Language.Haskell.LSP.Types as J

src/Haskell/Ide/Engine/LSP/Completions.hs renamed to src/Haskell/Ide/Engine/Completions.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-# LANGUAGE DeriveGeneric #-}
22
{-# LANGUAGE NamedFieldPuns #-}
33
{-# LANGUAGE OverloadedStrings #-}
4-
module Haskell.Ide.Engine.LSP.Completions
4+
module Haskell.Ide.Engine.Completions
55
( WithSnippets(..)
66
, getCompletions
77
, resolveCompletion
@@ -48,7 +48,7 @@ import qualified Language.Haskell.LSP.Types.Lens
4848
as J
4949
import qualified Haskell.Ide.Engine.Support.Fuzzy
5050
as Fuzzy
51-
import qualified Haskell.Ide.Engine.Plugin.Hoogle
51+
import qualified Haskell.Ide.Engine.Support.Hoogle
5252
as Hoogle
5353
import qualified Language.Haskell.LSP.VFS as VFS
5454

@@ -102,7 +102,7 @@ resolveCompletion :: WithSnippets -> J.CompletionItem -> IdeM J.CompletionItem
102102
resolveCompletion withSnippets origCompl =
103103
case fromJSON <$> origCompl ^. J.xdata of
104104
Just (J.Success compdata) -> do
105-
mdocs <- Hoogle.infoCmd' $ hoogleQuery compdata
105+
mdocs <- Hoogle.info $ hoogleQuery compdata
106106
let docText = case mdocs of
107107
Right x -> Just x
108108
_ -> Nothing

src/Haskell/Ide/Engine/Options.hs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import Options.Applicative.Simple
66
data GlobalOpts = GlobalOpts
77
{ optDebugOn :: Bool
88
, optLogFile :: Maybe String
9-
, optLsp :: Bool
10-
, optJson :: Bool
119
, projectRoot :: Maybe String
1210
, optBiosVerbose :: Bool
1311
, optCaptureFile :: Maybe FilePath
@@ -27,12 +25,6 @@ globalOptsParser = GlobalOpts
2725
<> metavar "LOGFILE"
2826
<> help "File to log to, defaults to stdout"
2927
))
30-
<*> flag True True
31-
( long "lsp"
32-
<> help "Enable the Language Server Protocol transport on STDIO (default)")
33-
<*> switch
34-
( long "json"
35-
<> help "Enable JSON transport on STDIO")
3628
<*> optional (strOption
3729
( long "project-root"
3830
<> short 'r'

src/Haskell/Ide/Engine/Plugin/Haddock.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import GHC
1717
import GhcMonad
1818
import Haskell.Ide.Engine.MonadFunctions
1919
import Haskell.Ide.Engine.MonadTypes
20-
import qualified Haskell.Ide.Engine.Plugin.Hoogle as Hoogle
20+
import qualified Haskell.Ide.Engine.Support.Hoogle as Hoogle
2121
import Haskell.Ide.Engine.PluginUtils
2222
import Haskell.Ide.Engine.Support.HieExtras
2323
import HscTypes

src/Haskell/Ide/Engine/Plugin/HsImport.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import qualified Haskell.Ide.Engine.Support.HieExtras as Hie
2222
import qualified Language.Haskell.LSP.Types as J
2323
import qualified Language.Haskell.LSP.Types.Lens as J
2424
import Haskell.Ide.Engine.PluginUtils
25-
import qualified Haskell.Ide.Engine.Plugin.Hoogle
25+
import qualified Haskell.Ide.Engine.Support.Hoogle
2626
as Hoogle
2727
import System.Directory
2828
import System.IO

src/Haskell/Ide/Engine/Plugin/Liquid.hs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ liquidDescriptor plId = PluginDescriptor
3535
{ pluginId = plId
3636
, pluginName = "Liquid Haskell"
3737
, pluginDesc = "Integration with Liquid Haskell"
38-
, pluginCommands =
39-
[ PluginCommand "sayHello" "say hello" sayHelloCmd
40-
, PluginCommand "sayHelloTo" "say hello to the passed in param" sayHelloToCmd
41-
]
38+
, pluginCommands = []
4239
, pluginCodeActionProvider = Nothing
4340
, pluginDiagnosticProvider = Just (DiagnosticProvider
4441
(S.singleton DiagnosticOnSave)
@@ -50,24 +47,6 @@ liquidDescriptor plId = PluginDescriptor
5047

5148
-- ---------------------------------------------------------------------
5249

53-
sayHelloCmd :: CommandFunc () T.Text
54-
sayHelloCmd = CmdSync $ \_ -> return (IdeResultOk sayHello)
55-
56-
sayHelloToCmd :: CommandFunc T.Text T.Text
57-
sayHelloToCmd = CmdSync $ \n -> do
58-
r <- liftIO $ sayHelloTo n
59-
return $ IdeResultOk r
60-
61-
-- ---------------------------------------------------------------------
62-
63-
sayHello :: T.Text
64-
sayHello = "hello from ExamplePlugin2"
65-
66-
sayHelloTo :: T.Text -> IO T.Text
67-
sayHelloTo n = return $ "hello " <> n <> " from ExamplePlugin2"
68-
69-
-- ---------------------------------------------------------------------
70-
7150
data LiquidJson
7251
= LJ
7352
{ status :: T.Text

src/Haskell/Ide/Engine/Plugin/Package.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module Haskell.Ide.Engine.Plugin.Package where
88

99
import Haskell.Ide.Engine.MonadTypes
10-
import qualified Haskell.Ide.Engine.Plugin.Hoogle as Hoogle
10+
import qualified Haskell.Ide.Engine.Support.Hoogle as Hoogle
1111
import Haskell.Ide.Engine.PluginUtils
1212
import Haskell.Ide.Engine.Support.HieExtras as Hie
1313
import GHC.Generics

src/Haskell/Ide/Engine/LSP/Reactor.hs renamed to src/Haskell/Ide/Engine/Reactor.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-# LANGUAGE MultiParamTypeClasses #-}
22
{-# LANGUAGE FlexibleContexts #-}
33
{-# LANGUAGE FlexibleInstances #-}
4-
module Haskell.Ide.Engine.LSP.Reactor
4+
module Haskell.Ide.Engine.Reactor
55
( R
66
, runReactor
77
, reactorSend

src/Haskell/Ide/Engine/Transport/LspStdio.hs renamed to src/Haskell/Ide/Engine/Server.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
{-# LANGUAGE ScopedTypeVariables #-}
1111
{-# LANGUAGE PartialTypeSignatures #-}
1212

13-
module Haskell.Ide.Engine.Transport.LspStdio
13+
module Haskell.Ide.Engine.Server
1414
(
15-
lspStdioTransport
15+
server
1616
) where
1717

1818
import Control.Concurrent
@@ -41,20 +41,20 @@ import qualified Data.Yaml as Yaml
4141
import Haskell.Ide.Engine.Cradle (findLocalCradle, cradleDisplay)
4242
import Haskell.Ide.Engine.Config
4343
import qualified Haskell.Ide.Engine.Ghc as HIE
44-
import Haskell.Ide.Engine.LSP.CodeActions
45-
import qualified Haskell.Ide.Engine.LSP.Completions as Completions
46-
import Haskell.Ide.Engine.LSP.Reactor
44+
import Haskell.Ide.Engine.CodeActions
45+
import qualified Haskell.Ide.Engine.Completions as Completions
46+
import Haskell.Ide.Engine.Reactor
4747
import Haskell.Ide.Engine.MonadFunctions
4848
import Haskell.Ide.Engine.MonadTypes
4949
import qualified Haskell.Ide.Engine.Plugin.ApplyRefact as ApplyRefact
50-
import Haskell.Ide.Engine.Plugin.Base
5150
-- import qualified Haskell.Ide.Engine.Plugin.HaRe as HaRe
52-
import qualified Haskell.Ide.Engine.Plugin.Hoogle as Hoogle
51+
import qualified Haskell.Ide.Engine.Support.Hoogle as Hoogle
5352
import Haskell.Ide.Engine.PluginUtils
5453
import qualified Haskell.Ide.Engine.Scheduler as Scheduler
5554
import qualified Haskell.Ide.Engine.Support.HieExtras as Hie
5655
import Haskell.Ide.Engine.Types
5756
import qualified Haskell.Ide.Engine.Plugin.Bios as BIOS
57+
import Haskell.Ide.Engine.Version
5858
import qualified Language.Haskell.LSP.Control as CTRL
5959
import qualified Language.Haskell.LSP.Core as Core
6060
import Language.Haskell.LSP.Diagnostics
@@ -76,13 +76,13 @@ import GHC.Conc
7676
{-# ANN module ("hlint: ignore Use tuple-section" :: String) #-}
7777
-- ---------------------------------------------------------------------
7878

79-
lspStdioTransport
79+
server
8080
:: Scheduler.Scheduler R
8181
-> FilePath
8282
-> IdePlugins
8383
-> Maybe FilePath
8484
-> IO ()
85-
lspStdioTransport scheduler origDir plugins captureFp = do
85+
server scheduler origDir plugins captureFp = do
8686
run scheduler origDir plugins captureFp >>= \case
8787
0 -> exitSuccess
8888
c -> exitWith . ExitFailure $ c
@@ -395,7 +395,7 @@ reactor inp diagIn = do
395395
reactorSend $ ReqRegisterCapability $ fmServerRegisterCapabilityRequest rid registrations
396396

397397
reactorSend $ NotLogMessage $
398-
fmServerLogMessageNotification J.MtLog $ "Using hie version: " <> T.pack version
398+
fmServerLogMessageNotification J.MtLog $ "Using hie version: " <> T.pack hieVersion
399399

400400
lspRootDir <- asksLspFuncs Core.rootPath
401401
currentDir <- liftIO getCurrentDirectory

0 commit comments

Comments
 (0)