Skip to content

Commit

Permalink
Drop label from SyntaxInTree initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
ahoppen committed Aug 29, 2023
1 parent 3ee9d14 commit dd37387
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/SyntaxChildren.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ struct RawSyntaxChildren: BidirectionalCollection {
let offset = startIndex.offset + UInt32(parent.totalLength.utf8Length)
let indexInParent = startIndex.indexInParent + UInt32(parentLayoutView.children.count)
let indexInTree = startIndex.indexInTree.indexInTree + UInt32(parent.totalNodes) - 1
let syntaxIndexInTree = SyntaxIndexInTree(indexInTree: indexInTree)
let syntaxIndexInTree = SyntaxIndexInTree(indexInTree)
let materialized = SyntaxChildrenIndex(
offset: offset,
indexInParent: indexInParent,
Expand Down
10 changes: 5 additions & 5 deletions Sources/SwiftSyntax/SyntaxData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,28 @@ struct AbsoluteSyntaxInfo {
public struct SyntaxIndexInTree: Comparable, Hashable {
let indexInTree: UInt32

static var zero: SyntaxIndexInTree = SyntaxIndexInTree(indexInTree: 0)
static var zero: SyntaxIndexInTree = SyntaxIndexInTree(0)

/// Assuming that this index points to the start of ``Raw``, so that it points
/// to the next sibling of ``Raw``.
func advancedBy(_ raw: RawSyntax?) -> SyntaxIndexInTree {
let newIndexInTree = self.indexInTree + UInt32(truncatingIfNeeded: raw?.totalNodes ?? 0)
return .init(indexInTree: newIndexInTree)
return .init(newIndexInTree)
}

/// Assuming that this index points to the next sibling of ``Raw``, reverse it
/// so that it points to the start of ``Raw``.
func reversedBy(_ raw: RawSyntax?) -> SyntaxIndexInTree {
let newIndexInTree = self.indexInTree - UInt32(truncatingIfNeeded: raw?.totalNodes ?? 0)
return .init(indexInTree: newIndexInTree)
return .init(newIndexInTree)
}

func advancedToFirstChild() -> SyntaxIndexInTree {
let newIndexInTree = self.indexInTree + 1
return .init(indexInTree: newIndexInTree)
return .init(newIndexInTree)
}

init(indexInTree: UInt32) {
init(_ indexInTree: UInt32) {
self.indexInTree = indexInTree
}

Expand Down

0 comments on commit dd37387

Please sign in to comment.