Skip to content

Instantly share code, notes, and snippets.

@DavidPiper94
Last active April 9, 2020 05:28
Show Gist options
  • Select an option

  • Save DavidPiper94/d830d59cf2c1f365d190f40966d5a36d to your computer and use it in GitHub Desktop.

Select an option

Save DavidPiper94/d830d59cf2c1f365d190f40966d5a36d to your computer and use it in GitHub Desktop.
Example code for article about SourceKitten - SyntaxStructure
struct SyntaxStructure: Codable {
// 1
let accessibility: String?
let attribute: String?
let attributes: [SyntaxStructure]?
let bodylength: Int?
let bodyoffset: Int?
let diagnosticstage: String?
let elements: [SyntaxStructure]?
let inheritedTypes: [SyntaxStructure]?
let kind: String?
let length: Int?
let name: String?
let namelength: Int?
let nameoffset: Int?
let offset: Int?
let runtimename: String?
let substructure: [SyntaxStructure]?
let typename: String?
// 2
enum CodingKeys: String, CodingKey {
case accessibility = "key.accessibility"
case attribute = "key.attribute"
case attributes = "key.attributes"
case bodylength = "key.bodylength"
case bodyoffset = "key.bodyoffset"
case diagnosticstage = "key.diagnostic_stage"
case elements = "key.elements"
case inheritedTypes = "key.inheritedtypes"
case kind = "key.kind"
case length = "key.length"
case name = "key.name"
case namelength = "key.namelength"
case nameoffset = "key.nameoffset"
case offset = "key.offset"
case runtimename = "key.runtime_name"
case substructure = "key.substructure"
case typename = "key.typename"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment