Documentation ¶
Overview ¶
Package glob implements an LSP-compliant glob pattern matcher for testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Glob ¶
type Glob struct {
// contains filtered or unexported fields
}
A Glob is an LSP-compliant glob pattern, as defined by the spec: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentFilter
NOTE: this implementation is currently only intended for testing. In order to make it production ready, we'd need to:
- verify it against the VS Code implementation
- add more tests
- microbenchmark, likely avoiding the element interface
- resolve the question of what is meant by "character". If it's a UTF-16 code (as we suspect) it'll be a bit more work.
Quoting from the spec: Glob patterns can have the following syntax:
- `*` to match one or more characters in a path segment
- `?` to match on one character in a path segment
- `**` to match any number of path segments, including none
- `{}` to group sub patterns into an OR expression. (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files)
- `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
- `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
Expanding on this:
- '/' matches one or more literal slashes.
- any other character matches itself literally.
func Parse ¶
Parse builds a Glob for the given pattern, returning an error if the pattern is invalid.
Click to show internal directories.
Click to hide internal directories.