Skip to content

Commit

Permalink
Including changes from Review
Browse files Browse the repository at this point in the history
  • Loading branch information
konradweiss committed Jan 15, 2024
1 parent f8d08eb commit b6cb824
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,16 @@ fun <T : Node, S> T.codeAndLocationFromChildren(

// Search through all children to find the first and last node based on region startLine and
// startColumn
var worklist: MutableList<Node> = this.astChildren.toMutableList()
val worklist: MutableList<Node> = this.astChildren.toMutableList()
while (worklist.isNotEmpty()) {
var current = worklist.removeFirst()
val current = worklist.removeFirst()
if (current.location?.region == null || current.location?.region == Region()) {
// If the node has no location we use the same search on his children again
worklist.addAll(current.astChildren)
} else {
// Compare nodes by line and column in lexicographic order, i.e. column is compared if
// lines are equal
if (first == null || last == null) {
if (first == null) {
first = current
last = current
}
Expand All @@ -311,8 +311,8 @@ fun <T : Node, S> T.codeAndLocationFromChildren(
first,
current,
compareBy(
{ it?.location?.region?.startLine },
{ it?.location?.region?.startColumn }
{ it.location?.region?.startLine },
{ it.location?.region?.startColumn }
)
)
last =
Expand Down

0 comments on commit b6cb824

Please sign in to comment.