@@ -31,12 +31,6 @@ struct AbsoluteSyntaxPosition {
3131 return . init( offset: self . offset, indexInParent: 0 )
3232 }
3333
34- func advancedToEndOfChildren( _ raw: RawSyntax ) -> AbsoluteSyntaxPosition {
35- let newOffset = self . offset + UInt32( truncatingIfNeeded: raw. totalLength. utf8Length)
36- let newIndexInParent = UInt32 ( truncatingIfNeeded: raw. numberOfChildren)
37- return . init( offset: newOffset, indexInParent: newIndexInParent)
38- }
39-
4034 static var forRoot : AbsoluteSyntaxPosition {
4135 return . init( offset: 0 , indexInParent: 0 )
4236 }
@@ -70,12 +64,6 @@ struct AbsoluteSyntaxInfo {
7064 return . init( position: newPosition, nodeId: newNodeId)
7165 }
7266
73- func advancedToEndOfChildren( _ raw: RawSyntax ) -> AbsoluteSyntaxInfo {
74- let newPosition = position. advancedToEndOfChildren ( raw)
75- let newNodeId = nodeId. advancedToEndOfChildren ( raw)
76- return . init( position: newPosition, nodeId: newNodeId)
77- }
78-
7967 static var forRoot : AbsoluteSyntaxInfo {
8068 return . init( position: . forRoot, nodeId: . newRoot( ) )
8169 }
@@ -87,13 +75,17 @@ struct SyntaxIndexInTree: Hashable {
8775
8876 static var zero : SyntaxIndexInTree = SyntaxIndexInTree ( indexInTree: 0 )
8977
90- func advancedBySibling( _ raw: RawSyntax ? ) -> SyntaxIndexInTree {
78+ /// Assuming that this index points to the start of `Raw`, so that it points
79+ /// to the next sibling of `Raw`.
80+ func advancedBy( _ raw: RawSyntax ? ) -> SyntaxIndexInTree {
9181 let newIndexInTree = self . indexInTree +
9282 UInt32( truncatingIfNeeded: raw? . totalNodes ?? 0 )
9383 return . init( indexInTree: newIndexInTree)
9484 }
9585
96- func reversedBySibling( _ raw: RawSyntax ? ) -> SyntaxIndexInTree {
86+ /// Assuming that this index points to the next sibling of `Raw`, reverse it
87+ /// so that it points to the start of `Raw`.
88+ func reversedBy( _ raw: RawSyntax ? ) -> SyntaxIndexInTree {
9789 let newIndexInTree = self . indexInTree -
9890 UInt32( truncatingIfNeeded: raw? . totalNodes ?? 0 )
9991 return . init( indexInTree: newIndexInTree)
@@ -104,12 +96,6 @@ struct SyntaxIndexInTree: Hashable {
10496 return . init( indexInTree: newIndexInTree)
10597 }
10698
107- func advancedToEndOfChildren( _ raw: RawSyntax ) -> SyntaxIndexInTree {
108- let newIndexInTree = self . indexInTree +
109- UInt32( truncatingIfNeeded: raw. totalNodes)
110- return . init( indexInTree: newIndexInTree)
111- }
112-
11399 init ( indexInTree: UInt32 ) {
114100 self . indexInTree = indexInTree
115101 }
@@ -123,12 +109,12 @@ public struct SyntaxIdentifier: Hashable {
123109 let indexInTree : SyntaxIndexInTree
124110
125111 func advancedBySibling( _ raw: RawSyntax ? ) -> SyntaxIdentifier {
126- let newIndexInTree = indexInTree. advancedBySibling ( raw)
112+ let newIndexInTree = indexInTree. advancedBy ( raw)
127113 return . init( rootId: self . rootId, indexInTree: newIndexInTree)
128114 }
129115
130116 func reversedBySibling( _ raw: RawSyntax ? ) -> SyntaxIdentifier {
131- let newIndexInTree = self . indexInTree. reversedBySibling ( raw)
117+ let newIndexInTree = self . indexInTree. reversedBy ( raw)
132118 return . init( rootId: self . rootId, indexInTree: newIndexInTree)
133119 }
134120
@@ -137,11 +123,6 @@ public struct SyntaxIdentifier: Hashable {
137123 return . init( rootId: self . rootId, indexInTree: newIndexInTree)
138124 }
139125
140- func advancedToEndOfChildren( _ raw: RawSyntax ) -> SyntaxIdentifier {
141- let newIndexInTree = self . indexInTree. advancedToEndOfChildren ( raw)
142- return . init( rootId: self . rootId, indexInTree: newIndexInTree)
143- }
144-
145126 static func newRoot( ) -> SyntaxIdentifier {
146127 return . init( rootId: UInt32 ( truncatingIfNeeded: AtomicCounter . next ( ) ) ,
147128 indexInTree: . zero)
0 commit comments