Граф коммитов

542 Коммитов

Автор SHA1 Сообщение Дата
Robert Findley 5210e0ca15 gopls: wire in LangVersion and ModulePath for gofumpt formatting
If available, pass the LangVersion and ModulePath provided by
go/packages to gofumpt. This allows gofumpt to apply additional
formatting rules that require this information.

Also add a regression test for gofumpt formatting.

Fixes golang/go#51327

Change-Id: I47c8c96d595d62e1c444285ce69ce6a4e61fa74c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/387634
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-24 18:08:50 +00:00
Robert Findley 258e473066 internal/lsp/source: disable the useany analyzer by default
This analyzer was written at a time when any was only allowed in
constraints, and usage of any vs interface{} was more likely to be
confusing.

Any is now allowed anywhere, and so it is inconsistent to suggest it
only for constraints. However, we can't suggest any over interface{}
everywhere, as that would be incredibly noisy.

Perhaps we should remove this analyzer, but for now simply change it to
off by default.

Change-Id: Ib9726bdb835808d69827c6cd8e4a58dc5d83ad0e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/387614
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-02-23 15:44:43 +00:00
Daniel Martí 4f21f7a508 gopls: update gofumpt to v0.3.0
Also add a TODO inside the format.Options expression,
as we are not currently wiring up some information from the main go.mod.
The TODO comment contains a summary of what should be done.

Change-Id: Ibace6c36de4b729b5ba8b347f6f48f0a8fda695e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/387374
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-23 14:43:16 +00:00
Robert Findley fd59bdfe0d internal/lsp/source: adjust object position when formatting full AST
Thread through an adjusted object position when we format an re-parsed
AST that wasn't type-checked to produce the object. Also remove some
unnecessary handling of the object type.

Fixes golang/go#46158

Change-Id: Ic8bee2bb4cb992d577d085599213fca1deab3b4e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/384697
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-17 17:37:03 +00:00
Marwan Sulaiman 70c3ea29e2 gopls,internal/lsp: Implement method stubbing via CodeAction
This CL adds a quickfix CodeAction that detects "missing method"
compiler errors and suggests adding method stubs to the concrete
type that would implement the interface. There are many ways that
a user might indicate a concrete type is meant to be used as an interface.
This PR detects two types of those errors: variable declaration and function returns.
For variable declarations, things like the following should be detected:
1. var _ SomeInterface = SomeType{}
2. var _ = SomeInterface(SomeType{})
3. var _ SomeInterface = (*SomeType)(nil)
For function returns, the following example is the primary detection:
func newIface() SomeInterface {
	return &SomeType{}
}
More detections can be added in the future of course.

Fixes golang/go#37537

Change-Id: Ibb7784622184c9885eff2ccc786767682876b4d3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274372
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-16 19:42:34 +00:00
Nooras Saba 2ff4db7dab go/analysis/passes/tests: Check malformed fuzz target.
This will validate that first letter after FuzzFoo() should be uppercase
Also, following validation will be performed for f.Fuzz() calls :
	1. f.Fuzz() should call a function and it should be of type (*testing.F).Fuzz().
	2. The called function in f.Fuzz(func(){}) should not return result.
	3. First argument of func() should be of type *testing.T
	4. Second argument onwards should be of type []byte, string, bool, byte,
	   rune, float32, float64, int, int8, int16, int32, int64, uint, uint8, uint16,
	   uint32, uint64

For golang/go#50198

Change-Id: I540daf635f0fe03d954b010b9b5f8616fd5df47a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/374495
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Peter Weinberger <pjw@google.com>
2022-02-16 18:26:19 +00:00
Michael Matloob be40034de7 internal/lsp: add support for formatting go.work files
Wired through support for calling x/mod's go.work formatter on go.work
files into LSP. Tested it by hand in editor using the "Format Document"
command. Added a test case to workspace_test regtest, though I'm not
totally sure the test is correct.

