-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x/tools/gopls: implement struct field generation quickfix
- Loading branch information
1 parent
e426616
commit 1675eb9
Showing
7 changed files
with
510 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ upgrading a module dependency. | |
|
||
## Go command compatibility: the 2 most recent major Go versions | ||
|
||
The [email protected] releases will be the final versions of gopls to nominally | ||
The <[email protected]> releases will be the final versions of gopls to nominally | ||
support integrating with more than the 2 most recent Go releases. In the past, | ||
we implied "best effort" support for up to 4 versions, though in practice we | ||
did not have resources to fix bugs that were present only with older Go | ||
|
@@ -169,7 +169,7 @@ constructor of the type of each symbol: | |
`interface`, `struct`, `signature`, `pointer`, `array`, `map`, `slice`, `chan`, `string`, `number`, `bool`, and `invalid`. | ||
Editors may use this for syntax coloring. | ||
|
||
## SignatureHelp for ident and values. | ||
## SignatureHelp for ident and values | ||
|
||
Now, function signature help can be used on any identifier with a function | ||
signature, not just within the parentheses of a function being called. | ||
|
@@ -196,3 +196,24 @@ causing `Add` to race with `Wait`. | |
(This check is equivalent to | ||
[staticcheck's SA2000](https://staticcheck.dev/docs/checks#SA2000), | ||
but is enabled by default.) | ||
|
||
## Add test for function or method | ||
|
||
If the selected chunk of code is part of a function or method declaration F, | ||
gopls will offer the "Add test for F" code action, which adds a new test for the | ||
selected function in the corresponding `_test.go` file. The generated test takes | ||
into account its signature, including input parameters and results. | ||
|
||
Since this feature is implemented by the server (gopls), it is compatible with | ||
all LSP-compliant editors. VS Code users may continue to use the client-side | ||
`Go: Generate Unit Tests For file/function/package` command which utilizes the | ||
[gotests](https://github.com/cweill/gotests) tool. | ||
|
||
## Generate missing struct field from access | ||
|
||
When you attempt to access a field on a type that does not have the field, | ||
the compiler will report an error like “type X has no field or method Y”. | ||
Gopls now offers a new code action, “Declare missing field of T.f”, | ||
where T is the concrete type and f is the undefined field. | ||
The stub field's signature is inferred | ||
from the context of the access. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.