Skip to content

Commit 70fceec

Browse files
authored
Merge pull request #513 from haskell/mpj/pretty-lsp
Add Pretty instances for LSP types
2 parents a81ea6d + a383354 commit 70fceec

File tree

381 files changed

+1217
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+1217
-19
lines changed

lsp-types/ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Revision history for lsp-types
22

3+
## Unreleased
4+
5+
- Add `Language.LSP.Protocol.Utils.Misc.prettyJSON :: Value -> Doc ann` for prettyprinting JSON,
6+
and `ViaJSON` as a deriving-via newtype wrapper for it.
7+
- Generate `Pretty` instances for all LSP types using `ViaJSON`.
8+
39
## 2.0.1.1
410

511
* Fix parsing of notifications with missing params

lsp-types/generated/Language/LSP/Protocol/Internal/Types/AnnotatedTextEdit.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.AnnotatedTextEdit where
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson as Aeson
1214
import qualified Data.Row.Aeson as Aeson
1315
import qualified Data.Row.Hashable as Hashable
@@ -39,6 +41,7 @@ data AnnotatedTextEdit = AnnotatedTextEdit
3941
}
4042
deriving stock (Show, Eq, Ord, Generic)
4143
deriving anyclass (NFData, Hashable)
44+
deriving Pretty via (ViaJSON AnnotatedTextEdit)
4245

4346
instance Aeson.ToJSON AnnotatedTextEdit where
4447
toJSON (AnnotatedTextEdit arg0 arg1 arg2) = Aeson.object $ concat $ [["range" Aeson..= arg0]

lsp-types/generated/Language/LSP/Protocol/Internal/Types/ApplyWorkspaceEditParams.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.ApplyWorkspaceEditParams where
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson as Aeson
1214
import qualified Data.Row.Aeson as Aeson
1315
import qualified Data.Row.Hashable as Hashable
@@ -32,6 +34,7 @@ data ApplyWorkspaceEditParams = ApplyWorkspaceEditParams
3234
}
3335
deriving stock (Show, Eq, Ord, Generic)
3436
deriving anyclass (NFData, Hashable)
37+
deriving Pretty via (ViaJSON ApplyWorkspaceEditParams)
3538

3639
instance Aeson.ToJSON ApplyWorkspaceEditParams where
3740
toJSON (ApplyWorkspaceEditParams arg0 arg1) = Aeson.object $ concat $ ["label" Language.LSP.Protocol.Types.Common..=? arg0

lsp-types/generated/Language/LSP/Protocol/Internal/Types/ApplyWorkspaceEditResult.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.ApplyWorkspaceEditResult where
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson as Aeson
1214
import qualified Data.Row.Aeson as Aeson
1315
import qualified Data.Row.Hashable as Hashable
@@ -39,6 +41,7 @@ data ApplyWorkspaceEditResult = ApplyWorkspaceEditResult
3941
}
4042
deriving stock (Show, Eq, Ord, Generic)
4143
deriving anyclass (NFData, Hashable)
44+
deriving Pretty via (ViaJSON ApplyWorkspaceEditResult)
4245

4346
instance Aeson.ToJSON ApplyWorkspaceEditResult where
4447
toJSON (ApplyWorkspaceEditResult arg0 arg1 arg2) = Aeson.object $ concat $ [["applied" Aeson..= arg0]

lsp-types/generated/Language/LSP/Protocol/Internal/Types/BaseSymbolInformation.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.BaseSymbolInformation where
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson as Aeson
1214
import qualified Data.Row.Aeson as Aeson
1315
import qualified Data.Row.Hashable as Hashable
@@ -44,6 +46,7 @@ data BaseSymbolInformation = BaseSymbolInformation
4446
}
4547
deriving stock (Show, Eq, Ord, Generic)
4648
deriving anyclass (NFData, Hashable)
49+
deriving Pretty via (ViaJSON BaseSymbolInformation)
4750

4851
instance Aeson.ToJSON BaseSymbolInformation where
4952
toJSON (BaseSymbolInformation arg0 arg1 arg2 arg3) = Aeson.object $ concat $ [["name" Aeson..= arg0]

lsp-types/generated/Language/LSP/Protocol/Internal/Types/CallHierarchyClientCapabilities.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.CallHierarchyClientCapabilities wher
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson as Aeson
1214
import qualified Data.Row.Aeson as Aeson
1315
import qualified Data.Row.Hashable as Hashable
@@ -26,6 +28,7 @@ data CallHierarchyClientCapabilities = CallHierarchyClientCapabilities
2628
}
2729
deriving stock (Show, Eq, Ord, Generic)
2830
deriving anyclass (NFData, Hashable)
31+
deriving Pretty via (ViaJSON CallHierarchyClientCapabilities)
2932

