Debian Codegraph @

internal/astutil/cursor.go

raw symbols SCIP
1 // Copyright 2026 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package astutilscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/astutil`/
6
7 import (
8 "go/astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/"
9
10 "golang.org/x/tools/go/ast/edgescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/edge`/"
11 "golang.org/x/tools/go/ast/inspectorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/"
12 )
13
14 // UnparenCursor returns the cursor for an expression with any
15 // enclosing parentheses removed, similar to [ast.Unparen].
16 // It is often prudent to call this before switching on the
17 // type of cur.Node().
18 //
19 // See also [UnparenEnclosingCursor].
20 func UnparenCursorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/astutil`/UnparenCursor().(cur inspectorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/.Cursorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/Cursor#) inspectorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/.Cursorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/Cursor# {
21 for isscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/astutil`/is().[*astscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/.ParenExprscip-go gomod github.com/golang/go/src go1.25.0 `go/ast`/ParenExpr#](cur) {
22 cur, _ = cur.FirstChildscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/Cursor#FirstChild().()
23 }
24 return cur
25 }
26
27 // UnparenEnclosingCursor returns the first element of
28 // the [Cursor.Enclosing] sequence that is not itself enclosed
29 // in parens. It is often prudent to call this before switching on
30 // cur.ParentEdge().
31 //
32 // See also [UnparenCursor].
33 func UnparenEnclosingCursorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/astutil`/UnparenEnclosingCursor().(cur inspectorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/.Cursorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/Cursor#) inspectorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/.Cursorscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/Cursor# {
34 for cur.ParentEdgeKindscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/Cursor#ParentEdgeKind().() == edgescip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/edge`/.ParenExpr_Xscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/edge`/ParenExpr_X. {
35 cur = cur.Parentscip-go gomod golang.org/x/tools . `golang.org/x/tools/go/ast/inspector`/Cursor#Parent().()
36 }
37 return cur
38 }