Files
sourcekit-lsp/Sources/LanguageServerProtocol/Requests/InlayHintsRequest.swift
Fredrik Wieczerkowski 3fef5145ea Add support for inlay hints using CollectExpressionType
- Add UID for CollectExpressionType request
- Add ExpressionTypeInfo structure
- Add keys to support sourcekitd's CollectExpressionType
- Implement CollectExpressionType request
- Add SwiftLanguageServer.expressionTypeInfos
- Add InlayHint and supporting types
- Add InlayHintsRequest
- Add inlayHints handler stub
- Implement inlay hints request
- Update InlayHint to follow the current proposal
- # This is the commit message #11:
- ...as described in the LSP proposal
- Update doc comment on InlayHintsRequest
- Map inlay hints lazily
- Fix minor style issue
- Add new files to CMakeLists.txt
- Specify commit of the current inlay hints proposal state
- Add public, memberwise initializer for InlayHintsRequest
- assert(false) if deserializing ExpressionTypeInfos fails
- Add dispatch precondition to _expressionTypeInfos
- Add InlayHintsRequest to the builtinRequests
- Factor out function for querying document symbols for URI
- Only render inlay hints after variable bindings
- Test inlay hints on empty document
- Test inlay hints for some simple bindings
- Test ranged inlay hint requests
- Make sure that inlay hints are unique per position
- Test inlay hints for fields
- Apply various PR suggestions regarding inlay hints
- Update inlay hint tests and add case with explicit type annotations
- Continue iterating if an ExpressionTypeInfo fails to deserialize
2021-06-10 16:41:54 +02:00

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 **(LSP Extension)**.
///
/// This implements the proposed `textDocument/inlayHints` 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 InlayHintsRequest: TextDocumentRequest, Hashable {
public static let method: String = "sourcekit-lsp/inlayHints"
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: [InlayHintCategory]?
public init(
textDocument: TextDocumentIdentifier,
range: Range<Position>? = nil,
only: [InlayHintCategory]? = nil
) {
self.textDocument = textDocument
self._range = CustomCodable(wrappedValue: range)
self.only = only
}
}