Skip to content

Commit

Permalink
Hide LSP ids from the users
Browse files Browse the repository at this point in the history
This changes the send function into two separate functions, where
parameters are passed instead of raw messages. That way haskell-lsp can
do the bookkeeping work of figuring out the appropriate request id, and
we can get rid of MessageFuncs since the user no longer needs to
construct messages from scratch.
  • Loading branch information
lukel97 committed May 12, 2020
1 parent 2d65114 commit bce18bc
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 426 deletions.
1 change: 0 additions & 1 deletion haskell-lsp-types/haskell-lsp-types.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ library
, Language.Haskell.LSP.Types.Capabilities
, Language.Haskell.LSP.Types.Constants
, Language.Haskell.LSP.Types.Lens
, Language.Haskell.LSP.Types.MessageFuncs
, Language.Haskell.LSP.Types.Utils
, Data.IxMap
other-modules: Language.Haskell.LSP.Types.ClientCapabilities
Expand Down
5 changes: 2 additions & 3 deletions haskell-lsp-types/src/Language/Haskell/LSP/Types/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ instance (ToJSON (MessageParams m), FromJSON (SMethod m)) => ToJSON (RequestMess
toJSON = genericToJSON lspOptions
toEncoding = genericToEncoding lspOptions

-- | A custom message data type is needed to distinguish between
-- notifications and requests, since a CustomMethod can be both!
data CustomMessage p t where
ReqMess :: RequestMessage (CustomMethod :: Method p Request) -> CustomMessage p Request
NotMess :: NotificationMessage (CustomMethod :: Method p Notification) -> CustomMessage p Notification
Expand Down Expand Up @@ -421,10 +423,7 @@ type HandlerFunc a = Either ResponseError a -> IO ()
-- () for Notifications
-- This is a callback that will be invoked when your request
-- recieves a response
-- Custom methods can either be a notification or a request, so
-- it may or may not have a response handler!
type family ResponseHandlerFunc m :: Type where
ResponseHandlerFunc CustomMethod = Maybe (HandlerFunc Value)
ResponseHandlerFunc (m :: Method p t) = BaseHandlerFunc t m

type family BaseHandlerFunc (t :: MethodType) (m :: Method p t) :: Type where
Expand Down
344 changes: 0 additions & 344 deletions haskell-lsp-types/src/Language/Haskell/LSP/Types/MessageFuncs.hs

This file was deleted.

6 changes: 3 additions & 3 deletions haskell-lsp-types/src/Language/Haskell/LSP/Types/Uri.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Control.DeepSeq
import qualified Data.Aeson as A
import Data.Binary (Binary, Get, put, get)
import Data.Hashable
import Data.List (isPrefixOf, stripPrefix)
import Data.List (stripPrefix)
#if __GLASGOW_HASKELL__ < 804
import Data.Monoid ((<>))
#endif
Expand Down Expand Up @@ -112,8 +112,8 @@ platformAdjustFromUriPath systemOS authority srcPath =
if systemOS /= windowsOS || null srcPath then srcPath
else let
firstSegment:rest = (FPP.splitDirectories . tail) srcPath -- Drop leading '/' for absolute Windows paths
drive = if FPW.isDrive firstSegment
then FPW.addTrailingPathSeparator firstSegment
drive = if FPW.isDrive firstSegment
then FPW.addTrailingPathSeparator firstSegment
else firstSegment
in FPW.joinDrive drive $ FPW.joinPath rest

Expand Down
Loading

0 comments on commit bce18bc

Please sign in to comment.