Skip to content

Commit

Permalink
[c#] handle ParenthesizedExpression AST nodes (#5252)
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierpinho authored Jan 24, 2025
1 parent 20636ae commit b2bf9bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode) {
case ConditionalAccessExpression => astForConditionalAccessExpression(expr)
case SuppressNullableWarningExpression => astForSuppressNullableWarningExpression(expr)
case _: BaseLambdaExpression => astForSimpleLambdaExpression(expr)
case ParenthesizedExpression => astForParenthesizedExpression(expr)
case _ => notHandledYet(expr)
}
}

private def astForParenthesizedExpression(parenExpr: DotNetNodeInfo): Seq[Ast] = {
astForNode(parenExpr.json(ParserKeys.Expression))
}

private def astForAwaitExpression(awaitExpr: DotNetNodeInfo): Seq[Ast] = {
/* fullName is the name in case of STATIC_DISPATCH */
val node =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ object DotNetJsonAst {

object Attribute extends BaseExpr

object ParenthesizedExpression extends BaseExpr

object Unknown extends DotNetParserNode

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class OperatorDataflowTests extends CSharpCode2CpgFixture(withDataFlow = true) {
val src = cpg.identifier.nameExact("a").l;
val sink = cpg.identifier.nameExact("d").l
sink.reachableBy(src).size shouldBe 2
sink.reachableBy(cpg.literal("3")).size shouldBe 1
}

"be reachable (case 2)" in {
Expand Down

0 comments on commit b2bf9bd

Please sign in to comment.