File tree Expand file tree Collapse file tree 4 files changed +12
-9
lines changed
semanticcpg/src/main/scala/io/shiftleft/semanticcpg/language/nodemethods Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name := "joern"
22ThisBuild / organization := " io.joern"
33ThisBuild / scalaVersion := " 3.6.4"
44
5- val cpgVersion = " 1.7.41 "
5+ val cpgVersion = " 1.7.43 "
66
77lazy val joerncli = Projects .joerncli
88lazy val querydb = Projects .querydb
Original file line number Diff line number Diff line change 11package io .shiftleft .semanticcpg .language .nodemethods
22
3- import io .shiftleft .Implicits .IterableOnceDeco
43import io .shiftleft .codepropertygraph .generated .nodes .*
54import io .shiftleft .codepropertygraph .generated .PropertyDefaults
65import io .shiftleft .semanticcpg .NodeExtension
@@ -66,7 +65,14 @@ class AstNodeMethods(val node: AstNode) extends AnyVal with NodeExtension {
6665 }
6766
6867 def astParent : AstNode =
69- node._astIn.onlyChecked.asInstanceOf [AstNode ]
68+ node._astIn
69+ .loneElement(
70+ " trying to resolve astParent - either this is a root node, or it has two parents (which is probably a malformed cpg)"
71+ )
72+ .asInstanceOf [AstNode ]
73+
74+ def astParentOption : Option [AstNode ] =
75+ node._astIn.loneElementOption.asInstanceOf [Option [AstNode ]]
7076
7177 /** Direct children of node in the AST. Siblings are ordered by their `order` fields
7278 */
Original file line number Diff line number Diff line change 11package io .shiftleft .semanticcpg .language .nodemethods
22
3- import io .shiftleft .Implicits .IterableOnceDeco
43import io .shiftleft .codepropertygraph .generated .nodes .*
54import io .shiftleft .semanticcpg .NodeExtension
65import io .shiftleft .semanticcpg .language .*
@@ -120,10 +119,10 @@ class CfgNodeMethods(val node: CfgNode) extends AnyVal with NodeExtension {
120119 }
121120
122121 private def walkUpAst (node : CfgNode ): Method =
123- node._astIn.onlyChecked .asInstanceOf [Method ]
122+ node.astParent .asInstanceOf [Method ]
124123
125124 private def walkUpContains (node : StoredNode ): Method =
126- node._containsIn.onlyChecked match {
125+ node._containsIn.loneElement( " trying to walk `containsIn` edge " ) match {
127126 case method : Method => method
128127 case typeDecl : TypeDecl =>
129128 typeDecl.astParent match {
Original file line number Diff line number Diff line change 11package io .shiftleft .semanticcpg .language .nodemethods
22
3- import io .shiftleft .Implicits .IterableOnceDeco
43import io .shiftleft .codepropertygraph .generated .nodes .*
54import io .shiftleft .semanticcpg .NodeExtension
65import io .shiftleft .semanticcpg .language .ICallResolver
@@ -22,8 +21,7 @@ class ExpressionMethods(val node: Expression) extends AnyVal with NodeExtension
2221
2322 @ tailrec
2423 private final def _parentExpression (argument : AstNode ): Option [Expression ] = {
25- val parent = argument._astIn.onlyChecked
26- parent match {
24+ argument.astParent match {
2725 case call : Call if MemberAccess .isGenericMemberAccessName(call.name) =>
2826 _parentExpression(call)
2927 case expression : Expression =>
You can’t perform that action at this time.
0 commit comments