mirror of
https://github.com/golang/go
synced 2024-11-18 19:24:39 -07:00
5ae4576c3a
Sometimes the prefix of the thing you want to complete is a keyword. For example: variance := 123 fmt.Println(var<>) In this case the parser produces an *ast.BadExpr which breaks completion. We now repair this BadExpr by replacing it with an *ast.Ident named "var". We also repair empty decls using a similar approach. This fixes cases like: var typeName string type<> // want to complete to "typeName" We also fix accidental keywords in selectors, such as: foo.var<> The parser produces a phantom "_" in place of the keyword, so we swap it back for an *ast.Ident named "var". In general, though, accidental keywords wreak havoc on the AST so we can only do so much. There are still many cases where a keyword prefix breaks completion. Perhaps in the future the parser can be cursor/in-progress-edit aware and turn accidental keywords into identifiers. Fixes golang/go#34332. PS I tweaked nodeContains() to include n.End() to fix a test failure against tip related to a change to go/parser. When a syntax error is present, an *ast.BlockStmt's End() is now set to the block's final statement's End() (earlier than what it used to be). In order for the cursor pos to test "inside" the block in this case I had to relax the End() comparison. Change-Id: Ib45952cf086cc974f1578298df3dd12829344faa Reviewed-on: https://go-review.googlesource.com/c/tools/+/209438 Run-TryBot: Muir Manders <muir@mnd.rs> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
24 lines
492 B
Plaintext
24 lines
492 B
Plaintext
-- summary --
|
|
CompletionsCount = 219
|
|
CompletionSnippetCount = 51
|
|
UnimportedCompletionsCount = 3
|
|
DeepCompletionsCount = 5
|
|
FuzzyCompletionsCount = 7
|
|
RankedCompletionsCount = 26
|
|
CaseSensitiveCompletionsCount = 4
|
|
DiagnosticsCount = 22
|
|
FoldingRangesCount = 2
|
|
FormatCount = 6
|
|
ImportCount = 7
|
|
SuggestedFixCount = 1
|
|
DefinitionsCount = 38
|
|
TypeDefinitionsCount = 2
|
|
HighlightsCount = 37
|
|
ReferencesCount = 7
|
|
RenamesCount = 22
|
|
PrepareRenamesCount = 8
|
|
SymbolsCount = 1
|
|
SignaturesCount = 22
|
|
LinksCount = 6
|
|
|