language

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParserBuilder

func ParserBuilder[T any, F any](languageBuilder Builder[T, F]) dep_tree.NodeParserBuilder[T]

Types

type Builder

type Builder[T any, F any] func(context.Context, string) (context.Context, Language[T, F], error)

type ExportEntry

type ExportEntry struct {
	// All: all the names from Path are exported.
	All bool
	// Names: exported specific names from Path.
	Names []ExportName
	// Path: absolute path from where they are exported, it might be from the same file or from another.
	Path string
}

type ExportName

type ExportName struct {
	Original string
	Alias    string
}

type ExportsCacheKey

type ExportsCacheKey string

type ExportsResult

type ExportsResult struct {
	// Exports: array of ExportEntry
	//  NOTE: even though it could work returning a path relative to the file, it should return absolute.
	Exports []ExportEntry
	// Errors: errors while parsing exports.
	Errors []error
}

type FileCacheKey

type FileCacheKey string

type ImportEntry

type ImportEntry struct {
	// All: if all the names from Path are imported.
	All bool
	// Names: what specific names form Path are imported.
	Names []string
	// Path: from where are the names imported.
	Path string
}

type ImportsCacheKey

type ImportsCacheKey string

type ImportsResult

type ImportsResult struct {
	// Imports: ordered map from absolute imported path to the array of names that where imported.
	//  if one of the names is *, then all the names are imported
	Imports []ImportEntry
	// Errors: errors while parsing imports.
	Errors []error
}

type Language

type Language[T any, F any] interface {
	// ParseFile receives an absolute file path and returns F, where F is the specific file implementation
	//  defined by the language. This file object F will be used as input for parsing imports and exports.
	ParseFile(path string) (*F, error)
	// MakeNode receives an absolute file path and returns a graph.Node implementation.
	MakeNode(path string) (*graph.Node[T], error)
	// ParseImports receives the file F parsed by the ParseFile method and gathers the imports that the file
	//  F contains.
	ParseImports(file *F) (*ImportsResult, error)
	// ParseExports receives the file F parsed by the ParseFile method and gathers the exports that the file
	//  F contains.
	ParseExports(file *F) (*ExportsResult, error)
}

type Parser

type Parser[T any, F any] struct {
	// contains filtered or unexported fields
}

func (*Parser[T, F]) CachedParseExports

func (p *Parser[T, F]) CachedParseExports(
	ctx context.Context,
	filePath string,
) (context.Context, *ExportsResult, error)

func (*Parser[T, F]) CachedParseFile

func (p *Parser[T, F]) CachedParseFile(ctx context.Context, id string) (context.Context, *F, error)

func (*Parser[T, F]) CachedParseImports

func (p *Parser[T, F]) CachedParseImports(
	ctx context.Context,
	id string,
) (context.Context, *ImportsResult, error)

func (*Parser[T, F]) CachedUnwrappedParseExports

func (p *Parser[T, F]) CachedUnwrappedParseExports(
	ctx context.Context,
	id string,
) (context.Context, *UnwrappedExportsResult, error)

func (*Parser[T, F]) Deps

func (p *Parser[T, F]) Deps(ctx context.Context, n *graph.Node[T]) (context.Context, []*graph.Node[T], error)

func (*Parser[T, F]) Display

func (p *Parser[T, F]) Display(n *graph.Node[T]) string

func (*Parser[T, F]) Entrypoint

func (p *Parser[T, F]) Entrypoint() (*graph.Node[T], error)

type TestFile

type TestFile struct {
	Name string
}

type TestLanguage

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

func (*TestLanguage) MakeNode

func (t *TestLanguage) MakeNode(id string) (*graph.Node[TestLanguageData], error)

func (*TestLanguage) ParseExports

func (t *TestLanguage) ParseExports(file *TestFile) (*ExportsResult, error)

func (*TestLanguage) ParseFile

func (t *TestLanguage) ParseFile(id string) (*TestFile, error)

func (*TestLanguage) ParseImports

func (t *TestLanguage) ParseImports(file *TestFile) (*ImportsResult, error)

type TestLanguageData

type TestLanguageData struct{}

type UnwrappedExportsCacheKey

type UnwrappedExportsCacheKey string

type UnwrappedExportsResult

type UnwrappedExportsResult struct {
	// Exports: map from exported name to exported path.
	Exports *orderedmap.OrderedMap[string, string]
	// Errors: errors gathered while resolving exports.
	Errors []error
}

Jump to

Keyboard shortcuts

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