@@ -31,12 +31,6 @@ struct AbsoluteSyntaxPosition {
31
31
return . init( offset: self . offset, indexInParent: 0 )
32
32
}
33
33
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
-
40
34
static var forRoot : AbsoluteSyntaxPosition {
41
35
return . init( offset: 0 , indexInParent: 0 )
42
36
}
@@ -70,12 +64,6 @@ struct AbsoluteSyntaxInfo {
70
64
return . init( position: newPosition, nodeId: newNodeId)
71
65
}
72
66
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
-
79
67
static var forRoot : AbsoluteSyntaxInfo {
80
68
return . init( position: . forRoot, nodeId: . newRoot( ) )
81
69
}
@@ -87,13 +75,17 @@ struct SyntaxIndexInTree: Hashable {
87
75
88
76
static var zero : SyntaxIndexInTree = SyntaxIndexInTree ( indexInTree: 0 )
89
77
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 {
91
81
let newIndexInTree = self . indexInTree +
92
82
UInt32( truncatingIfNeeded: raw? . totalNodes ?? 0 )
93
83
return . init( indexInTree: newIndexInTree)
94
84
}
95
85
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 {
97
89
let newIndexInTree = self . indexInTree -
98
90
UInt32( truncatingIfNeeded: raw? . totalNodes ?? 0 )
99
91
return . init( indexInTree: newIndexInTree)
@@ -104,12 +96,6 @@ struct SyntaxIndexInTree: Hashable {
104
96
return . init( indexInTree: newIndexInTree)
105
97
}
106
98
107
- func advancedToEndOfChildren( _ raw: RawSyntax ) -> SyntaxIndexInTree {
108
- let newIndexInTree = self . indexInTree +
109
- UInt32( truncatingIfNeeded: raw. totalNodes)
110
- return . init( indexInTree: newIndexInTree)
111
- }
112
-
113
99
init ( indexInTree: UInt32 ) {
114
100
self . indexInTree = indexInTree
115
101
}
@@ -123,12 +109,12 @@ public struct SyntaxIdentifier: Hashable {
123
109
let indexInTree : SyntaxIndexInTree
124
110
125
111
func advancedBySibling( _ raw: RawSyntax ? ) -> SyntaxIdentifier {
126
- let newIndexInTree = indexInTree. advancedBySibling ( raw)
112
+ let newIndexInTree = indexInTree. advancedBy ( raw)
127
113
return . init( rootId: self . rootId, indexInTree: newIndexInTree)
128
114
}
129
115
130
116
func reversedBySibling( _ raw: RawSyntax ? ) -> SyntaxIdentifier {
131
- let newIndexInTree = self . indexInTree. reversedBySibling ( raw)
117
+ let newIndexInTree = self . indexInTree. reversedBy ( raw)
132
118
return . init( rootId: self . rootId, indexInTree: newIndexInTree)
133
119
}
134
120
@@ -137,11 +123,6 @@ public struct SyntaxIdentifier: Hashable {
137
123
return . init( rootId: self . rootId, indexInTree: newIndexInTree)
138
124
}
139
125
140
- func advancedToEndOfChildren( _ raw: RawSyntax ) -> SyntaxIdentifier {
141
- let newIndexInTree = self . indexInTree. advancedToEndOfChildren ( raw)
142
- return . init( rootId: self . rootId, indexInTree: newIndexInTree)
143
- }
144
-
145
126
static func newRoot( ) -> SyntaxIdentifier {
146
127
return . init( rootId: UInt32 ( truncatingIfNeeded: AtomicCounter . next ( ) ) ,
147
128
indexInTree: . zero)
0 commit comments