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

4 Commits

Author SHA1 Message Date
Ian Cottrell
85edb9ef32 internal/lsp: abstract the diff library so it can be substituted
this moves the actual diff algorithm into a different package and then provides hooks so it can be easily replaced with an alternate algorithm.

Change-Id: Ia0359f58878493599ea0e0fda8920f21100e16f1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190898
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-08-20 03:37:07 +00:00
Suzy Mueller
15fda70baf internal/lsp: test adding imports for package statements with comments
Test that having a comment at the start of a file allows imports
to be added correctly.

Updates golang/go#33721

Change-Id: Id1673c2509537413710b73261ad2a59afe06b93f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190800
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-19 17:43:41 +00:00
Suzy Mueller
d308a98e2e internal/lsp: prefer inserting imports into existing blocks
Insert imports into existing multiline import declarations when
possible.

Logic for choosing where to insert taken from
golang.org/x/tools/go/ast/astutil.

Change-Id: Ie5ad96d5e3d5db2e92a2c05a6104d14a4a192ed3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190598
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-08-19 17:23:55 +00:00
Suzy Mueller
caa95bb40b internal/lsp: add completions of unimported std lib pkgs
Unimported packages may be suggested as completion items. Since these
are not yet imported, they should be ranked lower than other candidates.

They also require an additional import statement to be valid, which is
provided as an AdditionalTextEdit.

Adding this import does not use astutil.AddNamedImport, to avoid
editing the current ast and work even if there are errors. Additionally,
it can be hard to determine what changes need to be made to the source
document from the ast, as astutil.AddNamedImport includes a merging
pass. Instead, the completion item simply adds another import
declaration.

Change-Id: Icbde226d843bd49ee3713cafcbd5299d51530695
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190338
Run-TryBot: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-08-16 18:32:40 +00:00