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 {
197197 }
198198}
199199
200- public enum IndexPathValue : Codable {
200+ public enum IndexPathValue : Codable , Equatable {
201201 case index( Int )
202202 case key( String )
203203
@@ -242,7 +242,7 @@ extension IndexPathValue: CustomStringConvertible {
242242 }
243243}
244244
245- public protocol IndexPathElement {
245+ public protocol IndexPathElement : CustomStringConvertible {
246246 var indexPathValue : IndexPathValue { get }
247247}
248248
Original file line number Diff line number Diff line change 22 * Contains a range of UTF-8 character offsets and token references that
33 * identify the region of the source from which the AST derived.
44 */
5- public struct Location {
5+ public struct Location : Equatable {
66 /**
77 * The character offset at which this Node begins.
88 */
@@ -159,6 +159,21 @@ public enum NodeResult {
159159 }
160160 return false
161161 }
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+ }
162177}
163178
164179/**
Original file line number Diff line number Diff line change 1- public enum Kind : CaseIterable {
1+ public enum Kind : String , CaseIterable {
22 case name
33 case document
44 case operationDefinition
You can’t perform that action at this time.
0 commit comments