From b6cb824062cce33b75c411b233f2d54facda2743 Mon Sep 17 00:00:00 2001 From: Konrad Weiss Date: Mon, 15 Jan 2024 21:05:25 +0100 Subject: [PATCH] Including changes from Review --- .../de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt index 105db8b77d..8f358af8de 100644 --- a/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt +++ b/cpg-core/src/main/kotlin/de/fraunhofer/aisec/cpg/graph/NodeBuilder.kt @@ -293,16 +293,16 @@ fun T.codeAndLocationFromChildren( // Search through all children to find the first and last node based on region startLine and // startColumn - var worklist: MutableList = this.astChildren.toMutableList() + val worklist: MutableList = 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 } @@ -311,8 +311,8 @@ fun T.codeAndLocationFromChildren( first, current, compareBy( - { it?.location?.region?.startLine }, - { it?.location?.region?.startColumn } + { it.location?.region?.startLine }, + { it.location?.region?.startColumn } ) ) last =