internal/lsp/analysis: move implementmissing logic into undeclared
I missed the TODO in undeclaredname to add support for functions, so
really this belongs in that analyzer. This removes a fair bit of code.
However, the type error analyzers don't really work with the go/analysis
testing framework because the suggested fixes are split from the
diagnostics, so I moved the tests into the gopls tests.
Change-Id: I861a7ad531d2732fe698ee0ac46f23ad53b16812
Reviewed-on: https://go-review.googlesource.com/c/tools/+/351333
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/internal/lsp/source/api_json.go b/internal/lsp/source/api_json.go
index b78b57d..59eb437 100755
--- a/internal/lsp/source/api_json.go
+++ b/internal/lsp/source/api_json.go
@@ -562,11 +562,6 @@
Default: "true",
},
{
- Name: "\"implementmissing\"",
- Doc: "suggested fixes for \"undeclared name: %s\" on a function call\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: %s\" that happen for a function call. For example:\n\tfunc m() {\n\t a(1)\n\t}\nwill turn into\n\tfunc m() {\n\t a(1)\n\t}\n\n\tfunc a(i int) {}\n",
- Default: "false",
- },
- {
Name: "\"nonewvars\"",
Doc: "suggested fixes for \"no new vars on left side of :=\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"no new vars on left side of :=\". For example:\n\tz := 1\n\tz := 2\nwill turn into\n\tz := 1\n\tz = 2\n",
Default: "true",
@@ -578,7 +573,7 @@
},
{
Name: "\"undeclaredname\"",
- Doc: "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will insert a new statement:\n\"<> := \".",
+ Doc: "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will either insert a new statement,\nsuch as:\n\n\"<> := \"\n\nor a new function declaration, such as:\n\nfunc <>(inferred parameters) {\n\tpanic(\"implement me!\")\n}\n",
Default: "true",
},
{
@@ -1140,11 +1135,6 @@
Default: true,
},
{
- Name: "implementmissing",
- Doc: "suggested fixes for \"undeclared name: %s\" on a function call\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: %s\" that happen for a function call. For example:\n\tfunc m() {\n\t a(1)\n\t}\nwill turn into\n\tfunc m() {\n\t a(1)\n\t}\n\n\tfunc a(i int) {}\n",
- Default: false,
- },
- {
Name: "nonewvars",
Doc: "suggested fixes for \"no new vars on left side of :=\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"no new vars on left side of :=\". For example:\n\tz := 1\n\tz := 2\nwill turn into\n\tz := 1\n\tz = 2\n",
Default: true,
@@ -1156,7 +1146,7 @@
},
{
Name: "undeclaredname",
- Doc: "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will insert a new statement:\n\"<> := \".",
+ Doc: "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will either insert a new statement,\nsuch as:\n\n\"<> := \"\n\nor a new function declaration, such as:\n\nfunc <>(inferred parameters) {\n\tpanic(\"implement me!\")\n}\n",
Default: true,
},
{