Skip to content

Commit 73af860

Browse files
committed
Update inlayHintProvider registration
The LSP API allows a boolean here: ``` /** * The server provides inlay hints. * * @SInCE 3.17.0 */ inlayHintProvider?: boolean | InlayHintOptions | InlayHintRegistrationOptions; ``` Update our server capabilities to allow this. Resolves rdar://102913088.
1 parent c31dff2 commit 73af860

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

Sources/LanguageServerProtocol/SupportTypes/ServerCapabilities.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public struct ServerCapabilities: Codable, Hashable {
106106
public var semanticTokensProvider: SemanticTokensOptions?
107107

108108
/// Whether the server supports the `textDocument/inlayHint` family of requests.
109-
public var inlayHintProvider: InlayHintOptions?
109+
public var inlayHintProvider: ValueOrBool<InlayHintOptions>?
110110

111111
/// Whether the server provides selection range support.
112112
public var selectionRangeProvider: ValueOrBool<TextDocumentAndStaticRegistrationOptions>?
@@ -151,7 +151,7 @@ public struct ServerCapabilities: Codable, Hashable {
151151
callHierarchyProvider: ValueOrBool<TextDocumentAndStaticRegistrationOptions>? = nil,
152152
typeHierarchyProvider: ValueOrBool<TextDocumentAndStaticRegistrationOptions>? = nil,
153153
semanticTokensProvider: SemanticTokensOptions? = nil,
154-
inlayHintProvider: InlayHintOptions? = nil,
154+
inlayHintProvider: ValueOrBool<InlayHintOptions>? = nil,
155155
selectionRangeProvider: ValueOrBool<TextDocumentAndStaticRegistrationOptions>? = nil,
156156
linkedEditingRangeProvider: ValueOrBool<TextDocumentAndStaticRegistrationOptions>? = nil,
157157
monikerProvider: ValueOrBool<MonikerOptions>? = nil,

Sources/SourceKitLSP/SourceKitServer.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,16 @@ extension SourceKitServer {
696696
self.dynamicallyRegisterCapability($0, registry)
697697
}
698698
}
699-
if let inlayHintOptions = server.inlayHintProvider {
700-
registry.registerInlayHintIfNeeded(options: inlayHintOptions, for: languages) {
699+
if let inlayHintProvider = server.inlayHintProvider,
700+
inlayHintProvider.isSupported {
701+
let options: InlayHintOptions
702+
switch inlayHintProvider {
703+
case .bool(_):
704+
options = InlayHintOptions()
705+
case .value(let opts):
706+
options = opts
707+
}
708+
registry.registerInlayHintIfNeeded(options: options, for: languages) {
701709
self.dynamicallyRegisterCapability($0, registry)
702710
}
703711
}

Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ extension SwiftLanguageServer {
369369
tokenModifiers: SyntaxHighlightingToken.Modifiers.allModifiers.map { $0.lspName! }),
370370
range: .bool(true),
371371
full: .bool(true)),
372-
inlayHintProvider: InlayHintOptions(
373-
resolveProvider: false)
372+
inlayHintProvider: .value(InlayHintOptions(
373+
resolveProvider: false))
374374
))
375375
}
376376

0 commit comments

Comments
 (0)