cursorutil

package
v0.21.0-pre.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package cursorutil provides utility functions for working with inspector.Cursor.

It should create no additional dependencies beyond those of Cursor itself, so that functions can be promoted to the public API of Cursor in due course.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstEnclosing

func FirstEnclosing[N ast.Node](cur inspector.Cursor) (N, inspector.Cursor)

FirstEnclosing returns the first value from [cursor.Enclosing] as both a designated type and a inspector.Cursor pointing to it.

It returns the zero value if it is not found.

A common usage is:

call, callCur := cursorutil.FirstEnclosing[*ast.CallExpr](cur)
if call == nil {
	// Not Found
}

func Path

func Path(cur inspector.Cursor) (path []ast.Node)

Path returns the specified node followed by all its ancestors up to the file. Use it as an adaptor between cursors and code that works with PathEnclosingInterval. Ultimately all such code should be eliminated.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL