Unreviewed changes
2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: gopls/internal/test/marker/testdata/mcptools/file_diagnostics.txt
Insertions: 3, Deletions: 0.
@@ -3,8 +3,11 @@
Some diagnostics from the "printf" analyzer carry fixes, and those fixes have edits.
(Not all fixes have edits; some analyzers rely on gopls to compute them lazily.)
+The printf analyzer only reports a fix in files using >= go1.24.
+
-- flags --
-mcp
+-min_go_command=go1.24
-- settings.json --
{
```
Change information
Commit message:
go/analysis/passes/inline: add lazy-fix mode for gopls
Computation of inliner fixes can be expensive due to its
(unnecessary) strategy of formatting and parsing the file
repeatedly. Rather than fix that right now, this CL makes
the computation of fixes lazy when the analyzer is running
within gopls. An undocumented analyzer flag, set by gopls'
init, causes the analyzer to return an empty list of edits,
which triggers gopls to compute the edits lazily based on
the Diagnostic.Category string. As luck would have it, we
already have a lazy fix in place for the refactor.inline.call
Code Action, so we simply use that name again for the Category.
The change broke an MCP test that assumed that the inline
analyzer's fixes carry edits. There is a TODO in the
MCP code not to rely on this assumption, but rather than
do it, I rewrote the test to use the printf analyzer
instead.
For golang/go#75773
Change-Id: I5388e472e841cb23351fb9e90d8d7721dae3df07
Files:
- M go/analysis/passes/inline/inline.go
- M gopls/internal/golang/fix.go
- M gopls/internal/settings/analysis.go
- M gopls/internal/test/marker/testdata/mcptools/file_diagnostics.txt
- M internal/refactor/inline/inline.go
Change size: M
Delta: 5 files changed, 132 insertions(+), 98 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Robert Findley
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI