Skip to content

Commit 6345ef9

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 2e175ba commit 6345ef9

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
@@ -1025,6 +1025,12 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int, ski
10251025
return
10261026
}
10271027

1028+
// Skip parenthesised expressions and extract their child directly in their place
1029+
if paren, ok := expr.(*ast.ParenExpr); ok {
1030+
extractExpr(tw, paren.X, parent, idx, skipExtractingValue)
1031+
return
1032+
}
1033+
10281034
lbl := tw.Labeler.LocalID(expr)
10291035
extractTypeOf(tw, expr, lbl)
10301036

@@ -1099,9 +1105,6 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int, ski
10991105
kind = dbscheme.CompositeLitExpr.Index()
11001106
extractExpr(tw, expr.Type, lbl, 0, false)
11011107
extractExprs(tw, expr.Elts, lbl, 1, 1)
1102-
case *ast.ParenExpr:
1103-
kind = dbscheme.ParenExpr.Index()
1104-
extractExpr(tw, expr.X, lbl, 0, false)
11051108
case *ast.SelectorExpr:
11061109
kind = dbscheme.SelectorExpr.Index()
11071110
extractExpr(tw, expr.X, lbl, 0, false)

0 commit comments

Comments
 (0)