For golang/go#50930

Change-Id: Ied052ded514bb36f561737698f0e2d7b488158e7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383774
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-15 17:15:32 +00:00
Heschi Kreinick c0b9fb59f7 internal/lsp/analysis/undeclaredname: suppress impossible quick fixes
Reading the code and running the tests, it appears we only support quick
fixes for undeclared name errors inside function bodies. Don't offer
them in other places.

The specific situation raised was type constraints, so that's what I
tested even though the problem was much broader. Also add actual error
messages where we had empty strings.

Fixes golang/go#50935.

Change-Id: I8dadcb6e4301bf22cbe7fe5d66064aafeef02690
Reviewed-on: https://go-review.googlesource.com/c/tools/+/384117
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-09 19:35:26 +00:00
Heschi Kreinick 164402db9d internal/lsp/cache: set types.Config.GoVersion
Set the language version from the controlling go.mod file's go version,
if any. Also verify that we properly surface a diagnostic if the version
is invalid.

I didn't add any quick fixes.

Fixes golang/go#50688.

Change-Id: Ic472502d1224a1decb5b989d51110b837020e998
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383394
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-07 18:19:30 +00:00
Heschi Kreinick 414ec9c3f0 internal/lsp: add ListImports
The VS Code extension uses information about imports to figure out
whether a given function is a Testify test. As of writing, it asks:
- Does the file import Testify?
- Does the package it's in do so?
To answer these questions, add ListImports, which tells you about the
packages imported by the current file, including their import name,
plus the import paths of all imports in the entire package.

I suspect the latter may be wrong in the presence of GOPATH vendoring,
but that should be a relatively rare situation at this point so I didn't
bother testing.

Fixes golang/go#40514.

Change-Id: I4c69e1db80dce6e594bdb595a81aade1ddec4d29
Reviewed-on: https://go-review.googlesource.com/c/tools/+/383354
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 22:09:29 +00:00
David Chase d55d8929fe gopls/doc: how to request a particular gopls w/ sublime text
I needed to do this to get a generics-capable version of gopls,
because sublime LSP downloads and installs its own.  Other
people may also need to do this, now or in the future, and it
was a pain to figure out the exact incantation.

Change-Id: I360b7ee9438a2c6588f55745aa1d6f3a47ddd2fc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382794
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-02-04 21:02:33 +00:00
Robert Findley cf66aec62b gopls: update coc.nvim documentation for using go.work
For golang/go#50955

Change-Id: Idab88d258ceab3312adccd97eb58ed64e5fb5053
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382242
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:04:20 +00:00
Robert Findley 597b165f5f internal/lsp/cache: use -workfile on 1.18
When using go 1.18 with go.work files, don't fake workspaces by creating
a workspace module: just run from the workspace root and pass -workfile.

For golang/go#44696

Change-Id: Iaa1979d26b1ce67c6e18e0bf26546a504069da8c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382241
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:03:59 +00:00
Robert Findley 3e30e21b53 gopls: remove the workspace_metadata command
Remove the workspace_metadata command, as VS Code no longer needs this
to run workspace commands (it can use go.work instead).

Updates golang/go#44696

Change-Id: Ife579a15e64969c4301e4508e18b7c8a8b633b9f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382235
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:02:58 +00:00
Robert Findley 25d2ab26ce internal/lsp/cache: fixes for workspace invalidation
This CL fixes a several bugs in workspace invalidation:
 - When invalidating the workspace due to a change in gopls.mod or
   go.work files, we should not update the workspace if the change does
   not parse. There was a comment to this effect, but it was not
   properly implemented.
 - Check go.work before gopls.mod, consistent with our intitial
   workspace load.
 - If we get an 'unchanged' change (such as a save) to go.work, don't
   continue looking for gopls.mod.

A regression test that inadvertently relied on our mishandling of broken
go.work files is updated to have the correct syntax. A new regtest
expectation is added to assert on a clean workspace.

