parsers

package
v0.0.0-...-b95a7b5 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

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

func ParseSassImports(source string) []string

ParseSassImports takes the contents of a Sass source file and extracts the verbatim paths of any imported modules.

func ParseTSImports

func ParseTSImports(source string) []string

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.

Jump to

Keyboard shortcuts

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