language

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder[F CodeFile, C any] func(C) (Language[F], error)

type CodeFile added in v0.17.4

type CodeFile interface {
	Loc() int
	Size() int
}

type Config added in v0.17.4

type Config interface {
	UnwrapProxyExports() bool
	IgnoreFiles() []string
}

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 ExportsEntries added in v0.17.4

type ExportsEntries 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 ExportsResult

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

type FileCacheKey

type FileCacheKey string

type FileInfo added in v0.17.4

type FileInfo struct {
	Loc  int
	Size int
}

type Graph added in v0.17.4

type Graph = graph.Graph[FileInfo]

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
}

func AllImport added in v0.17.4

func AllImport(path string) ImportEntry

func EmptyImport added in v0.17.4

func EmptyImport(path string) ImportEntry

func NamesImport added in v0.17.4

func NamesImport(names []string, path string) ImportEntry

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[F CodeFile] 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)
	// 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) (*ExportsEntries, error)
	// Display takes an absolute path to a file and displays it nicely.
	Display(path string) string
}

type Node added in v0.17.4

type Node = graph.Node[FileInfo]

type NodeParser added in v0.17.4

type NodeParser = dep_tree.NodeParser[FileInfo]

type NodeParserBuilder added in v0.17.4

type NodeParserBuilder = dep_tree.NodeParserBuilder[FileInfo]

func ParserBuilder

func ParserBuilder[F CodeFile, C any](languageBuilder Builder[F, C], langCfg C, generalCfg Config) NodeParserBuilder

type Parser

type Parser[F CodeFile] struct {
	// contains filtered or unexported fields
}

func (*Parser[F]) Deps

func (p *Parser[F]) Deps(n *Node) ([]*Node, error)

func (*Parser[F]) Display

func (p *Parser[F]) Display(n *Node) string

func (*Parser[F]) Node added in v0.19.0

func (p *Parser[F]) Node(id string) (*Node, error)

type TestFile

type TestFile struct {
	Name string
}

func (TestFile) Loc added in v0.17.4

func (t TestFile) Loc() int

func (TestFile) Size added in v0.17.4

func (t TestFile) Size() int

type TestLanguage

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

func (*TestLanguage) Display added in v0.19.0

func (t *TestLanguage) Display(id string) string

func (*TestLanguage) ParseExports

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

func (*TestLanguage) ParseFile

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

func (*TestLanguage) ParseImports

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

Jump to

Keyboard shortcuts

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