For golang/go#44696

Change-Id: I2b7e739573e225cadfbf8cc892a0b5daf0191e40
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382115
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:02:15 +00:00
Robert Findley 77f5fa5142 internal/lsp/cache: replace old go.work parser with x/mod
Gopls was using an old version of workfile support in x/mod that did not
support the 'use' syntax.

Upgrade to x/mod@master, and update tests accordingly.

For golang/go#44696

Change-Id: I87841cd1322d7b1aa0fbc929838746ea600bee77
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382078
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04 14:01:19 +00:00
pjw c009ab4a1f internal/lsp/completion: the inserted text should be what is shown to the user
CompletionItem.Label is what is shown to the user. Unless InsertText is
overridden by there being a TextEdit, InsertText should be the same
as Label.

Change-Id: I200739fbdfca19aa33154d5391b3ebcc79dd7af5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382243
Run-TryBot: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-03 15:40:54 +00:00
Robert Findley eeb95ae5ed gopls: make 'fastfuzzy' the default fuzzy matcher for workspace symbols
For dense queries, the fastfuzzy matcher is around 3x faster. It also
has improved scoring for exact matches of CamelCase words or path
segments.

Fixes golang/go#50016

Change-Id: I04cae11cbc54de59d54733836876a9ee759c80b6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382394
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
2022-02-03 14:26:36 +00:00
pjw 461d130035 internal/lsp: include receiver type parameters when completing receivers
In
type SyncMap[K comparable, V any] struct {}
func (s *Syn
Syn sould be completed as SyncMap[K, V], as the type parameters
are required for receivers by the language definition.

fixes golang/go#50684

Change-Id: I6946d41c49df8bbd336225718c36e3c17dde0b6f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380354
Trust: Peter Weinberger <pjw@google.com>
Run-TryBot: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Muir Manders <muir@mnd.rs>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-02-01 13:36:13 +00:00
Robert Findley 263785d774 gopls: update dependencies post-release
This breaks the build at Go 1.12, as documented in golang/go#50827.

Fixes golang/go#50827

Change-Id: Ic7c122757e53981c5ee8f7fdf74fe276895717f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380555
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-01-31 22:10:16 +00:00
Robert Findley 8e9bdc58e5 gopls: document that v0.7.5 is the final version to support Go 1.12
For golang/go#50827

Change-Id: Ib59aa4431dcc492db9436c19f43872781679f789
Reviewed-on: https://go-review.googlesource.com/c/tools/+/382075
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-31 21:11:00 +00:00
Hana 492cf3ac49 doc: update the instruction to use beta2
And include the link to the milestone and a known issue

Change-Id: Iaae07cdf1a533da44fd15e0692b29e4173ed879f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381016
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-31 20:30:41 +00:00
pjw fe74b5f080 internal/template: return available semantic tokens even on template error
Fixes golang/go#50801

Change-Id: Ic5c541d6244bd56b90bee204be7c2b2fdfa90264
Reviewed-on: https://go-review.googlesource.com/c/tools/+/381014
Run-TryBot: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-26 20:10:56 +00:00
pjw 772a39974b internal/template: return a Source with template diagnostics
Template diagnostics now return Soure 'template' instead of no Source.

Fixes golang/go#50786

Change-Id: Ifd7f26ffcee238b7168667c259c6b0006f8c03e6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380974
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Trust: Peter Weinberger <pjw@google.com>
2022-01-26 16:53:13 +00:00
Bryan C. Mills c20fd7c261 internal/lsp/regtest: eliminate arbitrary timeouts
We care that gopls operations complete within a reasonable time.
However, what is “reasonable” depends strongly on the specifics of the
user and the hardware they are running on: a timeout that would be
perfectly reasonable on a high-powered user workstation with little
other load may be far too short on an overloaded and/or underpowered
CI builder.

This change adjusts the regtest runner to use the test deadline
instead of an arbitrary, flag-defined timeout; we expect the user or
system running the test to scale the test timeout appropriately to the
specific platform and system load.

When the testing package gains support for per-test timeouts
(golang/go#48157), this approach will automatically apply those
timeouts too.

If we decide that we also want to test specific performance and/or
latency targets, we can set up specific configurations for that (as
either aggressive per-test timeouts or benchmarks) in a followup
change.

For golang/go#50582

Change-Id: I1ab11b2049effb097aa620046fe11609269f91c4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380497
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-25 21:51:33 +00:00
Bryan C. Mills 135972eb89 gopls/internal/regtest/codelens: use the test's deadline instead of a hard-coded timeout
We may want to generalize this to have regtest.Run always derive the
default timeout from the test's deadline. In the meantime, this is a
more targeted fix for the specific timeout in TestGCDetails.

Fixes golang/go#49902
(Maybe.)

Change-Id: Ie15735dc7b0d462ec047d3f3d8a2eceeb4411fa0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380496
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-24 16:28:24 +00:00
Bryan C. Mills 342596760e gopls/internal/regtest/workspace: temporarily skip TestWatchReplaceTargets
This test has a high failure rate on the builders, and the failures
appear to be mostly platform-independent. This change skips the test
until the failures can be diagnosed and fixed.

For golang/go#50748

Change-Id: Iadfda7345f3dcbafa61338469aa6dc45e1d85a49
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380215
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-21 21:08:53 +00:00
Bryan C. Mills ab35822fb7 gopls/internal/regtest/completion: temporarily skip TestPostfixSnippetCompletion
TestPostfixSnippetCompletion appears to produce racy writes to the
filesystem, and the failure mode does not seem to be
platform-specific. This skips the test to reduce noise until someone
has the time to investigate in more depth.

For golang/go#50707

Change-Id: I31c3aaf0cdb92ae2323cc8a926d3775d1433a9ff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/379735
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-20 14:52:25 +00:00
Robert Findley a71de3f351 gopls/doc: fix inconsistent rendering of enum newlines
We have inconsistent rendering of newlines in enums, as pointed out in
CL 314189 (that change edited the markdown directly, which won't work).

Change-Id: Ie39b80fe65287bd447d18cacdaea60b24b4bd08f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/369957
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-19 15:07:38 +00:00
Robert Findley 21ca3b3a93 internal/lsp/source: parse symbol queries when using fastfuzzy
Hook up the fastfuzzy symbol matcher to our fzf-style query parsing, for
consistency with the (slow) fuzzy matcher.

In the past I had wanted to implement this natively inside the
SymbolMatcher, but it is much simpler to keep using combinators. In the
common case we'll just be using fuzzy matching.

For golang/go#50016

Change-Id: I1c62c8c8e9d29da570cb1e4034c2b10782529081
Reviewed-on: https://go-review.googlesource.com/c/tools/+/376362
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
2022-01-19 15:06:07 +00:00
Robert Findley 3737ecd836 internal/lsp/fuzzy: consider whole word matching in SymbolMatcher
In the new SymbolMatcher, add an additional scoring feature that
considers whether the matching pattern streak is part of a whole-word
match. This differentiates matches of "foo" against "pkg.foo" and
"pkg.foobar".

For golang/go#50016

Change-Id: Ib84ff13eee0b7ec23143325592cef9a41be07375
Reviewed-on: https://go-review.googlesource.com/c/tools/+/376361
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-19 15:05:25 +00:00
Russ Cox fddb0d54e9 internal/lsp/analysis/noresultvalues: update for CL 379116 error message change
CL 379116 changes the format of the error this checker is looking for.
Update it to handle both the old and new form.

Change-Id: I91668e4fcbe203a9028d07b780fd17e9758fc838
Reviewed-on: https://go-review.googlesource.com/c/tools/+/379174
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-18 21:28:05 +00:00
Robert Findley 7424a4db47 internal/lsp/cache: fix check for excluded paths in locateTemplateFiles
The pathExcludedByFilter helper function expects path to be relative to
the workspace folder. This is a confusing API, and led to us passing
absolute paths when checking for excluded template files.

Fix it, add a regtest, and add a TODO to clean up the API.

Fixes golang/go#50431

Change-Id: Iedcf0dd9710e541c9fb8c296d9856a13ef3fbcb6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/378398
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-14 17:01:02 +00:00
Robert Findley a222cdb107 gopls/internal/regtest: add regression tests for template diagnostics
Add some additional regressions tests for our loading of templates based
on language ID and/or the configured templateExtensions. Move these
tests to a new regtest package "templates", so that they may be easily
run together.

Fixes golang/vscode-go#1957

Change-Id: Ic83454725e9aec41b3c1f5202bb68d97cc73c839
Reviewed-on: https://go-review.googlesource.com/c/tools/+/378394
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
2022-01-13 20:57:08 +00:00
Robert Findley c4cfc425f2 gopls: change the default value for templateExtensions to be empty
There is no standard for go template file extensions, and users may not
want this functionality. Make template support opt-in by changing the
default value of templateExtensions to be [].

Updates golang/vscode-go#1957

Change-Id: I7e37d22b1bc63d8300634b3b0394b4036b43fa49
Reviewed-on: https://go-review.googlesource.com/c/tools/+/375874
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-13 20:56:24 +00:00
Robert Findley 0a91d41f6f internal/lsp/source: sort workspace symbol results for stability
Add additional order invariants to workspace symbol results to
differentiate between items of equal score: sort next by symbol length,
and then finally by lexical ordering.

For golang/go#50016

Change-Id: Ic5cda2628f57cecfe972b7585525c49b0f8518bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/376360
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
2022-01-11 13:58:16 +00:00
A_D eb07148636 gopls: add string join/split postfix completions
This adds two new snippets, centred around string manipulation.

The first snippet applies to variables of type string, and is called
split. When used, it replaces `someStringVar.split!` with
`strings.Split(someStringVar, "|")`, where `|` indicates the location of
the cursor.

The second snippet is essentially the same as the first, but in
"reverse". Meaning that rather than going from a string to a slice of
strings, it goes from a slice of strings to a single string:
`someStringSlice.join!` -> `strings.Join(someStringSlice, "|")`.

Change-Id: I0e303a39766463034687f76a5d9dbab419e2021b
GitHub-Last-Rev: 935cc418e7
GitHub-Pull-Request: golang/tools#347
Reviewed-on: https://go-review.googlesource.com/c/tools/+/362474
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-01-11 13:55:59 +00:00
Robert Findley f234b3d4ab internal/lsp/source: keep collecting symbols on metadata errors
Workspace symbols requests fail when a file in the workspace is missing
metadata, such as if a build-tagged file is open in an overlay. We keep
going if metadata is missing, but not on metadata errors (such as
packages.Load errors).

Change this to log and keep going on errors.

Fixes golang/go#50536

Change-Id: I41331e864bf21e4f39674248bc30bfc02a4c3d1d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/377234
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
2022-01-10 19:19:50 +00:00
Bryan C. Mills 778a20b1a0 x/tools/gopls/internal/regtest/modfile: skip TestUnknownRevision and MultiModule tests on plan9
For golang/go#50477
For golang/go#50478

Change-Id: If2a9d175c06446db70628a21a1552e32239627c1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/375876
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-07 05:33:44 +00:00
Kir Kolyshkin d4d432564f gopls: remove obsoleted text from README
CL 358074 changed "go get" to "go install", but forgot to remove the
sentence telling to not use "-u" flag.

As "go install" does not support "-u", the leftover sentence is both
useless and misleading. Remove it.

Updates golang/go#49114

Change-Id: Iec584ae1ea5eb50eb203af48da46bb2ca9e30fc8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/375774
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Trust: Nooras Saba‎ <saba@golang.org>
2022-01-06 15:23:01 +00:00
Jonathan Amsterdam 8d383106f7 gopls/doc: use improved code generator for API doc
Use github.com/jba/printsrc in place of github.com/sanity-io/litter to
generate the Go code with API documentation. It is smart enough
to elide type names, making the "massive hack" of deleting them
unnecessary. It also omits zero values from the output.

Change-Id: Ic1bb937b9a3695e6da6db72b74c6049be1c5b80d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/370840
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-16 11:15:33 +00:00
Robert Findley c6ae451aec gopls/doc: add some commentary on editor configuration for templates
Change-Id: I3d9298f4f033a86e52419ac2187ecc5e69e7f9d6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/372255
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-12-15 16:50:15 +00:00
Robert Findley cd2143c081 gopls/doc: update instructions for generics following the beta
Change-Id: Id163d51dfd3fc7583457792714398529a0a12dd7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/372254
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-15 16:03:37 +00:00
Akhil cadd57e399 docs: updated nvim-lspconfig link
This PR updates the link of nvim-lspconfig doc for gopls.

Change-Id: I9f64ca9c310af8a6c6392245c88eea666edf4657
GitHub-Last-Rev: 9774e504c7
GitHub-Pull-Request: golang/tools#351
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367254
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-08 15:21:23 +00:00
Shoshin Nikita feb39d0cd7 internal/lsp/source: don't format generated files
Fixes golang/go#49555

Change-Id: I53e3c0d34be6a545386d6766371fbeda8a2b2ffb
GitHub-Last-Rev: 5161687656
GitHub-Pull-Request: golang/tools#349
Reviewed-on: https://go-review.googlesource.com/c/tools/+/365295
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-06 16:11:25 +00:00
Robert Findley c882a49eac gopls/doc: fix rendering of example for the infertypeargs analyzer
Fixes golang/go#49774

Change-Id: I10d2ebd9d831325e0ede73cf11ff30b2adfb744d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367844
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-12-03 18:55:11 +00:00
Robert Findley f64c0f46fa internal/lsp/analysis/fillreturns: update fillreturns for new type errs
The error messages produced by go/types related to an incorrect number
of return values have changed, and have been repositioned. Update the
fillreturns analyzer to handle the Go 1.18 form of these errors.

Ideally we'd use error codes here, but can't because they are not
forwarded by go/packages. Added a TODO to revisit when error codes are
exposed.

Change-Id: I4c594fd2fd1cb7423f37ff9c6a57e9490dcbc2a4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367714
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
2021-12-03 18:55:02 +00:00
Bryan C. Mills 3c63f30840 gopls/internal/regtest/misc: temporarily skip TestGenerateProgress
For golang/go#49901

Change-Id: Id41c6437fadf1c539488662fc0ca5bc746b8a498
Reviewed-on: https://go-review.googlesource.com/c/tools/+/368216
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-12-01 18:47:44 +00:00
Robert Griesemer 6e52f51f5b x/tools: temporarily skip a couple of tests
Skip tests so we can get CL 367196 submitted. After that
reenable tests (and adjust as needed).

Change-Id: Id0a6d6b873a0760ae438f6f0cb147c20d00b1ca6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/367574
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-29 20:12:13 +00:00
Peter Weinberger 1e71a25a93 gopls: template suffix flags and documentation
Adds 'templateExtensions' (with default ["tmpl", "gotmpl"]) to control
which files gopls considers template files.

Adds template support documentation to features.md.

Fixes golang/go#36911

Change-Id: If0920912bf3748d1c231b3b29e7a008da186bede
Reviewed-on: https://go-review.googlesource.com/c/tools/+/363360
Run-TryBot: Peter Weinberger <pjw@google.com>
Trust: Peter Weinberger <pjw@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2021-11-23 16:39:20 +00:00