File tree Expand file tree Collapse file tree 4 files changed +834
-5
lines changed
Tests/GraphQLTests/LanguageTests Expand file tree Collapse file tree 4 files changed +834
-5
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ extension IndexPath: ExpressibleByArrayLiteral {
197
197
}
198
198
}
199
199
200
- public enum IndexPathValue : Codable {
200
+ public enum IndexPathValue : Codable , Equatable {
201
201
case index( Int )
202
202
case key( String )
203
203
@@ -242,7 +242,7 @@ extension IndexPathValue: CustomStringConvertible {
242
242
}
243
243
}
244
244
245
- public protocol IndexPathElement {
245
+ public protocol IndexPathElement : CustomStringConvertible {
246
246
var indexPathValue : IndexPathValue { get }
247
247
}
248
248
Original file line number Diff line number Diff line change 2
2
* Contains a range of UTF-8 character offsets and token references that
3
3
* identify the region of the source from which the AST derived.
4
4
*/
5
- public struct Location {
5
+ public struct Location : Equatable {
6
6
/**
7
7
* The character offset at which this Node begins.
8
8
*/
@@ -159,6 +159,21 @@ public enum NodeResult {
159
159
}
160
160
return false
161
161
}
162
+
163
+ func get( key: IndexPathElement ) -> NodeResult ? {
164
+ switch self {
165
+ case let . node( node) :
166
+ guard let key = key. keyValue else {
167
+ return nil
168
+ }
169
+ return node. get ( key: key)
170
+ case let . array( array) :
171
+ guard let key = key. indexValue else {
172
+ return nil
173
+ }
174
+ return . node( array [ key] )
175
+ }
176
+ }
162
177
}
163
178
164
179
/**
Original file line number Diff line number Diff line change 1
- public enum Kind : CaseIterable {
1
+ public enum Kind : String , CaseIterable {
2
2
case name
3
3
case document
4
4
case operationDefinition
You can’t perform that action at this time.
0 commit comments