Skip to content

Commit

Permalink
gopls/doc/generate: add status in codelenses and inlayhints
Browse files Browse the repository at this point in the history
Features configurable through map[K]V can not be marked as
experimental. To comply with deprecation guideline, this CL
introduces a per key and per value status where gopls can
mark a specific key or a specific value as experimental.

The status can be indicated by the comment directives as part
of the doc comment. The status can be delcared following
pattern "//gopls:status X" very similar to struct tag.

This clarifies the question: if "codelenses" is a released feature,
are all enum keys configurable in "codelenses" are also released
feature?

VSCode-Go CL 652357

Change-Id: I4ddc5155751452d5f7b92bbb3610aa61680a29a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/652356
Auto-Submit: Hongxiang Jiang <hxjiang@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
h9jiang authored and gopherbot committed Mar 5, 2025
1 parent 340f21a commit ece9e9b
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 230 deletions.
4 changes: 4 additions & 0 deletions gopls/doc/codelenses.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ File type: Go

## `run_govulncheck`: Run govulncheck (legacy)

**This setting is experimental and may be deleted.**


This codelens source annotates the `module` directive in a go.mod file
with a command to run Govulncheck asynchronously.
Expand Down Expand Up @@ -134,6 +136,8 @@ File type: go.mod

## `vulncheck`: Run govulncheck

**This setting is experimental and may be deleted.**


This codelens source annotates the `module` directive in a go.mod file
with a command to run govulncheck synchronously.
Expand Down
95 changes: 0 additions & 95 deletions gopls/internal/analysis/gofix/directive.go

This file was deleted.

3 changes: 2 additions & 1 deletion gopls/internal/analysis/gofix/gofix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"golang.org/x/tools/go/types/typeutil"
"golang.org/x/tools/gopls/internal/util/moreiters"
"golang.org/x/tools/internal/analysisinternal"
internalastutil "golang.org/x/tools/internal/astutil"
"golang.org/x/tools/internal/astutil/cursor"
"golang.org/x/tools/internal/astutil/edge"
"golang.org/x/tools/internal/diff"
Expand Down Expand Up @@ -598,7 +599,7 @@ func currentFile(c cursor.Cursor) *ast.File {
// hasFixInline reports the presence of a "//go:fix inline" directive
// in the comments.
func hasFixInline(cg *ast.CommentGroup) bool {
for _, d := range directives(cg) {
for _, d := range internalastutil.Directives(cg) {
if d.Tool == "go" && d.Name == "fix" && d.Args == "inline" {
return true
}
Expand Down
8 changes: 6 additions & 2 deletions gopls/internal/doc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ type EnumKey struct {
Name string // in JSON syntax (quoted)
Doc string
Default string
Status string // = "" | "advanced" | "experimental" | "deprecated"
}

type EnumValue struct {
Value string // in JSON syntax (quoted)
Doc string // doc comment; always starts with `Value`
Value string // in JSON syntax (quoted)
Doc string // doc comment; always starts with `Value`
Status string // = "" | "advanced" | "experimental" | "deprecated"
}

type Lens struct {
Expand All @@ -60,6 +62,7 @@ type Lens struct {
Title string
Doc string
Default bool
Status string // = "" | "advanced" | "experimental" | "deprecated"
}

type Analyzer struct {
Expand All @@ -73,4 +76,5 @@ type Hint struct {
Name string
Doc string
Default bool
Status string // = "" | "advanced" | "experimental" | "deprecated"
}
Loading

0 comments on commit ece9e9b

Please sign in to comment.