1
- {-# LANGUAGE DerivingStrategies #-}
2
- {-# LANGUAGE TypeOperators #-}
1
+ {-# LANGUAGE DerivingStrategies #-}
2
+ {-# LANGUAGE DuplicateRecordFields #-}
3
+ {-# LANGUAGE TypeOperators #-}
3
4
module Ide.TypesTests
4
5
( tests
5
6
) where
@@ -25,6 +26,7 @@ import Language.LSP.Protocol.Types (ClientCapabilities,
25
26
Range (Range ),
26
27
TextDocumentClientCapabilities (TextDocumentClientCapabilities , _definition ),
27
28
TextDocumentIdentifier (TextDocumentIdentifier ),
29
+ TypeDefinitionParams (.. ),
28
30
Uri (Uri ), filePathToUri ,
29
31
type (|? ) (.. ))
30
32
import Test.Tasty (TestTree , testGroup )
@@ -37,19 +39,26 @@ tests = testGroup "PluginTypes"
37
39
combineResponsesTests :: TestTree
38
40
combineResponsesTests = testGroup " combineResponses"
39
41
[ combineResponsesTextDocumentDefinitionTests
42
+ , combineResponsesTextDocumentTypeDefinitionTests
40
43
]
41
44
42
45
combineResponsesTextDocumentDefinitionTests :: TestTree
43
- combineResponsesTextDocumentDefinitionTests = testGroup " TextDocumentDefinition"
44
- [ testCase " merges all single location responses into one response with all locations and upgrades them into links (with link support)" $ do
46
+ combineResponsesTextDocumentDefinitionTests = testGroup " TextDocumentDefinition" $
47
+ defAndTypeDefSharedTests SMethod_TextDocumentDefinition definitionParams
48
+
49
+ combineResponsesTextDocumentTypeDefinitionTests :: TestTree
50
+ combineResponsesTextDocumentTypeDefinitionTests = testGroup " TextDocumentTypeDefinition" $
51
+ defAndTypeDefSharedTests SMethod_TextDocumentTypeDefinition typeDefinitionParams
52
+
53
+ defAndTypeDefSharedTests message params = [ testCase " merges all single location responses into one response with all locations and upgrades them into links (with link support)" $ do
45
54
let pluginResponses :: NonEmpty (Definition |? ([DefinitionLink ] |? Null ))
46
55
pluginResponses =
47
56
(InL . Definition . InL . Location testFileUri $ range1) :|
48
57
[ InL . Definition . InL . Location testFileUri $ range2
49
58
, InL . Definition . InL . Location testFileUri $ range3
50
59
]
51
60
52
- result = combineResponses SMethod_TextDocumentDefinition def supportsLinkInDefinitionCaps definitionParams pluginResponses
61
+ result = combineResponses message def supportsLinkInDefinitionCaps params pluginResponses
53
62
54
63
expectedResult :: Definition |? ([DefinitionLink ] |? Null )
55
64
expectedResult = InR . InL $
@@ -69,7 +78,7 @@ combineResponsesTextDocumentDefinitionTests = testGroup "TextDocumentDefinition"
69
78
]
70
79
]
71
80
72
- result = combineResponses SMethod_TextDocumentDefinition def supportsLinkInDefinitionCaps definitionParams pluginResponses
81
+ result = combineResponses message def supportsLinkInDefinitionCaps params pluginResponses
73
82
74
83
expectedResult :: Definition |? ([DefinitionLink ] |? Null )
75
84
expectedResult = InR . InL $
@@ -87,7 +96,7 @@ combineResponsesTextDocumentDefinitionTests = testGroup "TextDocumentDefinition"
87
96
, InL . Definition . InR $ [Location testFileUri range3]
88
97
]
89
98
90
- result = combineResponses SMethod_TextDocumentDefinition def supportsLinkInDefinitionCaps definitionParams pluginResponses
99
+ result = combineResponses message def supportsLinkInDefinitionCaps params pluginResponses
91
100
92
101
expectedResult :: Definition |? ([DefinitionLink ] |? Null )
93
102
expectedResult = InR . InL $
@@ -105,7 +114,7 @@ combineResponsesTextDocumentDefinitionTests = testGroup "TextDocumentDefinition"
105
114
, InL . Definition . InR $ [Location testFileUri range3]
106
115
]
107
116
108
- result = combineResponses SMethod_TextDocumentDefinition def supportsLinkInDefinitionCaps definitionParams pluginResponses
117
+ result = combineResponses message def supportsLinkInDefinitionCaps params pluginResponses
109
118
110
119
expectedResult :: Definition |? ([DefinitionLink ] |? Null )
111
120
expectedResult = InR . InL $
@@ -122,7 +131,7 @@ combineResponsesTextDocumentDefinitionTests = testGroup "TextDocumentDefinition"
122
131
, InR . InR $ Null
123
132
]
124
133
125
- result = combineResponses SMethod_TextDocumentDefinition def supportsLinkInDefinitionCaps definitionParams pluginResponses
134
+ result = combineResponses message def supportsLinkInDefinitionCaps params pluginResponses
126
135
127
136
expectedResult :: Definition |? ([DefinitionLink ] |? Null )
128
137
expectedResult = InR . InR $ Null
@@ -145,5 +154,13 @@ definitionParams = DefinitionParams
145
154
, _partialResultToken = Nothing
146
155
}
147
156
157
+ typeDefinitionParams :: TypeDefinitionParams
158
+ typeDefinitionParams = TypeDefinitionParams
159
+ { _textDocument = TextDocumentIdentifier testFileUri
160
+ , _position = Position 5 4
161
+ , _workDoneToken = Nothing
162
+ , _partialResultToken = Nothing
163
+ }
164
+
148
165
testFileUri :: Uri
149
166
testFileUri = filePathToUri " file://tester/Test.hs"
0 commit comments