Skip to content

Commit cab0947

Browse files
committed
Add description to CodeSuggestion
1 parent ed2e4f4 commit cab0947

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

Tool/Sources/SuggestionBasic/CodeSuggestion.swift

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,47 @@
1-
import Foundation
21
import CodableWrappers
2+
import Foundation
33

44
public struct CodeSuggestion: Codable, Equatable {
5+
public struct Description: Codable, Equatable {
6+
public enum Kind: Codable, Equatable {
7+
case warning
8+
case action
9+
}
10+
11+
public var kind: Kind
12+
public var content: String
13+
14+
public init(kind: Kind, content: String) {
15+
self.kind = kind
16+
self.content = content
17+
}
18+
}
19+
520
public init(
621
id: String,
722
text: String,
823
position: CursorPosition,
924
range: CursorRange,
25+
descriptions: [Description],
1026
middlewareComments: [String] = [],
1127
metadata: [String: String] = [:]
1228
) {
1329
self.text = text
1430
self.position = position
1531
self.id = id
1632
self.range = range
33+
self.descriptions = descriptions
1734
self.middlewareComments = middlewareComments
1835
self.metadata = metadata
1936
}
2037

2138
public static func == (lhs: CodeSuggestion, rhs: CodeSuggestion) -> Bool {
22-
return lhs.text == rhs.text
23-
&& lhs.position == rhs.position
24-
&& lhs.id == rhs.id
25-
&& lhs.range == rhs.range
39+
return lhs.text == rhs.text
40+
&& lhs.position == rhs.position
41+
&& lhs.id == rhs.id
42+
&& lhs.range == rhs.range
43+
&& lhs.descriptions == rhs.descriptions
44+
&& lhs.middlewareComments == rhs.middlewareComments
2645
}
2746

2847
/// The new code to be inserted and the original code on the first line.
@@ -33,6 +52,8 @@ public struct CodeSuggestion: Codable, Equatable {
3352
public var id: String
3453
/// The range of the original code that should be replaced.
3554
public var range: CursorRange
55+
/// Descriptions about this code suggestion
56+
@FallbackDecoding<EmptyArray> public var descriptions: [Description]
3657
/// A place to store comments inserted by middleware for debugging use.
3758
@FallbackDecoding<EmptyArray> public var middlewareComments: [String]
3859
/// A place to store extra data.

0 commit comments

Comments
 (0)