parse

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsumeLineDirective added in v1.5.0

func ConsumeLineDirective(r io.Reader) (string, error)

ConsumeLineDirective consumes the first line from r if it's a "//line" directive that either does not have line/column information or has it set to line 1 (and column 1). If the directive is consumed, the filename it refers to is returned. Otherwise, the reader is rewinded to its original position if the provided reader supports the io.Seeker interface.

Types

type File

type File struct {
	// Name is the name of the file.
	Name string
	// AstFile is the parsed AST of the file, cannot be nil
	AstFile *ast.File
	// Aspects is the list of aspects that may match on this file.
	Aspects []*aspect.Aspect
}

File represents a parsed file with its name, its AST and with the aspects that may match on it.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(fset *token.FileSet, nbFiles int) *Parser

NewParser creates a new parser with the given token.FileSet and the number of files to parse.

func (*Parser) ParseFiles

func (p *Parser) ParseFiles(ctx context.Context, files []string, aspects []*aspect.Aspect) ([]File, error)

ParseFiles return either zero files if no aspect matched on any file of the package, or all files parsed with their respective aspects that can match on them.

Jump to

Keyboard shortcuts

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