File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed
Sources/SourceKitLSP/Swift Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,20 @@ fileprivate final class FoldingRangeFinder: SyntaxAnyVisitor {
134
134
return . visitChildren
135
135
}
136
136
137
+ override func visit( _ node: ArrayExprSyntax ) -> SyntaxVisitorContinueKind {
138
+ return self . addFoldingRange (
139
+ start: node. leftSquare. endPositionBeforeTrailingTrivia. utf8Offset,
140
+ end: node. rightSquare. positionAfterSkippingLeadingTrivia. utf8Offset
141
+ )
142
+ }
143
+
144
+ override func visit( _ node: DictionaryExprSyntax ) -> SyntaxVisitorContinueKind {
145
+ return self . addFoldingRange (
146
+ start: node. leftSquare. endPositionBeforeTrailingTrivia. utf8Offset,
147
+ end: node. rightSquare. positionAfterSkippingLeadingTrivia. utf8Offset
148
+ )
149
+ }
150
+
137
151
override func visit( _ node: FunctionCallExprSyntax ) -> SyntaxVisitorContinueKind {
138
152
return self . addFoldingRange (
139
153
start: node. arguments. position. utf8Offset,
Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ func assertFoldingRanges(
66
66
Expected \( expectedRanges. count) ranges but got \( foldingRanges. count)
67
67
68
68
\( foldingRanges)
69
- """
69
+ """ ,
70
+ file: file,
71
+ line: line
70
72
)
71
73
return
72
74
}
@@ -258,7 +260,27 @@ final class FoldingRangeTests: XCTestCase {
258
260
)
259
261
}
260
262
261
- func testFoldCollections( ) {
262
- // let testClient
263
+ func testFoldCollections( ) async throws {
264
+ try await assertFoldingRanges (
265
+ markedSource: """
266
+ let x = [1️⃣1, 2, 32️⃣]
267
+ """ ,
268
+ expectedRanges: [
269
+ FoldingRangeSpec ( from: " 1️⃣ " , to: " 2️⃣ " )
270
+ ]
271
+ )
272
+
273
+ try await assertFoldingRanges (
274
+ markedSource: """
275
+ let x = [1️⃣
276
+ 1: " one " ,
277
+ 2: " two " ,
278
+ 3: " three "
279
+ 2️⃣]
280
+ """ ,
281
+ expectedRanges: [
282
+ FoldingRangeSpec ( from: " 1️⃣ " , to: " 2️⃣ " )
283
+ ]
284
+ )
263
285
}
264
286
}
You can’t perform that action at this time.
0 commit comments