Skip to content

Commit 8945c2c

Browse files
committed
Conform InlayHintLabel to ExpressibleByStringX protocols
1 parent d66d80d commit 8945c2c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Sources/LanguageServerProtocol/SupportTypes/InlayHint.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public struct InlayHint: ResponseType, Codable, Hashable {
1919
public let kind: InlayHintKind?
2020

2121
/// The hint's text, e.g. a printed type
22-
public let label: String
22+
public let label: InlayHintLabel
2323

2424
/// Optional text edits that are performed when accepting this inlay hint.
2525
public let textEdits: [TextEdit]?
@@ -36,7 +36,7 @@ public struct InlayHint: ResponseType, Codable, Hashable {
3636
public init(
3737
position: Position,
3838
kind: InlayHintKind? = nil,
39-
label: String,
39+
label: InlayHintLabel,
4040
textEdits: [TextEdit]? = nil,
4141
tooltip: MarkupContent? = nil,
4242
paddingLeft: Bool? = nil,
@@ -93,6 +93,18 @@ public enum InlayHintLabel: Codable, Hashable {
9393
}
9494
}
9595

96+
extension InlayHintLabel: ExpressibleByStringLiteral {
97+
public init(stringLiteral value: String) {
98+
self = .string(value)
99+
}
100+
}
101+
102+
extension InlayHintLabel: ExpressibleByStringInterpolation {
103+
public init(stringInterpolation interpolation: DefaultStringInterpolation) {
104+
self = .string(.init(stringInterpolation: interpolation))
105+
}
106+
}
107+
96108
/// A part of an interactive or composite inlay hint label.
97109
public struct InlayHintLabelPart: Codable, Hashable {
98110
/// The value of this label part.

0 commit comments

Comments
 (0)