3033
instance Aeson.ToJSON CallHierarchyClientCapabilities where
3134
toJSON (CallHierarchyClientCapabilities arg0) = Aeson.object $ concat $ ["dynamicRegistration" Language.LSP.Protocol.Types.Common..=? arg0]

lsp-types/generated/Language/LSP/Protocol/Internal/Types/CallHierarchyIncomingCall.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.CallHierarchyIncomingCall where
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson as Aeson
1214
import qualified Data.Row.Aeson as Aeson
1315
import qualified Data.Row.Hashable as Hashable
@@ -33,6 +35,7 @@ data CallHierarchyIncomingCall = CallHierarchyIncomingCall
3335
}
3436
deriving stock (Show, Eq, Ord, Generic)
3537
deriving anyclass (NFData, Hashable)
38+
deriving Pretty via (ViaJSON CallHierarchyIncomingCall)
3639

3740
instance Aeson.ToJSON CallHierarchyIncomingCall where
3841
toJSON (CallHierarchyIncomingCall arg0 arg1) = Aeson.object $ concat $ [["from" Aeson..= arg0]

lsp-types/generated/Language/LSP/Protocol/Internal/Types/CallHierarchyIncomingCallsParams.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.CallHierarchyIncomingCallsParams whe
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson as Aeson
1214
import qualified Data.Row.Aeson as Aeson
1315
import qualified Data.Row.Hashable as Hashable
@@ -37,6 +39,7 @@ data CallHierarchyIncomingCallsParams = CallHierarchyIncomingCallsParams
3739
}
3840
deriving stock (Show, Eq, Ord, Generic)
3941
deriving anyclass (NFData, Hashable)
42+
deriving Pretty via (ViaJSON CallHierarchyIncomingCallsParams)
4043

4144
instance Aeson.ToJSON CallHierarchyIncomingCallsParams where
4245
toJSON (CallHierarchyIncomingCallsParams arg0 arg1 arg2) = Aeson.object $ concat $ ["workDoneToken" Language.LSP.Protocol.Types.Common..=? arg0

lsp-types/generated/Language/LSP/Protocol/Internal/Types/CallHierarchyItem.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.CallHierarchyItem where
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson
1214
import qualified Data.Aeson as Aeson
1315
import qualified Data.Row.Aeson as Aeson
@@ -63,6 +65,7 @@ data CallHierarchyItem = CallHierarchyItem
6365
}
6466
deriving stock (Show, Eq, Ord, Generic)
6567
deriving anyclass (NFData, Hashable)
68+
deriving Pretty via (ViaJSON CallHierarchyItem)
6669

6770
instance Aeson.ToJSON CallHierarchyItem where
6871
toJSON (CallHierarchyItem arg0 arg1 arg2 arg3 arg4 arg5 arg6 arg7) = Aeson.object $ concat $ [["name" Aeson..= arg0]

lsp-types/generated/Language/LSP/Protocol/Internal/Types/CallHierarchyOptions.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Language.LSP.Protocol.Internal.Types.CallHierarchyOptions where
88
import Control.DeepSeq
99
import Data.Hashable
1010
import GHC.Generics
11+
import Language.LSP.Protocol.Utils.Misc
12+
import Prettyprinter
1113
import qualified Data.Aeson as Aeson
1214
import qualified Data.Row.Aeson as Aeson
1315
import qualified Data.Row.Hashable as Hashable
@@ -26,6 +28,7 @@ data CallHierarchyOptions = CallHierarchyOptions
2628
}
2729
deriving stock (Show, Eq, Ord, Generic)
2830
deriving anyclass (NFData, Hashable)
31+
deriving Pretty via (ViaJSON CallHierarchyOptions)
2932

3033
instance Aeson.ToJSON CallHierarchyOptions where
3134
toJSON (CallHierarchyOptions arg0) = Aeson.object $ concat $ ["workDoneProgress" Language.LSP.Protocol.Types.Common..=? arg0]

0 commit comments

Comments
 (0)