Skip to content

Commit ec9161f

Browse files
committed
WIP: Code refactor
1 parent 08c782d commit ec9161f

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

CodeGeneration/Sources/SyntaxSupport/Node.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,11 @@ public class Node {
128128
continue
129129
}
130130

131+
choices.append(contentsOf: getChildTokenChoice(child))
132+
131133
if !child.isOptional {
132-
choices.append(contentsOf: getChildTokenChoice(child))
133134
break
134135
}
135-
136-
choices.append(contentsOf: getChildTokenChoice(child))
137136
}
138137
return choices
139138
}

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/IncrementalParseUtilsFile.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ let IncrementalParseUtilsFile = SourceFileSyntax(leadingTrivia: copyrightHeader)
8383
lastNonNilChildIdx != children.endIndex
8484
{
8585
86-
var nextPotentialNodeIndex = children.distance(from: children.startIndex, to: children.index(after: lastNonNilChildIdx))
86+
var nextPotentialNodeIndex = children.index(after: lastNonNilChildIdx)
8787
8888
if self.kind.syntaxLayout[nextPotentialNodeIndex].allSatisfy({ $0 == .unexpectedNodes }) {
89-
nextPotentialNodeIndex += 1
89+
nextPotentialNodeIndex = children.index(after: nextPotentialNodeIndex)
9090
}
9191
92-
if nextPotentialNodeIndex == children.count {
92+
if nextPotentialNodeIndex == children.endIndex {
9393
return []
9494
}
9595

Sources/SwiftParser/generated/IncrementalParseUtils.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7669,15 +7669,15 @@ extension RawSyntax {
76697669
lastNonNilChildIdx != children.endIndex
76707670
{
76717671

7672-
var nextPotentialNodeIndex = children.distance(from: children.startIndex, to: children.index(after: lastNonNilChildIdx))
7672+
var nextPotentialNodeIndex = children.index(after: lastNonNilChildIdx)
76737673

76747674
if self.kind.syntaxLayout[nextPotentialNodeIndex].allSatisfy({
76757675
$0 == .unexpectedNodes
76767676
}) {
7677-
nextPotentialNodeIndex += 1
7677+
nextPotentialNodeIndex = children.index(after: nextPotentialNodeIndex)
76787678
}
76797679

7680-
if nextPotentialNodeIndex == children.count {
7680+
if nextPotentialNodeIndex == children.endIndex {
76817681
return []
76827682
}
76837683

0 commit comments

Comments
 (0)