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

11 Commits

Author SHA1 Message Date
Muir Manders
920acffc3e internal/lsp: fix bad *ast.ArrayTypes for completion
Currently array and slice literals don't work very well for
completion. When go/parser is not expecting a type, it often turns
array types (e.g. "[]int") into *ast.BadExpr, which messes up
completion because we can't figure out the prefix from *ast.BadExpr,
and *ast.BadExprs don't get type checked.

This change addresses the first problem of not being able to figure
out the prefix. If we see an *ast.BadExpr, we now blindly try to
reparse it as a composite literal by adding on "{}". If we end up with
an *ast.CompositeLit with an *ast.ArrayType "Type", we swap
the *ast.BadExpr for the *ast.ArrayType. This approach is dumb but
simple, and fixes lexical completions in array types.

Change-Id: Ifa42e646bcbf2a30170d73e6dd11982384d40b43
Reviewed-on: https://go-review.googlesource.com/c/tools/+/197437
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-10-17 20:53:01 +00:00
Rebecca Stambler
719fbf7c21 internal/lsp: move function signature into detail instead of label
Fixes golang/go#32414

Change-Id: If08e655d7a0e29b0865c13d8377e98be01cf24c5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/184777
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-07-03 21:07:46 +00:00
Suzy Mueller
bca362e842 internal/lsp: add find all references
This change implements the find all references feature by finding all of
the uses and definitions of the identifier within the current package.

Testing for references is done using "refs" in the testdata files and
marking the references in the package.

Change-Id: Ieb44b68608e940df5f65c3052eb9ec974f6fae6c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181122
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-06-10 19:06:22 +00:00
Muir Manders
63859f3815 internal/lsp: add definition support for packages
Now the "type" of a *ast.PkgName is the package it points to. Of
course, a package is not a real types.Type, but we can still jump you
there. We have to pick one of the package's files, so we choose the
longest one, hoping it is the most interesting.

Similarly, the "definition" of an *ast.ImportSpec is the package being
imported.

I also added a nil check for the package in SignatureHelp. This panics
for me occasionally.

Change-Id: Ide4640530a28bcec9da6de36723eb7f0e4cc941c
GitHub-Last-Rev: 8190baa0b908065db5b53f236de03d2f3bff39b5
GitHub-Pull-Request: golang/tools#92
Reviewed-on: https://go-review.googlesource.com/c/tools/+/174081
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-10 15:10:30 +00:00
Rebecca Stambler
ad9eeb8003 internal/lsp: handle shadowed variables in lexical completions
Fixes golang/go#31621

Change-Id: I6d5cfde5d5bebc704c9178d40bb93801b255e01c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173958
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2019-04-25 22:28:32 +00:00
Andzej Maciusovic
2d2e1b1749 internal/lsp: do not complete inside comments in functions
The previous change (https://go-review.googlesource.com/c/tools/+/157678) only stopped completion in comments in global scope. This change prevents completions results from being sent for comments inside of functions.

Fixes golang/go#29370

Change-Id: I2b43ae2942c6ce7376d2a5f88c40e6ac45c2b773
GitHub-Last-Rev: bc4aac1370aa5758941cdfae63290f061a55e204
GitHub-Pull-Request: golang/tools#71
Reviewed-on: https://go-review.googlesource.com/c/158538
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-22 18:08:10 +00:00
Andzej Maciusovic
f94e9803bf internal/lsp: do not complete inside comments
Fixes golang/go#29370

Change-Id: I160b00f95fe44b2d87f66dc5842bb3a124e0292c
GitHub-Last-Rev: 924c13bc86f947ca01b291e7cc0d171164c2c856
GitHub-Pull-Request: golang/tools#69
Reviewed-on: https://go-review.googlesource.com/c/157678
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-01-16 17:22:44 +00:00
Rebecca Stambler
2e4132e53b internal/lsp: add a test for completion of builtin types and functions
Change-Id: I7df2cfebbf2c44d189066a6d16770c753f7bf1d4
Reviewed-on: https://go-review.googlesource.com/c/158020
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-01-16 00:24:28 +00:00
Rebecca Stambler
3832e276fb internal/lsp: implement type definitions
Extend definition tests to add typdef test.

Change-Id: Ibad988ae68f91d18f2c6b4739d758a536172fb35
Reviewed-on: https://go-review.googlesource.com/c/152239
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2018-12-04 18:51:09 +00:00
Ian Cottrell
6778892796 internal/lsp: use the new marker support
We use the custom marker support to allow us to simplify the
annotations, making it much easier to understand the tests.

Change-Id: Id818a286e4e85f48cfe505f14ec82a80498e494c
Reviewed-on: https://go-review.googlesource.com/c/149611
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-11-15 01:11:27 +00:00
Rebecca Stambler
806e1cfd89 internal/lsp: add a preliminary test for completion
Use the packagestest framework to test completion. Add support for a
slice of token.Position to packagestest to support this.

Change-Id: Ie5ddece4446a3c74419727461a77faa3788cb040
Reviewed-on: https://go-review.googlesource.com/c/148197
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2018-11-12 19:56:38 +00:00