@@ -66,3 +66,58 @@ public struct InlayHintKind: RawRepresentable, Codable, Hashable {
6666 /// Swift, since Swift already has explicit parameter labels.
6767 public static let parameter : InlayHintKind = InlayHintKind ( rawValue: 2 )
6868}
69+
70+ /// A hint's label, either being a single string or a composition of parts.
71+ public enum InlayHintLabel : Codable , Hashable {
72+ case parts( [ InlayHintLabelPart ] )
73+ case string( String )
74+
75+ public init ( from decoder: Decoder ) throws {
76+ if let parts = try ? [ InlayHintLabelPart] ( from: decoder) {
77+ self = . parts( parts)
78+ } else if let string = try ? String ( from: decoder) {
79+ self = . string( string)
80+ } else {
81+ let context = DecodingError . Context ( codingPath: decoder. codingPath, debugDescription: " Expected [InlayHintLabelPart] or String " )
82+ throw DecodingError . dataCorrupted ( context)
83+ }
84+ }
85+
86+ public func encode( to encoder: Encoder ) throws {
87+ switch self {
88+ case let . parts( parts) :
89+ try parts. encode ( to: encoder)
90+ case let . string( string) :
91+ try string. encode ( to: encoder)
92+ }
93+ }
94+ }
95+
96+ /// A part of an interactive or composite inlay hint label.
97+ public struct InlayHintLabelPart : Codable , Hashable {
98+ /// The value of this label part.
99+ public let value : String
100+
101+ /// The tooltip to show when the part is hovered.
102+ public let tooltip : MarkupContent ?
103+
104+ /// An optional source code location representing this part.
105+ /// Used by the editor for hover and code navigation, e.g.
106+ /// by making the part a clickable link to the given position.
107+ public let location : Location ?
108+
109+ /// An optional command for this label part.
110+ public let command : Command ?
111+
112+ public init (
113+ value: String ,
114+ tooltip: MarkupContent ? = nil ,
115+ location: Location ? = nil ,
116+ command: Command ? = nil
117+ ) {
118+ self . value = value
119+ self . tooltip = tooltip
120+ self . location = location
121+ self . command = command
122+ }
123+ }
0 commit comments