aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorRohan Challa <rohan@golang.org>2020-02-12 16:13:57 -0500
committerRohan Challa <rohan@golang.org>2020-02-13 21:50:53 +0000
commit695c81b9c693534f2daef553f9b55116b70768a6 (patch)
treedfe45c2b34b367398251adaa002cec49a9d392a7 /internal
parente3acd584e2df2ab36886e1577f4ea15f91335d1a (diff)
downloadgolang-x-tools-695c81b9c693534f2daef553f9b55116b70768a6.tar.gz
internal/lsp: fix diagnostics not clearing when creating new files
This change fixes an issue where import errors would not disappear when creating new files in a module by removing the segment of code where we check for listErrors when fixing imports. Updates golang/go#36960 Change-Id: Iefa17edeb0417cac7e33ffa88faf7c9a607e98b3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/219222 Run-TryBot: Rohan Challa <rohan@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Diffstat (limited to 'internal')
-rw-r--r--internal/lsp/source/format.go14
1 files changed, 1 insertions, 13 deletions
diff --git a/internal/lsp/source/format.go b/internal/lsp/source/format.go
index 54f6d4a65..d8efad05d 100644
--- a/internal/lsp/source/format.go
+++ b/internal/lsp/source/format.go
@@ -80,13 +80,10 @@ func AllImportsFixes(ctx context.Context, snapshot Snapshot, fh FileHandle) (all
ctx, done := trace.StartSpan(ctx, "source.AllImportsFixes")
defer done()
- pkg, pgh, err := getParsedFile(ctx, snapshot, fh, NarrowestPackageHandle)
+ _, pgh, err := getParsedFile(ctx, snapshot, fh, NarrowestPackageHandle)
if err != nil {
return nil, nil, errors.Errorf("getting file for AllImportsFixes: %v", err)
}
- if hasListErrors(pkg) {
- return nil, nil, errors.Errorf("%s has list errors, not running goimports", fh.Identity().URI)
- }
err = snapshot.View().RunProcessEnvFunc(ctx, func(opts *imports.Options) error {
allFixEdits, editsPerFix, err = computeImportEdits(ctx, snapshot.View(), pgh, opts)
return err
@@ -297,15 +294,6 @@ func trimToFirstNonImport(fset *token.FileSet, f *ast.File, src []byte, err erro
return src[0:fset.Position(end).Offset], true
}
-func hasListErrors(pkg Package) bool {
- for _, err := range pkg.GetErrors() {
- if err.Kind == ListError {
- return true
- }
- }
- return false
-}
-
func computeTextEdits(ctx context.Context, view View, fh FileHandle, m *protocol.ColumnMapper, formatted string) ([]protocol.TextEdit, error) {
ctx, done := trace.StartSpan(ctx, "source.computeTextEdits")
defer done()