Documentation ¶
Index ¶
- func Names() []string
- func Register(lang LangInterface) error
- func Reset(name string)
- type FileTreeFilter
- type LangInterface
- type Language
- func (lang *Language) AllSrcFiles() (result []string, err error)
- func (lang *Language) AllTestFiles() (result []string, err error)
- func (lang *Language) DirsToWatch(baseDir string) (dirs []string)
- func (lang *Language) GetName() string
- func (lang *Language) GetSrcFileFilter() FileTreeFilter
- func (lang *Language) GetTestFileFilter() FileTreeFilter
- func (lang *Language) GetToolchain(toolchainName string) (tchn toolchain.TchnInterface, err error)
- func (lang *Language) GetToolchains() Toolchains
- func (lang *Language) IsLanguageFile(aPath string) bool
- func (lang *Language) IsSrcFile(aPath string) bool
- func (lang *Language) IsTestFile(aPath string) bool
- type Toolchains
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
Types ¶
type FileTreeFilter ¶
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 ¶
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 ¶
AllTestFiles returns the list of test files for this language.
func (*Language) DirsToWatch ¶
DirsToWatch returns the list of directories that TCR engine needs to watch for this language
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 ¶
IsLanguageFile returns true if the provided filePath is recognized as either a source or a test file for this language
func (*Language) IsSrcFile ¶
IsSrcFile returns true if the provided filePath is recognized as a source file for this language
func (*Language) IsTestFile ¶
IsTestFile returns true if the provided filePath is recognized as a test file for this language
type Toolchains ¶
Toolchains defines the structure for toolchains related to a language