wrkspc

package
v0.0.0-...-e49a3f0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ErrParseFmt     = "Error parsing file %s syntax nodes: %w"
	ErrReadFmt      = "Error reading file %s: %w"
	ErrParseWalkFmt = "Error walking the workspace files: %w"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ParsedFile

type ParsedFile struct {
	Path    string
	Content string
}

type Rooter

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

Rooter is a common way of passing around the root and path of a file/symbol.

If root is not available upon creation, you can leave it nil and it will be retrieved and cached when asked for.

A valid path is mandatory though.

func NewRooter

func NewRooter(path string, root ...*ast.Root) *Rooter

NewRooter creates a new rooter struct, you can pass 0 or 1 root. If 0 roots, the root will be retrieved and cached when asked for. If 1 root, the given root is used when asked for. If > 2 roots, panic.

func (*Rooter) Path

func (r *Rooter) Path() string

func (*Rooter) Root

func (r *Rooter) Root() *ast.Root

type Wrkspc

type Wrkspc interface {
	Root() string

	Index(files chan<- *ParsedFile, total *atomic.Uint64, totalDone chan<- bool) error

	// ContentOf returns the content of the file at the given path.
	ContentOf(path string) (string, error)
	// FContentOf returns the content of the file at the given path.
	// If an error occurs, it logs it and returns an empty string.
	// Use ContentOf for access to the error.
	FContentOf(path string) string

	// IROf returns the parsed root node of the given path.
	// If an error occurs, it returns an empty root node, this NEVER returns nil.
	IROf(path string) (*ast.Root, error)
	// FIROf returns the root of the given path, if an error occurs, it logs it
	// and returns an empty root node. This never returns nil.
	// Use IROf for access to the error.
	FIROf(path string) *ast.Root

	// AllOf returns the content & parsed root node of the given path.
	// If an error occurs, it returns an empty root node, this NEVER returns nil.
	AllOf(path string) (string, *ast.Root, error)
	// FAllOf returns both the content and root node of the given path.
	// If an error occurs, it returns an empty root node and string after logging the error.
	FAllOf(path string) (string, *ast.Root)

	Refresh(path string) error

	RefreshFrom(path string, content string) error

	FLexerOf(path string) lexer.Lexer

	IsPhpFile(path string) bool
}
var (
	ErrFileNotIndexed = errors.New("File is not indexed in the workspace")

	Current Wrkspc
)

func New

func New(phpv *phpversion.PHPVersion, root string, stubs string) Wrkspc

fileExtensions should all start with a period.

Jump to

Keyboard shortcuts

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