var count: Int
The number of elements, present
or missing
, in this collection.
var customMirror: Mirror
var debugDescription: String
A simple description of this node (ie. its type).
var description: String
A source-accurate description of this node.
var detached: Self
Return this subtree with this node as the root, ie. detach this node from its parent.
var endIndex: SyntaxChildrenIndex
var endPosition: AbsolutePosition
The end position of this node, including its trivia.
var endPositionBeforeTrailingTrivia: AbsolutePosition
The end position of this node’s content, before any trailing trivia.
var first: Self.Element?
The first element of the collection.
var hasError: Bool
Whether the tree contained by this layout has any
var hasMaximumNestingLevelOverflow: Bool
var hasParent: Bool
Whether or not this node has a parent.
var hasSequenceExpr: Bool
Whether this tree contains a missing token or unexpected node.
var hasWarning: Bool
Whether the tree contained by this layout has any tokens with a TokenDiagnostic
of severity warning
.
var id: SyntaxIdentifier
Returns a value representing the unique identity of the node.
var indices: DefaultIndices<Self>
The indices that are valid for subscripting the collection, in ascending order.
var isEmpty: Bool
A Boolean value indicating whether the collection is empty.
var keyPathInParent: AnyKeyPath?
var kind: SyntaxKind
The kind of the syntax node, e.g. if it is a functionDecl
.
var last: Self.Element?
The last element of the collection.
var lazy: LazySequence<Self>
A sequence containing the same elements as this sequence, but on which some operations, such as map
and filter
, are implemented lazily.
var leadingTrivia: Trivia
The leading trivia of this syntax node.
var leadingTriviaLength: SourceLength
The length this node’s leading trivia takes up spelled out in source.
var parent: Syntax?
The parent of this syntax node, or nil
if this node is the root.
var position: AbsolutePosition
The absolute position of the starting point of this node. If the first token is with leading trivia, the position points to the start of the leading trivia.
var positionAfterSkippingLeadingTrivia: AbsolutePosition
The absolute position of the starting point of this node, skipping any leading trivia attached to the first token syntax.
var root: Syntax
The root of the tree in which this node resides.
var startIndex: SyntaxChildrenIndex
var syntaxNodeType: SyntaxProtocol.Type
The dynamic metatype of the concrete node.
var syntaxTextBytes: [UInt8]
Retrieve the syntax text as an array of bytes that models the input source even in the presence of invalid UTF-8.
var totalByteRange: ByteSourceRange
The byte source range of this node including leading and trailing trivia.
var totalLength: SourceLength
The length of this node including all of its trivia.
var trailingTrivia: Trivia
The trailing trivia of this syntax node.
var trailingTriviaLength: SourceLength
The length this node’s trailing trivia takes up spelled out in source.
var trimmed: Self
A copy of this node without the leading trivia of the first token in the node and the trailing trivia of the last token in the node.
var trimmedByteRange: ByteSourceRange
The byte source range of this node excluding leading and trailing trivia.
var trimmedDescription: String
The description of this node with leading whitespace of the first token and trailing whitespace of the last token removed.
var trimmedLength: SourceLength
The length this node takes up spelled out in the source, excluding its leading or trailing trivia.
var underestimatedCount: Int
A value less than or equal to the number of elements in the collection.
subscript(SyntaxChildrenIndex) -> Element
func allSatisfy((Self.Element) throws -> Bool) rethrows -> Bool
Returns a Boolean value indicating whether every element of a sequence satisfies a given predicate.
func append(Element)
Adds an element to the end of the collection.
func append(contentsOf: some Sequence<Element>)
Adds the elements of a sequence to the end of this collection.
func `as`<S>(S.Type) -> S?
Attempts to cast the current syntax node to a given specialized syntax type.
func asProtocol(MissingNodeSyntax.Protocol) -> MissingNodeSyntax?
Return the non-type erased version of this syntax node if it conforms to MissingNodeSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(ParenthesizedSyntax.Protocol) -> ParenthesizedSyntax?
Return the non-type erased version of this syntax node if it conforms to ParenthesizedSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(WithCodeBlockSyntax.Protocol) -> WithCodeBlockSyntax?
Return the non-type erased version of this syntax node if it conforms to WithCodeBlockSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(WithModifiersSyntax.Protocol) -> WithModifiersSyntax?
Return the non-type erased version of this syntax node if it conforms to WithModifiersSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(WithAttributesSyntax.Protocol) -> WithAttributesSyntax?
Return the non-type erased version of this syntax node if it conforms to WithAttributesSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(WithStatementsSyntax.Protocol) -> WithStatementsSyntax?
Return the non-type erased version of this syntax node if it conforms to WithStatementsSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(EffectSpecifiersSyntax.Protocol) -> EffectSpecifiersSyntax?
Return the non-type erased version of this syntax node if it conforms to EffectSpecifiersSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(WithTrailingCommaSyntax.Protocol) -> WithTrailingCommaSyntax?
Return the non-type erased version of this syntax node if it conforms to WithTrailingCommaSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(WithGenericParametersSyntax.Protocol) -> WithGenericParametersSyntax?
Return the non-type erased version of this syntax node if it conforms to WithGenericParametersSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(WithOptionalCodeBlockSyntax.Protocol) -> WithOptionalCodeBlockSyntax?
Return the non-type erased version of this syntax node if it conforms to WithOptionalCodeBlockSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(FreestandingMacroExpansionSyntax.Protocol) -> FreestandingMacroExpansionSyntax?
Return the non-type erased version of this syntax node if it conforms to FreestandingMacroExpansionSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(BracedSyntax.Protocol) -> BracedSyntax?
Return the non-type erased version of this syntax node if it conforms to BracedSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(DeclGroupSyntax.Protocol) -> DeclGroupSyntax?
Return the non-type erased version of this syntax node if it conforms to DeclGroupSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func asProtocol(NamedDeclSyntax.Protocol) -> NamedDeclSyntax?
Return the non-type erased version of this syntax node if it conforms to NamedDeclSyntax
. Otherwise return nil
. Note that this will incur an existential conversion.
func cast<S>(S.Type) -> S
Force-casts the current syntax node to a given specialized syntax type.
func children(viewMode: SyntaxTreeViewMode) -> SyntaxChildren
A sequence over the children of this node.
func compactMap<ElementOfResult>((Self.Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult]
Returns an array containing the non-nil
results of calling the given transformation with each element of this sequence.
func contains(Self.Element) -> Bool
Returns a Boolean value indicating whether the sequence contains the given element.
func contains(where: (Self.Element) throws -> Bool) rethrows -> Bool
Returns a Boolean value indicating whether the sequence contains an element that satisfies the given predicate.
func count<E>(where: (Self.Element) throws(E) -> Bool) throws(E) -> Int
Returns the number of elements in the sequence that satisfy the given predicate.
func debugDescription(includeTrivia: Bool, converter: SourceLocationConverter?, mark: SyntaxProtocol?, indentString: String) -> String
Returns a summarized dump of this node.
func difference<C>(from: C) -> CollectionDifference<Self.Element>
Returns the difference needed to produce this collection’s ordered elements from the given collection.
func difference<C>(from: C, by: (C.Element, Self.Element) -> Bool) -> CollectionDifference<Self.Element>
Returns the difference needed to produce this collection’s ordered elements from the given collection, using the given predicate as an equivalence test.
func distance(from: SyntaxChildrenIndex, to: SyntaxChildrenIndex) -> Int
func drop(while: (Self.Element) throws -> Bool) rethrows -> Self.SubSequence
Returns a subsequence by skipping elements while predicate
returns true
and returning the remaining elements.
func dropFirst(Int) -> Self.SubSequence
Returns a subsequence containing all but the given number of initial elements.
func dropLast(Int) -> Self.SubSequence
Returns a subsequence containing all but the specified number of final elements.
func elementsEqual<OtherSequence>(OtherSequence) -> Bool
Returns a Boolean value indicating whether this sequence and another sequence contain the same elements in the same order.
func elementsEqual<OtherSequence>(OtherSequence, by: (Self.Element, OtherSequence.Element) throws -> Bool) rethrows -> Bool
Returns a Boolean value indicating whether this sequence and another sequence contain equivalent elements in the same order, using the given predicate as the equivalence test.
func endLocation(converter: SourceLocationConverter, afterTrailingTrivia: Bool) -> SourceLocation
The ending location, in the provided file, of this Syntax node.
func enumerated() -> EnumeratedSequence<Self>
Returns a sequence of pairs (n, x), where n represents a consecutive integer starting at zero and x represents an element of the sequence.
func filter((Element) throws -> Bool) rethrows -> Self
Returns a new SyntaxCollection
that just contains the elements satisfying the given predicate.
func first(where: (Self.Element) throws -> Bool) rethrows -> Self.Element?
Returns the first element of the sequence that satisfies the given predicate.
func firstIndex(of: Self.Element) -> Self.Index?
Returns the first index where the specified value appears in the collection.
func firstIndex(where: (Self.Element) throws -> Bool) rethrows -> Self.Index?
Returns the first index in which an element of the collection satisfies the given predicate.
func firstRange<C>(of: C) -> Range<Self.Index>?
Finds and returns the range of the first occurrence of a given collection within this collection.
func firstToken(viewMode: SyntaxTreeViewMode) -> TokenSyntax?
Returns the first token node that is part of this syntax node.
func flatMap<SegmentOfResult>((Self.Element) throws -> SegmentOfResult) rethrows -> [SegmentOfResult.Element]
Returns an array containing the concatenated results of calling the given transformation with each element of this sequence.
func forEach((Self.Element) throws -> Void) rethrows
Calls the given closure on each element in the sequence in the same order as a for
-in
loop.
func formIndex(inout Self.Index, offsetBy: Int)
Offsets the given index by the specified distance.
func formIndex(inout Self.Index, offsetBy: Int, limitedBy: Self.Index) -> Bool
Offsets the given index by the specified distance, or so that it equals the given limiting index.
func formIndex(after: inout Self.Index)
Replaces the given index with its successor.
func formIndex(before: inout Self.Index)
func hash(into: inout Hasher)
func index(Self.Index, offsetBy: Int) -> Self.Index
func index(Self.Index, offsetBy: Int, limitedBy: Self.Index) -> Self.Index?
func index(after: SyntaxChildrenIndex) -> SyntaxChildrenIndex
func index(at: Int) -> SyntaxChildrenIndex
Returns the index of the n-th element in this collection.
func index(before: SyntaxChildrenIndex) -> SyntaxChildrenIndex
func index(of: Element) -> SyntaxChildrenIndex?
Return the index of node
within this collection.
func indices(of: Self.Element) -> RangeSet<Self.Index>
Returns the indices of all the elements that are equal to the given element.
func indices(where: (Self.Element) throws -> Bool) rethrows -> RangeSet<Self.Index>
Returns the indices of all the elements that match the given predicate.
func insert(Element, at: Index)
Inserts a new element into the collection at the specified position.
func insert(contentsOf: some Collection<Element>, at: Index)
Inserts the elements of a sequence into the collection at the specified position.
func `is`<S>(S.Type) -> Bool
Checks if the current syntax node can be cast to a given specialized syntax type.
func isProtocol(MissingNodeSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to MissingNodeSyntax
. Note that this will incur an existential conversion.
func isProtocol(ParenthesizedSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to ParenthesizedSyntax
. Note that this will incur an existential conversion.
func isProtocol(WithCodeBlockSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to WithCodeBlockSyntax
. Note that this will incur an existential conversion.
func isProtocol(WithModifiersSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to WithModifiersSyntax
. Note that this will incur an existential conversion.
func isProtocol(WithAttributesSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to WithAttributesSyntax
. Note that this will incur an existential conversion.
func isProtocol(WithStatementsSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to WithStatementsSyntax
. Note that this will incur an existential conversion.
func isProtocol(EffectSpecifiersSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to EffectSpecifiersSyntax
. Note that this will incur an existential conversion.
func isProtocol(WithTrailingCommaSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to WithTrailingCommaSyntax
. Note that this will incur an existential conversion.
func isProtocol(WithGenericParametersSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to WithGenericParametersSyntax
. Note that this will incur an existential conversion.
func isProtocol(WithOptionalCodeBlockSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to WithOptionalCodeBlockSyntax
. Note that this will incur an existential conversion.
func isProtocol(FreestandingMacroExpansionSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to FreestandingMacroExpansionSyntax
. Note that this will incur an existential conversion.
func isProtocol(BracedSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to BracedSyntax
. Note that this will incur an existential conversion.
func isProtocol(DeclGroupSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to DeclGroupSyntax
. Note that this will incur an existential conversion.
func isProtocol(NamedDeclSyntax.Protocol) -> Bool
Check whether the non-type erased version of this syntax node conforms to NamedDeclSyntax
. Note that this will incur an existential conversion.
func last(where: (Self.Element) throws -> Bool) rethrows -> Self.Element?
Returns the last element of the sequence that satisfies the given predicate.
func lastIndex(of: Self.Element) -> Self.Index?
Returns the last index where the specified value appears in the collection.
func lastIndex(where: (Self.Element) throws -> Bool) rethrows -> Self.Index?
Returns the index of the last element in the collection that matches the given predicate.
func lastToken(viewMode: SyntaxTreeViewMode) -> TokenSyntax?
Returns the last token node that is part of this syntax node.
func lexicographicallyPrecedes<OtherSequence>(OtherSequence, by: (Self.Element, Self.Element) throws -> Bool) rethrows -> Bool
Returns a Boolean value indicating whether the sequence precedes another sequence in a lexicographical (dictionary) ordering, using the given predicate to compare elements.
func makeIterator() -> SyntaxCollectionIterator<Element>
func map<T, E>((Self.Element) throws(E) -> T) throws(E) -> [T]
Returns an array containing the results of mapping the given closure over the sequence’s elements.
func map<T, E>((Self.Element) throws(E) -> T) throws(E) -> [T]
Returns an array containing the results of mapping the given closure over the sequence’s elements.
func max(by: (Self.Element, Self.Element) throws -> Bool) rethrows -> Self.Element?
Returns the maximum element in the sequence, using the given predicate as the comparison between elements.
func min(by: (Self.Element, Self.Element) throws -> Bool) rethrows -> Self.Element?
Returns the minimum element in the sequence, using the given predicate as the comparison between elements.
func nextToken(viewMode: SyntaxTreeViewMode) -> TokenSyntax?
Recursively walks through the tree to find the next token semantically after this node.
func node(at: SyntaxIdentifier) -> Syntax?
If the node with the given syntaxIdentifier
is a (recursive) child of this node, return the node with that identifier.
func prefix(Int) -> Self.SubSequence
Returns a subsequence, up to the specified maximum length, containing the initial elements of the collection.
func prefix(through: Self.Index) -> Self.SubSequence
Returns a subsequence from the start of the collection through the specified position.
func prefix(upTo: Self.Index) -> Self.SubSequence
Returns a subsequence from the start of the collection up to, but not including, the specified position.
func prefix(while: (Self.Element) throws -> Bool) rethrows -> Self.SubSequence
Returns a subsequence containing the initial elements until predicate
returns false
and skipping the remaining elements.
func previousToken(viewMode: SyntaxTreeViewMode) -> TokenSyntax?
Recursively walks through the tree to find the token semantically before this node.
func randomElement() -> Self.Element?
Returns a random element of the collection.
func randomElement<T>(using: inout T) -> Self.Element?
Returns a random element of the collection, using the given generator as a source for randomness.
func ranges<C>(of: C) -> [Range<Self.Index>]
Finds and returns the ranges of the all occurrences of a given sequence within the collection.
func reduce<Result>(Result, (Result, Self.Element) throws -> Result) rethrows -> Result
Returns the result of combining the elements of the sequence using the given closure.
func reduce<Result>(into: Result, (inout Result, Self.Element) throws -> ()) rethrows -> Result
Returns the result of combining the elements of the sequence using the given closure.
func remove(at: Index) -> Element
Removes and returns the element at the specified position.
func removeSubrange(Range<Index>)
Removes the elements in the specified subrange from the collection.
func removingSubranges(RangeSet<Self.Index>) -> DiscontiguousSlice<Self>
Returns a collection of the elements in this collection that are not represented by the given range set.
func replaceSubrange(Range<Self.Index>, with: some Collection<Element>)
Replace the nodes in subrange
by newElements
.
func reversed() -> ReversedCollection<Self>
Returns a view presenting the elements of the collection in reverse order.
func shuffled() -> [Self.Element]
Returns the elements of the sequence, shuffled.
func shuffled<T>(using: inout T) -> [Self.Element]
Returns the elements of the sequence, shuffled using the given generator as a source for randomness.
func sorted(by: (Self.Element, Self.Element) throws -> Bool) rethrows -> [Self.Element]
Returns the elements of the sequence, sorted using the given predicate as the comparison between elements.
func sourceRange(converter: SourceLocationConverter, afterLeadingTrivia: Bool, afterTrailingTrivia: Bool) -> SourceRange
The source range, in the provided file, of this Syntax node.
func split(maxSplits: Int, omittingEmptySubsequences: Bool, whereSeparator: (Self.Element) throws -> Bool) rethrows -> [Self.SubSequence]
Returns the longest possible subsequences of the collection, in order, that don’t contain elements satisfying the given predicate.
func split(separator: Self.Element, maxSplits: Int, omittingEmptySubsequences: Bool) -> [Self.SubSequence]
Returns the longest possible subsequences of the collection, in order, around elements equal to the given element.
func startLocation(converter: SourceLocationConverter, afterLeadingTrivia: Bool) -> SourceLocation
The starting location, in the provided file, of this Syntax node.
func starts<PossiblePrefix>(with: PossiblePrefix) -> Bool
Returns a Boolean value indicating whether the initial elements of the sequence are the same as the elements in another sequence.
func starts<PossiblePrefix>(with: PossiblePrefix, by: (Self.Element, PossiblePrefix.Element) throws -> Bool) rethrows -> Bool
Returns a Boolean value indicating whether the initial elements of the sequence are equivalent to the elements in another sequence, using the given predicate as the equivalence test.
func suffix(Int) -> Self.SubSequence
Returns a subsequence, up to the given maximum length, containing the final elements of the collection.
func suffix(from: Self.Index) -> Self.SubSequence
Returns a subsequence from the specified position to the end of the collection.
func token(at: AbsolutePosition) -> TokenSyntax?
Find the syntax token at the given absolute position within this syntax node or any of its children.
func tokens(viewMode: SyntaxTreeViewMode) -> TokenSequence
Sequence of tokens that are part of this Syntax node.
func trimmed(matching: (TriviaPiece) -> Bool) -> Self
A copy of this node with pieces that match matching
trimmed from the leading trivia of the first token and trailing trivia of the last token.
func trimmedDescription(matching: (TriviaPiece) -> Bool) -> String
The description of this node with pieces that match matching
removed from the leading trivia of the first token and trailing trivia of the last token.
func trimmingPrefix<Prefix>(Prefix) -> Self.SubSequence
Returns a new collection of the same type by removing prefix
from the start of the collection.
func trimmingPrefix(while: (Self.Element) throws -> Bool) rethrows -> Self.SubSequence
func with<T>(WritableKeyPath<Self, T>, T) -> Self
Returns a new syntax node that has the child at keyPath
replaced by value
.
func withContiguousStorageIfAvailable<R>((UnsafeBufferPointer<Self.Element>) throws -> R) rethrows -> R?
func write<Target>(to: inout Target)
Prints the raw value of this node to the provided stream.