1
0
mirror of https://github.com/golang/go synced 2024-10-01 10:28:31 -06:00
Commit Graph

3747 Commits

Author SHA1 Message Date
Muir Manders
5797d2e298 internal/lsp: add more flexible completion tests
Add a new @completePartial note that does not require you to specify
the full list of completions. This gets rid of a lot of noise when you
just want to test the relative order of some completion candidates but
don't care about all the other candidates in scope.

I changed one existing test to use @completePartial as an example.

Change-Id: I56005405477e562803f094c0cac05ef2b854ad1a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192657
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-10 04:40:04 +00:00
Rebecca Stambler
0673112484 internal/lsp: update to latest version of x/tools
The fix for golang/go#29313 just went in, so update so people can fetch
it more easily.

Change-Id: I60fda011dfdd62d5de429834a6692f6b21074f0d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194377
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-09 21:46:02 +00:00
Michael Matloob
75be6cdcda internal/lsp: enable suggested fixes by default
Remove the wantSuggestedFixes flag, and run the flagged code
by default.

Add test cases for suggested fixes.
Generate a suggested fix to the assign analysis that suggests removing redundant assignments.
Fix the propagation of suggested fixes (using rstambler's code).

Change-Id: I342c8e0b75790518f228b00ebd2979d24338be3b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193265
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-09 19:40:07 +00:00
Rebecca Stambler
dab579b762 internal/lsp: re-enable deep completions and fuzzy matching
CL 193726 accidentally turned off deep completions and fuzzy matching by default.
Re-enabling them now.

Change-Id: Ia120766b3a72243efe9c398c0efd6d1a101d0e7f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194020
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-09 19:15:43 +00:00
Muir Manders
dc339cc7c5 internal/lsp: improve completions in go and defer statements
Improve the existing fix-the-AST code to better identify the
expression following the "go" or "defer" keywords:

- Don't slurp the expression start outside the loop since the
  expression might only have a single token.
- Set expression end to the position after the final token, not the
  position of the final token.
- Track curly brace nesting to properly capture an entire "func() {}"
  expression.
- Fix parent node detection to work when BadStmt isn't first statement
  of block.
- Add special case to detect dangling period, e.g. "defer fmt.". We
  insert phantom "_" selectors like go/parser does to prevent the
  dangling "." from messing up the AST.
- Use reflect in offsetPositions so it updates positions in all node
  types. This code shouldn't be called often, so I don't think
  performance is a concern.

I also tweaked the function snippet code so it properly expands
"defer" and "go" expressions to function calls. It thought it didn't
have to expand since there was already a *ast.CallExpr, but the
CallExpr was faked by us and the source doesn't actually contain the
"()" calling parens.

Note that this does not work for nested go/defer statements. For
example, completions won't work properly in cases like this:

go func() {
  defer fmt.<>
}

I think we can fix this as well with some more work.

Change-Id: I8f9753fda76909b0e3a83489cdea69ad04ee237a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193997
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-09 19:09:43 +00:00
Michael Matloob
61375c9358 go/packages: ignore any go list errors that seem to come from cgo
This may overtrigger if there are errors other than cgo errors in
the output, but in general, we can't parse the errors output by
cgo. Long term, we should fix go list to suppress cgo errors when
run with -e.

Fixes golang/go#33937

Change-Id: Iad7472e41eb9ad1cdee32098649be75764f05521
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192330
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-09 18:32:57 +00:00
Rebecca Stambler
cdebb59945 internal/lsp: remove the GetToken and GetAST functions
Change-Id: Iddbdde5f47a31da9baab6539cd2b5bd858e7f811
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194057
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-09 18:10:35 +00:00
Michael Matloob
27d1b4e4f3 internal/lsp/diff: rewrite ApplyEdits to work with sub-line diffs
This replaces the definition of ApplyEdits to be more like that in
go vet -fix, so that we can apply the results of suggested fixes.

Change-Id: Ib5724139464954e3790bc51ed1edc3ce4b2115ff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193959
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-09 18:07:23 +00:00
zoumo
81ca6dc79c internal/lsp: fixed a bug where GOPROXY was set to GOROOT
Change-Id: I29802f65be1f048a43b0b016051d64d400040fe9
GitHub-Last-Rev: 21c19aa216696b17e03becb5591c570879ab46a8
GitHub-Pull-Request: golang/tools#152
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194197
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-09 18:04:07 +00:00
Ainar Garipov
5b82db0742 go/analysis: fix typos
Change-Id: I07235ffba66bf0f7ef0e1917c6f711d317c9ae02
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194139
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-09 03:06:54 +00:00
pjw
fef9eaa9e4 x/tools/gopls: convert to the august, 2019 version of the LSP protocol
The latest version of the LSP protocol introduces a number of changes.
It is now possible to indicate partial results and progress. request.ts
had to construct some new types (at the end of tsclient.go and tsserver,go)
to avoid using a struct for a formal parameter type.  Also,
instead of using the same type for many RPCs, most RPCs now have their own
types.

Change-Id: I095a3e872f42a9f851c01ca4e3c6ac6e32446042
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194177
Run-TryBot: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-08 13:59:31 +00:00
Tobias Klauser
4c50eace5a all: add a space before +build in build tag comments
Add a space before build tag comments so it corresponds to the format
documented at https://golang.org/pkg/go/build/.

Change-Id: I72a0f72ca422f15688b2d7991f82b2361c21fb17
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194138
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-09-08 12:23:18 +00:00
Rebecca Stambler
2ca718005c internal/lsp: use protocol.TextEdits in suggested fixes
Change-Id: I8b454dd8c59839468ecfcb19b7edfa659e386b57
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193957
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-07 02:01:28 +00:00
Edward Muller
12febf440a internal/lsp/cache: detail why the err is ignored
As per slack discussion with Rebecca Stambler.
https://gophers.slack.com/archives/CJZH85XCZ/p1560289227072200

Change-Id: Iaa0f93045edd719e1a874ff6ad9bc8d9e51543d5

Change-Id: Iaa0f93045edd719e1a874ff6ad9bc8d9e51543d5
GitHub-Last-Rev: b54997de95b10d01efe4722a28aea376795ba83f
GitHub-Pull-Request: golang/tools#115
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181778
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-06 20:38:14 +00:00
Muir Manders
fe7c687bb5 internal/lsp: don't lower score of builtin completions
Downranking builtins causes weird interplay with other completion
candidates due to fuzzy matching. For example:

notNil := 123
var foo *int = nil<>

ranks "notNil" before "nil" in the builtin list, which is counter
productive.

Change it to not downrank builtins. In my testing with this change,
builtins never were ranked above lexical items with similar names. I
think this is because the "natural" order of completion items puts
builtins last, and we stable sort items by score, so their relative
order is preserved.

Change-Id: Ifbad02be205e3cb26c1d4ce500b77690e7ac5b04
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193897
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-06 20:37:48 +00:00
Rebecca Stambler
8159a2d3d6 internal/lsp: use protocol.Position for textDocument/prepareRename
Change-Id: Ic896321dff17e788d46dae2efc12ecbf2b2f53dd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193723
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-06 18:55:03 +00:00
Rebecca Stambler
73ad5c96a1 internal/lsp: switch folding range to protocol ranges
Change-Id: I899b3cd89901b99a5c65a5be79ac561289506623
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193724
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-06 18:26:38 +00:00
Rebecca Stambler
04840ef8f3 internal/lsp: switch to using protocol positions for document symbols
Change-Id: I8e550b753328b8e536bff3bb61b4ff4486fcd4f9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193722
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-06 18:11:17 +00:00
Rebecca Stambler
bb4ee55d3d internal/lsp: change to protocol.TextEdit for formatting
The next in the sequence of CLs to convert to using protocol positions.

Change-Id: Ib3421bfc73af1b546b60c328ca66528cb9031e19
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193719
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-06 17:54:09 +00:00
Ian Cottrell
f1f4a3381f internal/lsp: move configuration options to structs
This cl is the first in a set that change the configuration behaviour.
This one should have no behaviour differences, but makes a lot of preparatory changes.
The same options are set to the same values in the same places.
The options are now stored on the Session instead of the Server
The View supports options, but does not have any yet.

Change-Id: Ie966cceca6878861686a1766d63bb8a78021259b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193726
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-06 17:30:54 +00:00
George Hartzell
fa2c3f315e internal/telemetry/export/ocagent: fix typo in comment
Change-Id: I26a6950518441850481f66d0c8844b16e908cffd
GitHub-Last-Rev: f83d960fddfa3ac65a7b766f7fc549ef80de560d
GitHub-Pull-Request: golang/tools#151
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-06 17:19:43 +00:00
Peter Weinberger
bc9f4f258a x/tools/gopls: fix race condition in logging
The existing code uses maps to associate requests with responses. This
change adds locking to avoid simultaneous and illegal reads and writes.

Change-Id: I7bfb21cad6b37ac25e4f6946cb660d82f23c2b80
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193058
Run-TryBot: Peter Weinberger <pjw@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-06 11:54:28 +00:00
Suzy Mueller
93dcc2f048 internal/lsp: fold contained lines when lineFoldingOnly
Folding ranges need to be computed to present folding ranges that make
sense when lineFoldingOnly is true. This change computes the folding
ranges to include the lines that are contained within the start and end
parenthesis/braces when applicable.

Folding ranges are not returned when the contained nodes begin or end on
the same lines as the parenthesis/brace. This is to avoid misleading
folding ranges like the following in unformatted code:

if true {
	fmt.Println("true") } else {
	fmt.Println("false")
}
---folding "if true {}"--->
if true {
	fmt.Println("false")
}

Change-Id: I2931d02837ad5f2dd96cc93da5ede59afd6bcdce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192678
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-05 23:56:50 +00:00
Muir Manders
59228eac51 internal/lsp: avoid invalid state due to context cancelation
In shouldRunGopackages we would reset a goFile's metadata and pkgs in
advance of re-running go/packages. However, if we did not end up
running go/packages for whatever reason (read: we got canceled), the
goFile gets stuck in the unfortunate state of not belonging to any
packages because "pkgs" is empty. I think this leads to "no
CheckPackageHandle" errors, at least in relation to GetCachedPackage()
calls.

Fix by deferring the reset of goFile's metadata and pkgs until after
the go/packages call has succeeded.

Change-Id: I95aace85c026e1232b42cadee9e7772951c817d0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193601
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-05 23:06:12 +00:00
Rebecca Stambler
4f238b926e internal/lsp: fix deadlock between f.mu and f.handleMu
This change propagates the file handle through the type-checking
process, ensuring that the same handle is used throughout. It also
removes the ordering constraint that f.mu needs to be acquired before
f.handleMu. To make this more correct, we should associate a cached
package only with a FileHandle, but this relies on correct cache
invalidation, so that will be addressed in future changes.

Updates golang/go#34052

Change-Id: I6645046bfd15c882619a7f01f9b48c838de42a30
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193718
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-05 22:17:16 +00:00
Rebecca Stambler
1d492ad178 internal/lsp/cache: add additional spans for tracing
Change-Id: I6935776293e55fb723801132592e7806d87f3930
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193637
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-05 21:33:45 +00:00
Rebecca Stambler
fd6a59f26d internal/lsp/cache: fix race condition in type-checking
We had previously been returning the metadata map in a few of the
loading functions. We don't actually need the map; we only need the
actual metadata. The race was caused by the return of the f.meta field
in a few functions, unprotected by the f.mu lock. This was likely a
result of the f.mu lock being added after the fact.

Fixes golang/go#33978

Change-Id: Ice5778d9d6dea23304237baf321b55d4fee6599c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193717
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-05 20:58:25 +00:00
Heschi Kreinick
6b3d1c9ba8 internal/imports: ignore invalid mod cache entries
If someone puts something silly in their module cache, ignore it instead
of crashing.

Fixes golang/go#34027.

Change-Id: I114e10010bd6bc483f865a628dc2b331c3a34a11
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193268
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-05 17:34:53 +00:00
Rebecca Stambler
2a03e9e3a7 internal/lsp: avoid using the importer's context as much as possible
There are issues with contexts being propagated through the calls to
type-checking, and I think that a lot of these were related to us using
the importer's context. Instead, we should propagate the context from
the store as much as possible - only using the importer's context when
absolutely necessary (in the call to Import). This change propagates the
correct context where possible.

Updates golang/go#34103

Change-Id: I4bdc37d014ee1f775b720c9e7ad8abffffcf6ba3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193480
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-05 15:54:44 +00:00
Rebecca Stambler
adb45749da internal/lsp: turn on completion documentation by default
This feature has been in an experimental state for a long enough time
that I think we can enable it by default at master.

Change-Id: I9bbb8b41377719f0e97f608f6e5163a883a176b3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192259
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-05 03:53:08 +00:00
Rebecca Stambler
df305b82d2 internal/lsp: fix declarations in references
Fixes golang/go#34087

Change-Id: I854c03cd124fe783f838dc53ee76cec5fffa563b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193379
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-05 03:51:44 +00:00
Rebecca Stambler
70bfb60283 internal/lsp: fix deadlock in type-checking
Fixes golang/go#33992

Change-Id: I4e27501d1c619887038dfa77cc9cf064c966ff43
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193317
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-05 03:50:54 +00:00
Michael Matloob
958971f5c2 go/ssa/interp: skip recover2 testcase
The test case (taken from the go distribution itself) seems to be broken
when run against tip. Disable it when run against tip.

Updates golang/go#34089

Change-Id: I47d2e12ca39bc060fe0a0c967e95b900bdd0d725
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193377
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-04 21:37:38 +00:00
Rebecca Stambler
a4fdb3a8b2 gopls: update x/tools version
Change-Id: Ibf3c3381a3ecb3015b44436b7e28b615fab00bf4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/193378
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-04 21:13:25 +00:00
Muir Manders
7dc6b39912 internal/lsp: use memoize store's context when type checking
The memoize store passes a detached context to the value getter
function. This is important since if the value getter experiences a
context cancellation it will end up caching context.Canceled, which
you never want. When type checking, we were ignoring the detached
context and using the "real" request context. This would cause the
context.Canceled error to get cached and continue popping up in
various situations.

Fix by swapping the importer's context to the detached context. It is
a little messy since the importer stores the context as a field. I
added a defer to restore the original context since it doesn't seem
correct to let the detached context escape the memoize function.

Updates golang/go#33678

Change-Id: I20dd466b0072ac2e856adbe993364f77e93ab054
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192719
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-09-04 20:12:04 +00:00
Suzy Mueller
be0da057c5 internal/lsp: return only multiline ranges when lineFoldingOnly
If the client registers with foldingRange.lineFoldingOnly = true, only
return folding ranges that span multiple lines. Do this as they are
computed, so that if other filtering is applied later, we do not include
ranges that would go unused by the client anyway.

Change-Id: I27ea24428d25f180e26892de0f6d16c211225bf7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192477
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-03 16:36:17 +00:00
Suzy Mueller
afe7f8212f internal/lsp: add tests for nested folding ranges
FoldingRanges may be nested. Test nested folding ranges by separating
out the folding ranges by nested level and checking each level.

Change-Id: I12c72daa3e6c6b9d4959209b3a41b27e2b59866f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192398
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-09-03 02:50:54 +00:00
Karthik Nayak
a56fc290d6 gopls: fix typo in the design document
Change-Id: I0ae8f7c9c02660111236ba88eba8faa69a974ab8
GitHub-Last-Rev: d428dbf26672646c4d25ded71e47a710279a8444
GitHub-Pull-Request: golang/tools#149
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192898
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-09-03 01:11:30 +00:00
Michael Matloob
573d992605 go/analysis/doc: fix stuff that was left out of the previous commit
I forgot to add the section on supplying AST nodes directly.

Change-Id: Ibf9930693cf32542832b21a95621224c8d68e0f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192682
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-30 22:31:41 +00:00
Michael Matloob
8fa7b020d0 go/analysis/doc: provide more motivation for suggestedfix design
Change-Id: I8139010883357616bf6bfd76b62debe00267164b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192681
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-30 22:15:19 +00:00
Michael Matloob
56125e7d70 go/packages: make sure to request dependencies when we NeedTypesInfo
If NeedTypesInfo, go/packages needs to do typechecking itself so it can
associate type info with the AST. To do so, we need the export data
for dependencies, which means we need to ask for the direct dependencies.
go list has no way to ask for direct dependencies, so we'll set -deps
in the command line to go list. (We need to type check the transitive
dependencies to get export data anyways so this shouldn't be that
much worse than a hypothetical mode that only did work for direct
dependencies. The main issue will be the I/O required (which could (?)
still be a problem?).)

On top of that, we need to make sure that we *don't* ask for sources for
those direct dependencies (which we might have done before) because
that would result in trying to type check the dependency packages
from source, which we'd need *those* packages' dependencies' export
data and transitive sources for and so on.

uggggggggggggggh

Fixes golang/go#32814

Change-Id: I8d95b320beea556bdf44c625607d9e7d2cc188e5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184165
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-30 17:24:00 +00:00
A. Jensen
2161848f5a internal/lsp/source: fixes completion for slice literals of pointers
The existing implementation did not suggest struct field names
when running completion from within a slice literal of
pointers. Now, struct field names are suggested in that case.

Fixes golang/go#33211

Change-Id: I6028420a9a789846b070fcc6e45ec89dc4d898d4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192277
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-30 17:14:47 +00:00
Bryan C. Mills
311ec0312e all: skip more memory-intensive tests on linux-arm
Updates golang/go#32834

Change-Id: I9844dc09d9a6eb2e79a0b28a1e69ed018bfa1bff
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192578
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-30 17:05:41 +00:00
Bryan C. Mills
df13fa7beb all: do not write to testdata directories
I got tired of spurious 'git' diffs while a 'go test' was running, so
I fixed the test that produced the diffs. (We need to do that anyway
in order to run them in the module cache, plus it's just good hygiene
not to have tests interfering with each other's sources.)

Tested using:

	$ chmod -R ugo-w . && go test ./...; chmod -R u+w .

Updates golang/go#28387

Change-Id: Ie17e31aecf0e3cb022df5503d7c443000366a5c6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192577
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-30 17:05:20 +00:00
Muir Manders
6afc7fcab5 internal/lsp: enable deep completion and fuzzy matching by default
Invert "useDeepCompletions" config flag to "disableDeepCompletion" and
separate out "disableFuzzyMatching" which reverts to the previous
prefix matching behavior.

I separated fuzzy matching tests out to a separate file so they aren't
entangled with deep completion tests. In coming up with representative
test cases I found a couple issues which I fixed:

- We were treating a fuzzy matcher score of 0 as no match, but the
  matcher returns 0 for candidates that match but have no bonuses. I
  changed the matcher interface so that a score of 0 counts as a
  match. For example, this was preventing a pattern of "o" from
  matching "foo".
- When we lower a candidate's score based on its depth, we were
  subtracting a static multiplier which could result in the score
  going negative. A negative score messes up future score weighting
  because multiplying it by a value in the range [0, 1) makes it
  bigger instead of smaller. Fix by scaling a candidate's score based
  on its depth rather than subtracting a constant factor.

Updates golang/go#32754

Change-Id: Ie6f9111f1696b0d067d08f7eed7b0a338ad9cd67
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192137
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-08-30 16:47:54 +00:00
Bryan C. Mills
c17b040389 all: skip tests if required tools are not found
Fixes golang/go#33950

Change-Id: Iefcb757e773bc052793611c099c25a457fd7e243
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192400
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-30 15:40:57 +00:00
Pontus Leitzler
f340ed3ae2 x/tools/gopls: add fallback to default GOPATH if missing
The "Organize imports" code action uses internal/imports that needs a
valid GOPATH set. Since Go 1.8 setting GOPATH manually is not required,
and if it isn't set gopls will sometimes fail to properly import
packages.

This CL sets GOPATH to the default if the env var GOPATH isn't set.

Fixes golang/go#33918.

Change-Id: Ib63a26a801e15af730197999de4d1d4901694a30
Reviewed-on: https://go-review.googlesource.com/c/tools/+/191600
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-30 08:22:54 +00:00
Suzy Mueller
340205e581 internal/imports: skip scanned module cache dirs
Packages found in the module cache do not change. When we encounter a
directory we have already processed in the module cache, skip that
directory and add the packages that have already been computed.

Change-Id: Ib1bf0bf22727110b8073b415b145034acceb6787
Reviewed-on: https://go-review.googlesource.com/c/tools/+/186921
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-08-29 21:03:13 +00:00
Bryan C. Mills
5d7988b71d go/packages,internal/lsp: skip memory-intensive tests on the linux-arm builder
Updates golang/go#32834
Updates golang/go#30309

Change-Id: I75edb84776216523d00fadfb2e2d94ae08533c03
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192336
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-08-29 20:36:57 +00:00
Suzy Mueller
ee1fc86af2 internal/imports: use cache of mod cache pkgs in find packages
To check if a package is in a module that is in scope, the module
resolver checks if there are Go files that would be included in a
package in the directory matching the import path in scope.

If this directory is in the module cache and we have saved it as a
package, we know this directory contains Go files, and do not have to
read the directory.

Change-Id: I7c9365ce42c760ab95bc68b036212120895c89fb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/186922
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-08-29 20:29:44 +00:00