internal/lsp/source: small fixes to directory filters

Add missing newlines in documentation, and allow trailing slashes in the
filter expressions.

Change-Id: I90106b209222d8cc542e3517c6ff6edb2569243d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/308453
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Heschi Kreinick 2021-04-08 14:33:27 -04:00
parent b261fe9609
commit be791d07ff
3 changed files with 8 additions and 2 deletions

View File

@ -63,8 +63,11 @@ the last filter that applies to a path controls whether it is included.
The path prefix can be empty, so an initial `-` excludes everything.
Examples:
Exclude node_modules: `-node_modules`
Include only project_a: `-` (exclude everything), `+project_a`
Include only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`
Default: `[]`.

View File

@ -34,7 +34,7 @@ var GeneratedAPIJSON = &APIJSON{
{
Name: "directoryFilters",
Type: "[]string",
Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\nExclude node_modules: `-node_modules`\nInclude only project_a: `-` (exclude everything), `+project_a`\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n",
Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\n\nExclude node_modules: `-node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n",
EnumKeys: EnumKeys{
ValueType: "",
Keys: nil,

View File

@ -213,8 +213,11 @@ type BuildOptions struct {
// The path prefix can be empty, so an initial `-` excludes everything.
//
// Examples:
//
// Exclude node_modules: `-node_modules`
//
// Include only project_a: `-` (exclude everything), `+project_a`
//
// Include only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`
DirectoryFilters []string
@ -747,7 +750,7 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
result.errorf("invalid filter %q, must start with + or -", filter)
return result
}
filters = append(filters, filepath.FromSlash(filter))
filters = append(filters, strings.TrimRight(filepath.FromSlash(filter), "/"))
}
o.DirectoryFilters = filters
case "completionDocumentation":