parser

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDefinition

func IsDefinition(name string) bool

IsDefinition returns true if the current name is a CUE definition Pattern detected are: - #Foo - _#Foo It returns false if it's not a definition

func ParseDefs

func ParseDefs(defs *Definitions, importAliases map[string]string, f *ast.File)

ParseDefs will fill Definitions data structure will all definitions found in the given ast.File There are two type of definitions declared in the AST - Ident: those are definitions from the package itself - SelectorExpr: those are definitions from external package they will be stored as <pkg>.<def> (E.g., foo.#Bar)

Types

type Definitions

type Definitions map[int][]Range

Definitions is a map with the line number of a CUE file as key and a range of definition as value. Those Range are sorted in ascending order by start.Column() Definitions can hold 10 definition (so 10 Range) in a line.

func (Definitions) AppendRange

func (def Definitions) AppendRange(name string, start token.Pos, end token.Pos)

AppendRange add a new definition to the line. Due to AST structure, it will always be sorted in ascending order by start.Column()

func (Definitions) Find

func (def Definitions) Find(line int, column int) (string, error)

Find will search for a definition in the Definition object following line and column It will return the definition's name if found, or an error if not found Find function has a complexity of O(log(n)) thanks Definitions data structure that his a map.

func (Definitions) String

func (def Definitions) String() string

type Range

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

Range position of a definition

func (Range) End

func (r Range) End() token.Pos

func (Range) Name

func (r Range) Name() string

func (Range) Start

func (r Range) Start() token.Pos

func (Range) String

func (r Range) String() string

Jump to

Keyboard shortcuts

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