SKBaseSubstructure
open class SKBaseSubstructure : NSObject, SKSequence
Represents the structure of a symbol.
Depending on the request, the structure may contain syntactic and semantic information.
Subclassing
Fancy your own subclass? No problem.
final class BetterSubstructureSubclass: SKBaseSubstructure, SKFinalSubclass {
var iAmAnImportantProperty: String = "πΆββοΈ"
public override func decodeChildren(from container: DecodingContainer) throws -> [SKBaseSubstructure]? {
return try decodeChildren(BetterSubstructureSubclass.self, from: container)
}
/// The default iterator for `SKChildren` does a pre-order (NLR) depth-first search (DFS) traversal; however, if you want something else, for instance:
class FunctionSubstructureIterator<Substructure: BetterSubstructureSubclass>: SKPreOrderDFSIterator<Substructure> {
override func next() -> Substructure? {
guard let nextSubstructure = super.next()
else { return nil }
if nextSubstructure.isFunction {
return nextSubstructure
} else {
return next()
}
}
}
override class func iteratorClass<Substructure: BetterSubstructureSubclass>() -> SKPreOrderDFSIterator<Substructure>.Type {
return FunctionSubstructureIterator.self
}
}
-
Undocumented
See moreDeclaration
Swift
public enum CodingKeys : String, CodingKey
-
Undocumented
Declaration
Swift
public typealias AccessLevel = SKAccessLevel
-
Undocumented
Declaration
Swift
public typealias Attribute = SKAttribute
-
Undocumented
Declaration
Swift
public typealias DocumentationParameter = SKDocumentationParameter
-
Undocumented
Declaration
Swift
public typealias Element = SKElement
-
Undocumented
Declaration
Swift
public typealias InheritedType = SKInheritedType
-
Undocumented
Declaration
Swift
public typealias Override = SKOverride
-
Undocumented
Declaration
Swift
public typealias Kind = SKDeclarationKind
-
Undocumented
Declaration
Swift
public typealias DecodingContainer = KeyedDecodingContainer<SKBaseSubstructure.CodingKeys>
-
The access level of the substructure.
Declaration
Swift
public let accessibility: AccessLevel?
-
The XML representing how the substructure was declared.
Declaration
Swift
public let annotatedDeclaration: String?
-
The attributes of the substructure.
The attributes include prefixed keywords such as
override
.Note
The attributes are ordered by increasing byte offset (i.e. the first attribute in the source is the first element in the array).Declaration
Swift
public let attributes: SKSortedEntities<Attribute>?
-
The byte offset of the substructure’s body inside the source contents.
Declaration
Swift
public let bodyOffset: Int?
-
The byte length of the substructure’s body inside the source contents.
Declaration
Swift
public let bodyLength: Int?
-
The column where the token’s declaration begins (
Int64
).Note
Resolved bySourceKitten
for a SwiftDocs request. Mileage may vary.Declaration
Swift
public let docColumn: Int?
-
The documentation comment.
Note
Resolved bySourceKitten
for a SwiftDocs request. Mileage may vary.Declaration
Swift
public let docComment: String?
-
The declaration of documented token.
Note
Resolved bySourceKitten
for a SwiftDocs request. Mileage may vary.Declaration
Swift
public let docDeclaration: String?
-
The file where the documented token is located.
Note
Resolved bySourceKitten
for a SwiftDocs request. Mileage may vary.Declaration
Swift
public let docFile: String?
-
The XML representing the substructure and its documentation.
Only present when the substructure is documented.
Note
Resolved bySourceKitten
for a SwiftDocs request.Declaration
Swift
public let docFullAsXML: String?
-
The line where the token’s declaration begins (Int64).
Note
Resolved bySourceKitten
for a SwiftDocs request. Mileage may vary.Declaration
Swift
public let docLine: Int?
-
The name of the documented token (String).
Note
Resolved bySourceKitten
for a SwiftDocs request. Mileage may vary.Declaration
Swift
public let docName: String?
-
The parameters of the documented token.
Note
Resolved bySourceKitten
for a SwiftDocs request. Mileage will vary. Not recommended for use.Declaration
Swift
public let docParameters: [DocumentationParameter]?
-
The type of the documented token.
Note
Resolved bySourceKitten
for a SwiftDocs request. Mileage may vary.Declaration
Swift
public let docType: String?
-
The byte offset of the substructure’s documentation inside the source contents.
Declaration
Swift
public let docOffset: Int?
-
The byte length of the substructure’s documentation inside the source contents.
Declaration
Swift
public let docLength: Int?
-
The elements of the substructure.
Note
The elements are ordered by increasing byte offset (i.e. the first element in the source is the first element in the array).Declaration
Swift
public let elements: SKSortedEntities<Element>?
-
The XML representing the substructure.
Declaration
Swift
public let fullyAnnotatedDeclaration: String?
-
The inherited types of the substructure.
Only present when the response is from a
SKSwiftDocumentation
request.Declaration
Swift
public let inheritedTypes: [InheritedType]?
-
The UID for the declaration or reference kind (function, class, etc.).
Declaration
Swift
public let kind: Kind
-
The byte offset of the substructure inside the source contents.
This offset is the location of the substructure’s declarative keyword (e.g.
class
,let
,func
, etc.).Declaration
Swift
public let offset: Offset
-
The byte length of the substructure inside the source contents.
The length includes the substructure’s body, if present.
Declaration
Swift
public let length: Int
-
The display name for the substructure.
Declaration
Swift
public let name: String?
-
The byte offset of the substructure’s name inside the source contents.
Declaration
Swift
public let nameOffset: Int?
-
The byte length of the substructure’s name inside the source contents.
For a function, the name encompasses everything up to the closing parameter
)
, including the generic parameter clause<...>
.Declaration
Swift
public let nameLength: Int?
-
The parsed declaration.
Declaration
Swift
public let parsedDeclaration: String?
-
The parsed scope end (Int64).
Declaration
Swift
public let parsedScopeEnd: Int?
-
The parsed scope start (Int64).
Declaration
Swift
public let parsedScopeStart: Int?
-
The objective-c runtime name.
Declaration
Swift
public let runtimeName: String?
-
The overrides of the substructure.
Declaration
Swift
public let overrides: [Override]?
-
The setter access level.
Declaration
Swift
public let setterAccessibility: AccessLevel?
-
A string describing the type of the substructure.
Declaration
Swift
public let typeName: String?
-
The Unified Symbol Resolution (USR) for the substructure’s type.
Declaration
Swift
public let typeUSR: String?
-
The Unified Symbol Resolution (USR) for the substructure.
Declaration
Swift
public let usr: String?
-
Declaration
Swift
public var index: Int?
-
Declaration
Swift
public var filePath: String?
-
Declaration
Swift
public weak var internalParent: SKBaseSubstructure?
-
Declaration
Swift
public var internalChildren: [SKBaseSubstructure]?
-
Declaration
Swift
required public init(from decoder: Decoder) throws
-
Whether the substructure has a body (i.e.
bodyOffset
andbodyLength
are non-nil).Declaration
Swift
open lazy var hasBody: Bool { get set }
-
The byte range of the substructure (i.e.
offset
andlength
).Unlike
contentByteRange
, this range does not include the attributes.Declaration
Swift
open lazy var byteRange: NSRange { get set }
-
The byte range of the substructure’s name (i.e.
nameOffset
andnameLength
).For a function, the name byte offset encompasses everything up to the closing parameter parenthesis
)
, including the generic parameter clause<...>
.Declaration
Swift
open lazy var nameByteRange: NSRange? { get set }
-
The byte range of the substructure’s body (i.e.
bodyOffset
andbodyLength
).Declaration
Swift
open lazy var bodyByteRange: NSRange? { get set }
-
The byte range encompassing the entire substructure content, including any attributes.
Declaration
Swift
open lazy var contentByteRange: NSRange { get set }
-
Whether the substructure is a function-kind and has a return type.
Declaration
Swift
open lazy var isReturningFunction: Bool { get set }
-
Returns the return type (
typeName
) of a function-kind substructure.Declaration
Swift
open lazy var functionReturnType: String? { get set }
-
Whether the substructure is a mark delimiter, which are
TODO
,FIXME
, andMARK
.Declaration
Swift
open lazy var isMark: Bool { get set }
-
Whether the substructure is a protocol or protocol extension.
Declaration
Swift
open lazy var isProtocol: Bool { get set }
-
Whether the substructure is a class-kind.
Class-kinds are:
.class
.varClass
.extensionClass
.functionMethodClass
Declaration
Swift
open lazy var isClass: Bool { get set }
-
Whether the substructure is an extension-kind.
Extension-kinds are:
.extension
.extensionClass
.extensionEnum
.extensionStruct
.extensionProtocol
Declaration
Swift
open lazy var isExtension: Bool { get set }
-
Whether the substructure is a variable-kind.
Variable-kinds are:
.varLocal
.varInstance
.varClass
.varStatic
.varGlobal
Declaration
Swift
open lazy var isVariable: Bool { get set }
-
Whether the substructure is a function-kind.
Function-kinds are:
.functionMethodInstance
.functionMethodClass
.functionMethodStatic
.functionFree
Declaration
Swift
open lazy var isFunction: Bool { get set }
-
Whether the substructure is an overridden function.
Declaration
Swift
open lazy var isOverride: Bool { get set }
-
Whether the substructure’s parent is a protocol declaration.
Declaration
Swift
open lazy var isInsideProtocolDeclaration: Bool { get set }
-
Declaration
Swift
open class func iteratorClass<Substructure>() -> SKPreOrderDFSIterator<Substructure>.Type where Substructure : SKSequence
-
A convenience method for decoding children substructures of a specified type from a decoding container.
Throws
ADecodingError
.Declaration
Swift
public func decodeChildren<Substructure: SKBaseSubstructure>(_ type: Substructure.Type, from container: DecodingContainer) throws -> [Substructure]?
Parameters
type
The child type.
container
The decoding container.
Return Value
The children substructures decoded as a specified type.
-
Decodes the children substructures from a decoding container.
If using a
SKBaseSubstructure
subclass, override this method and return the decoded children substructures by callingdecodeChildren(_:from:)
with the respective subclass.For example:
override public func decodeChildren(from container: DecodingContainer) throws -> [SKBaseSubstructure]? { return try decodeChildren(MySubstructureSubclass.self, from: container) }
Throws
ADecodingError
.Declaration
Swift
open func decodeChildren(from container: DecodingContainer) throws -> [SKBaseSubstructure]?
Parameters
container
The decoding container.
Return Value
The children substructures decoded as a specified type.
-
Undocumented
Declaration
Swift
open override func isEqual(_ object: Any?) -> Bool