language

package
v0.0.0-...-5ce2981 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Names

func Names() []string

Names returns the list of available language names sorted alphabetically

func Register

func Register(lang LangInterface) error

Register adds the provided language to the list of supported languages

func Reset

func Reset(name string)

Reset resets the language with the provided name to its default values

Types

type FileTreeFilter

type FileTreeFilter struct {
	Directories  []string
	FilePatterns []string
}

FileTreeFilter provides filtering mechanisms allowing to determine if a file or directory is related to a language

type LangInterface

type LangInterface interface {
	GetName() string
	GetToolchains() Toolchains
	GetSrcFileFilter() FileTreeFilter
	GetTestFileFilter() FileTreeFilter
	GetToolchain(toolchainName string) (toolchain.TchnInterface, error)
	DirsToWatch(baseDir string) []string
	IsSrcFile(aPath string) bool
	IsTestFile(aPath string) bool
	IsLanguageFile(filename string) bool
	AllSrcFiles() ([]string, error)
	AllTestFiles() ([]string, error)
	// contains filtered or unexported methods
}

LangInterface provides the interface for interacting with a language

func Get

func Get(name string) (LangInterface, error)

Get returns the language instance with the provided name. The language name is case-insensitive. This method does not guarantee that the returned language instance can be used out of the box for file filtering operations as it does not enforce that baseDir is set. Prefer GetLanguage in this case.

func GetLanguage

func GetLanguage(name string, baseDir string) (lang LangInterface, err error)

GetLanguage returns the language to be used in current session. If no value is provided for language (e.g. empty string), we try to detect the language based on the directory name. Both name and baseDir are case-insensitive

type Language

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

Language defines the data structure of a language. - name is the name of the language, it must be unique in the list of available languages

func New

func New(name string, toolchains Toolchains, srcFiles FileTreeFilter, testFiles FileTreeFilter) *Language

New creates a new Language instance with the provided name, toolchains, srcFiles and testFiles

func (*Language) AllSrcFiles

func (lang *Language) AllSrcFiles() (result []string, err error)

AllSrcFiles returns the list of source files for this language. If there is an overlap between source and test files patterns, test files are excluded from the returned list

func (*Language) AllTestFiles

func (lang *Language) AllTestFiles() (result []string, err error)

AllTestFiles returns the list of test files for this language.

func (*Language) DirsToWatch

func (lang *Language) DirsToWatch(baseDir string) (dirs []string)

DirsToWatch returns the list of directories that TCR engine needs to watch for this language

func (*Language) GetName

func (lang *Language) GetName() string

GetName provides the name of the toolchain

func (*Language) GetSrcFileFilter

func (lang *Language) GetSrcFileFilter() FileTreeFilter

GetSrcFileFilter provides the language's list of filters for source files

func (*Language) GetTestFileFilter

func (lang *Language) GetTestFileFilter() FileTreeFilter

GetTestFileFilter provides the language's list of filters for test files

func (*Language) GetToolchain

func (lang *Language) GetToolchain(toolchainName string) (tchn toolchain.TchnInterface, err error)

GetToolchain returns the toolchain instance for this language. - If toolchainName is provided and is compatible with this language, it will be returned. - If toolchainName is provided but is not compatible with this language, an error is returned. - If toolchainName is not provided, the language's default toolchain is returned.

func (*Language) GetToolchains

func (lang *Language) GetToolchains() Toolchains

GetToolchains returns the toolchains setup instance for this language.

func (*Language) IsLanguageFile

func (lang *Language) IsLanguageFile(aPath string) bool

IsLanguageFile returns true if the provided filePath is recognized as either a source or a test file for this language

func (*Language) IsSrcFile

func (lang *Language) IsSrcFile(aPath string) bool

IsSrcFile returns true if the provided filePath is recognized as a source file for this language

func (*Language) IsTestFile

func (lang *Language) IsTestFile(aPath string) bool

IsTestFile returns true if the provided filePath is recognized as a test file for this language

type Toolchains

type Toolchains struct {
	Default    string
	Compatible []string
}

Toolchains defines the structure for toolchains related to a language

Jump to

Keyboard shortcuts

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