diff --git a/Sources/SourceKitLSP/Swift/DocumentSymbols.swift b/Sources/SourceKitLSP/Swift/DocumentSymbols.swift index a95946a24..5028d55d9 100644 --- a/Sources/SourceKitLSP/Swift/DocumentSymbols.swift +++ b/Sources/SourceKitLSP/Swift/DocumentSymbols.swift @@ -170,6 +170,16 @@ fileprivate final class DocumentSymbolsFinder: SyntaxAnyVisitor { return .skipChildren } + override func visit(_ node: DeinitializerDeclSyntax) -> SyntaxVisitorContinueKind { + return record( + node: node, + name: node.deinitKeyword.text, + symbolKind: .null, + range: node.rangeWithoutTrivia, + selection: node.deinitKeyword.rangeWithoutTrivia + ) + } + override func visit(_ node: EnumCaseElementSyntax) -> SyntaxVisitorContinueKind { let rangeEnd = if let parameterClause = node.parameterClause { diff --git a/Tests/SourceKitLSPTests/DocumentSymbolTests.swift b/Tests/SourceKitLSPTests/DocumentSymbolTests.swift index 03b853f82..c6f5afc62 100644 --- a/Tests/SourceKitLSPTests/DocumentSymbolTests.swift +++ b/Tests/SourceKitLSPTests/DocumentSymbolTests.swift @@ -729,6 +729,35 @@ final class DocumentSymbolTests: XCTestCase { ] } } + + func testShowDeinit() async throws { + try await assertDocumentSymbols( + """ + 1️⃣class 2️⃣Foo3️⃣ { + 4️⃣deinit5️⃣ { + }6️⃣ + }7️⃣ + """ + ) { positions in + [ + DocumentSymbol( + name: "Foo", + kind: .class, + range: positions["1️⃣"]..