parser

package
v2.7.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearPackageCache added in v2.6.10

func ClearPackageCache()

ClearPackageCache resets the directory-level package-load cache. Call this in tests that need a clean state between ParseAndTypeCheckFile invocations.

func FindOriginalStartLine

func FindOriginalStartLine(diff []byte) int64

FindOriginalStartLine returns the original-file line number of the first changed line in a unified (`diff -u`) diff. It walks the body of the first hunk rather than assuming a fixed amount of leading context, so it stays correct when the change is near the top of the file (fewer than three context lines) or when a leading comment sits above the changed code — in both cases a fixed "header + 3" offset would point at the wrong line (often the comment). Returns 0 when no hunk header is found.

func ParseAndTypeCheckFile

func ParseAndTypeCheckFile(file string, collectors []filter.NodeCollector) (*ast.File, *token.FileSet, *types.Package, *types.Info, error)

ParseAndTypeCheckFile parses and type-checks the given file, and returns everything interesting about the file. If a fatal error is encountered the error return argument is not nil.

func ParseFile

func ParseFile(file string) (*ast.File, *token.FileSet, error)

ParseFile parses the content of the given file and returns the corresponding ast.File node and its file set for positional information. If a fatal error is encountered the error return argument is not nil.

func ParseSource

func ParseSource(data interface{}) (*ast.File, *token.FileSet, error)

ParseSource parses the given source and returns the corresponding ast.File node and its file set for positional information. If a fatal error is encountered the error return argument is not nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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