|
12 | 12 |
|
13 | 13 | /// Represents an inline annotation displayed by the editor in a source file. |
14 | 14 | public struct InlayHint: ResponseType, Codable, Hashable { |
15 | | - /// The range of the token to be annotated. |
16 | | - @CustomCodable<PositionRange> |
17 | | - public var range: Range<Position> |
18 | | - |
19 | | - /// The side of the token on which to place the hint. |
20 | | - public var side: InlayHintSide |
| 15 | + /// The position within the code that this hint is attached to. |
| 16 | + public var position: Position |
21 | 17 |
|
22 | 18 | /// The hint's kind, used for more flexible client-side styling. |
23 | | - public let kind: InlayHintKind |
| 19 | + public let category: InlayHintCategory? |
24 | 20 |
|
25 | 21 | /// The hint's text, e.g. a printed type |
26 | 22 | public let label: String |
27 | 23 |
|
28 | 24 | public init( |
29 | | - range: Range<Position>, |
30 | | - side: InlayHintSide = .after, |
31 | | - kind: InlayHintKind, |
| 25 | + position: Position, |
| 26 | + category: InlayHintCategory? = nil, |
32 | 27 | label: String |
33 | 28 | ) { |
34 | | - self.range = range |
35 | | - self.side = side |
36 | | - self.kind = kind |
| 29 | + self.position = position |
| 30 | + self.category = category |
37 | 31 | self.label = label |
38 | 32 | } |
39 | 33 | } |
40 | 34 |
|
41 | | -/// The side of a token on which to place an inlay hint. |
42 | | -public enum InlayHintSide: Int, Codable, Hashable { |
43 | | - case before = 0 |
44 | | - case after = 1 |
45 | | -} |
46 | | - |
47 | 35 | /// A hint's kind, used for more flexible client-side styling. |
48 | | -public enum InlayHintKind: Int, Codable, Hashable { |
49 | | - /// let x: Hint |
50 | | - case bindingType = 0 |
51 | | - /// { (x: Hint) in |
52 | | - case parameterType = 1 |
53 | | - /// .method(): Hint |
54 | | - case methodChainType = 2 |
| 36 | +public struct InlayHintCategory: RawRepresentable, Codable, Hashable { |
| 37 | + public var rawValue: String |
| 38 | + |
| 39 | + public init(rawValue: String) { |
| 40 | + self.rawValue = rawValue |
| 41 | + } |
| 42 | + |
| 43 | + /// A parameter label. Note that this case is not used by |
| 44 | + /// Swift, since Swift already has explicit parameter labels. |
| 45 | + public static let parameter: InlayHintCategory = InlayHintCategory(rawValue: "parameter") |
| 46 | + /// An inferred type. |
| 47 | + public static let type: InlayHintCategory = InlayHintCategory(rawValue: "type") |
55 | 48 | } |
0 commit comments