Skip to content

Commit c639d2b

Browse files
committed
Classify deinitializers as constructors in document symbols
LSP doesn't have a destructor kind. constructor is the closest match and also what clangd for destructors.
1 parent b9c7438 commit c639d2b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/SourceKitLSP/Swift/DocumentSymbols.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ fileprivate final class DocumentSymbolsFinder: SyntaxAnyVisitor {
171171
}
172172

173173
override func visit(_ node: DeinitializerDeclSyntax) -> SyntaxVisitorContinueKind {
174+
// LSP doesn't have a destructor kind. constructor is the closest match and also what clangd for destructors.
174175
return record(
175176
node: node,
176177
name: node.deinitKeyword.text,
177-
symbolKind: .null,
178+
symbolKind: .constructor,
178179
range: node.rangeWithoutTrivia,
179180
selection: node.deinitKeyword.rangeWithoutTrivia
180181
)

Tests/SourceKitLSPTests/DocumentSymbolTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ final class DocumentSymbolTests: XCTestCase {
748748
children: [
749749
DocumentSymbol(
750750
name: "deinit",
751-
kind: .null,
751+
kind: .constructor,
752752
range: positions["4️⃣"]..<positions["6️⃣"],
753753
selectionRange: positions["4️⃣"]..<positions["5️⃣"],
754754
children: []

0 commit comments

Comments
 (0)