parser

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCommentInTagExpr = errors.New("comments are not allowed within tag expressions")

Functions

func GetClosestModFile

func GetClosestModFile(startPath string) (file *modfile.File, moddir string, err error)

Types

type InputFile

type InputFile struct {
	Path      string            // Path of the file
	Modfile   *modfile.File     // File's module
	Moddir    string            // Directory where module file is present
	Pkg       *packages.Package // Parsed file's package
	SyntaxIdx int               // index of file ast in pkg.Syntax
}

func Parse

func Parse(targetFile string) (file *InputFile, err error)

func (InputFile) Ast

func (fi InputFile) Ast() *ast.File

func (InputFile) GetInputStructs

func (f InputFile) GetInputStructs(acceptor TypeAcceptor) ([]domain.InputStruct, error)

type TypeAcceptor

type TypeAcceptor interface {
	// Should return true if type is required to be serializable
	Accepts(tspec *ast.TypeSpec) bool
	// Should return true if no more types are expected
	IsDrained() bool
	// Should return true if acceptor has no type restrictions
	AcceptsAll() bool
	fmt.Stringer
}

Jump to

Keyboard shortcuts

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