Skip to content

Commit 0eeddc3

Browse files
owen-mcCopilot
andcommitted
Go: skip extracting ast.ParenExpr nodes
Instead of creating a database entry for parenthesised expressions, extract their child expression directly in their place. This makes the extracted AST act as if ParenExpr nodes do not exist while still correctly extracting children. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d5712ef commit 0eeddc3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

go/extractor/extractor.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,12 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int, ski
10131013
return
10141014
}
10151015

1016+
// Skip parenthesised expressions and extract their child directly in their place
1017+
if paren, ok := expr.(*ast.ParenExpr); ok {
1018+
extractExpr(tw, paren.X, parent, idx, skipExtractingValue)
1019+
return
1020+
}
1021+
10161022
lbl := tw.Labeler.LocalID(expr)
10171023
extractTypeOf(tw, expr, lbl)
10181024

@@ -1087,9 +1093,6 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int, ski
10871093
kind = dbscheme.CompositeLitExpr.Index()
10881094
extractExpr(tw, expr.Type, lbl, 0, false)
10891095
extractExprs(tw, expr.Elts, lbl, 1, 1)
1090-
case *ast.ParenExpr:
1091-
kind = dbscheme.ParenExpr.Index()
1092-
extractExpr(tw, expr.X, lbl, 0, false)
10931096
case *ast.SelectorExpr:
10941097
kind = dbscheme.SelectorExpr.Index()
10951098
extractExpr(tw, expr.X, lbl, 0, false)

0 commit comments

Comments
 (0)