mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
- Use official textDocument/inlayHint request - Rename InlayHintCategory to InlayHintKind - Additionally, represent it using an Int, as in the proposed LSP API. - Add inlay hint client capabilities - Add inlay hint server capabilities - Add dynamic registration of inlay hint request - Rename InlayHintsRequest -> InlayHintRequest This is to be consistent with the request itself being named in singular in LSP and the other requests (e.g. DocumentSymbolRequest). - Forward inlay hint requests to clangd - Add colon before inlay hints - Add other properties to InlayHint - Add InlayHintLabel structures - Conform InlayHintLabel to ExpressibleByStringX protocols - Attach TextEdit to inlay hints for committing them - Add InlayHint.data - Fix InlayHintTests We need to include text edits in the expected inlay hints.
48 lines
1.7 KiB
Swift
48 lines
1.7 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// Request for inline annotations to be displayed in the editor.
|
|
///
|
|
/// This implements the proposed `textDocument/inlayHint` API from
|
|
/// https://github.com/microsoft/language-server-protocol/pull/1249 (commit: `d55733d`)
|
|
///
|
|
/// - Parameters:
|
|
/// - textDocument: The document for which to provide the inlay hints.
|
|
///
|
|
/// - Returns: InlayHints for the entire document
|
|
public struct InlayHintRequest: TextDocumentRequest, Hashable {
|
|
public static let method: String = "textDocument/inlayHint"
|
|
public typealias Response = [InlayHint]
|
|
|
|
/// The document for which to provide the inlay hints.
|
|
public var textDocument: TextDocumentIdentifier
|
|
|
|
/// The range the inlay hints are requested for. If nil,
|
|
/// hints for the entire document are requested.
|
|
@CustomCodable<PositionRange?>
|
|
public var range: Range<Position>?
|
|
|
|
/// The categories of hints that are interesting to the client
|
|
/// and should be filtered.
|
|
public var only: [InlayHintKind]?
|
|
|
|
public init(
|
|
textDocument: TextDocumentIdentifier,
|
|
range: Range<Position>? = nil,
|
|
only: [InlayHintKind]? = nil
|
|
) {
|
|
self.textDocument = textDocument
|
|
self._range = CustomCodable(wrappedValue: range)
|
|
self.only = only
|
|
}
|
|
}
|