Skip to content

Commit 68af33e

Browse files
committed
Show deinit in document symbols
rdar://128715297
1 parent 98718d4 commit 68af33e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Sources/SourceKitLSP/Swift/DocumentSymbols.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ fileprivate final class DocumentSymbolsFinder: SyntaxAnyVisitor {
170170
return .skipChildren
171171
}
172172

173+
override func visit(_ node: DeinitializerDeclSyntax) -> SyntaxVisitorContinueKind {
174+
return record(
175+
node: node,
176+
name: node.deinitKeyword.text,
177+
symbolKind: .null,
178+
range: node.rangeWithoutTrivia,
179+
selection: node.deinitKeyword.rangeWithoutTrivia
180+
)
181+
}
182+
173183
override func visit(_ node: EnumCaseElementSyntax) -> SyntaxVisitorContinueKind {
174184
let rangeEnd =
175185
if let parameterClause = node.parameterClause {

Tests/SourceKitLSPTests/DocumentSymbolTests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,35 @@ final class DocumentSymbolTests: XCTestCase {
729729
]
730730
}
731731
}
732+
733+
func testShowDeinit() async throws {
734+
try await assertDocumentSymbols(
735+
"""
736+
1️⃣class 2️⃣Foo3️⃣ {
737+
4️⃣deinit5️⃣ {
738+
}6️⃣
739+
}7️⃣
740+
"""
741+
) { positions in
742+
[
743+
DocumentSymbol(
744+
name: "Foo",
745+
kind: .class,
746+
range: positions["1️⃣"]..<positions["7️⃣"],
747+
selectionRange: positions["2️⃣"]..<positions["3️⃣"],
748+
children: [
749+
DocumentSymbol(
750+
name: "deinit",
751+
kind: .null,
752+
range: positions["4️⃣"]..<positions["6️⃣"],
753+
selectionRange: positions["4️⃣"]..<positions["5️⃣"],
754+
children: []
755+
)
756+
]
757+
)
758+
]
759+
}
760+
}
732761
}
733762

734763
fileprivate func assertDocumentSymbols(

0 commit comments

Comments
 (0)