Documentation ¶
Overview ¶
Package parsers defines parsers for the paths of "import" statements found in TypeScript and Sass files.
The ad-hoc parsers in this package utilize regular expressions to extract out import paths, filter out comments, etc. While these parsers do not capture every aspect of the TypeScript and Sass grammars, they are sufficient for the purpose of parsing the import statements in the TypeScript and Sass files found in our codebase.
The following alternatives were ruled out because of their high implementation and maintenance cost:
- Using third-party parsers written in Go (none exist at this time).
- Generate real parsers using e.g. Goyacc (https://pkg.go.dev/golang.org/x/tools/cmd/goyacc).
- Use the TypeScript compiler API to inspect the AST of a TypeScript file (requires calling Node.js code from Gazelle).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseSassImports ¶
ParseSassImports takes the contents of a Sass source file and extracts the verbatim paths of any imported modules.
func ParseTSImports ¶
ParseTSImports takes the contents of a TypeScript source file and extracts the verbatim paths of any imported modules. Import statements ending with a "gazelle:ignore" comment are ignored.
Types ¶
This section is empty.