forked from haskell/lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See haskell#210 and haskell#211 Also rename Progress to ProgressAmount to avoid clashing with Progress method in haskell-lsp-types Also fix haskell#252, wrapping sendProgress notifications in bracket Also add example func-test for said bug
- Loading branch information
Showing
18 changed files
with
251 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
packages: | ||
./ | ||
./haskell-lsp-types/ | ||
./func-test/ | ||
|
||
package haskell-lsp | ||
flags: +demo | ||
|
||
|
||
source-repository-package | ||
type: git | ||
location: https://github.com/wz1000/lsp-test.git | ||
tag: 826575195f87238c46431ed70bda8f97f079ffc9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE GADTs, OverloadedStrings #-} | ||
module Main where | ||
|
||
import Data.Default | ||
import Language.Haskell.LSP.Core | ||
import Language.Haskell.LSP.Control | ||
import qualified Language.Haskell.LSP.Test as Test | ||
import Language.Haskell.LSP.Types | ||
import Language.Haskell.LSP.Types.Lens | ||
import Control.Monad.IO.Class | ||
import System.IO | ||
import Control.Concurrent | ||
import Control.Monad | ||
import System.Process | ||
import Control.Applicative.Combinators | ||
import Control.Monad.Trans.Control | ||
import Control.Lens | ||
|
||
main :: IO () | ||
main = do | ||
(hinRead, hinWrite) <- createPipe | ||
(houtRead, houtWrite) <- createPipe | ||
|
||
killVar <- newEmptyMVar | ||
|
||
forkIO $ void $ runWithHandles hinRead houtWrite initCallbacks (handlers killVar) def | ||
|
||
Test.runSessionWithHandles hinWrite houtRead Test.defaultConfig Test.fullCaps "." $ do | ||
skipManyTill Test.anyMessage $ do | ||
x <- Test.message SProgress | ||
let isBegin (Begin _) = True | ||
isBegin _ = False | ||
guard $ isBegin $ x ^. params . value | ||
liftIO $ putMVar killVar () | ||
skipManyTill Test.anyMessage $ do | ||
x <- Test.message SProgress | ||
let isEnd (End _) = True | ||
isEnd _ = False | ||
guard $ isEnd $ x ^. params . value | ||
liftIO $ putStrLn "Hello, Haskell!" | ||
|
||
initCallbacks :: InitializeCallbacks () | ||
initCallbacks = InitializeCallbacks | ||
{ onConfigurationChange = const $ pure $ Right () | ||
, onInitialization = const $ pure Nothing | ||
} | ||
|
||
handlers :: MVar () -> Handlers () | ||
handlers killVar SInitialized = Just $ \noti -> do | ||
tid <- liftBaseDiscard forkIO $ | ||
withProgress "Doing something" NotCancellable $ \updater -> | ||
liftIO $ threadDelay (1 * 1000000) | ||
liftIO $ void $ forkIO $ do | ||
takeMVar killVar | ||
killThread tid | ||
|
||
handlers _ _ = Nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cabal-version: >=1.10 | ||
name: func-test | ||
version: 0.1.0.0 | ||
build-type: Simple | ||
|
||
executable func-test | ||
main-is: FuncTest.hs | ||
build-depends: base >=4.14 && <4.15 | ||
, lsp-test | ||
, haskell-lsp | ||
, data-default | ||
, process | ||
, lens | ||
, monad-control | ||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.