-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/golang/completion: honor std symbol versions (imported)
This change is the counterpart to CL 569435 for completions in imported packages. Updates golang/go#46136 Change-Id: I57011897c395d37a89a8e3a99e8c3511de017ad3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/569796 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
- Loading branch information
Showing
4 changed files
with
128 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
gopls/internal/test/marker/testdata/completion/imported-std.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Test of imported completions respecting the effective Go version of the file. | ||
|
||
(See "un-" prefixed file for same test of unimported completions.) | ||
|
||
These symbols below were introduced in go1.20: | ||
|
||
types.Satisfied | ||
ast.File.FileStart | ||
(*token.FileSet).RemoveFile | ||
|
||
The underlying logic depends on versions.FileVersion, which only | ||
behaves correctly in go1.22. (When go1.22 is assured, we can remove | ||
the min_go flag but leave the test inputs unchanged.) | ||
|
||
-- flags -- | ||
-ignore_extra_diags -min_go=go1.22 | ||
|
||
-- go.mod -- | ||
module example.com | ||
|
||
go 1.19 | ||
|
||
-- a/a.go -- | ||
package a | ||
|
||
import "go/ast" | ||
import "go/token" | ||
import "go/types" | ||
|
||
// package-level func | ||
var _ = types.Imple //@rankl("Imple", "Implements") | ||
var _ = types.Satis //@rankl("Satis", "!Satisfies") | ||
|
||
// (Apparently we don't even offer completions of methods | ||
// of types from unimported packages, so the fact that | ||
// we don't implement std version filtering isn't evident.) | ||
|
||
// field | ||
var _ = new(ast.File).Packa //@rankl("Packa", "Package") | ||
var _ = new(ast.File).FileS //@rankl("FileS", "!FileStart") | ||
|
||
// method | ||
var _ = new(token.FileSet).Add //@rankl("Add", "AddFile") | ||
var _ = new(token.FileSet).Remove //@rankl("Remove", "!RemoveFile") | ||
|
||
-- b/b.go -- | ||
//go:build go1.20 | ||
|
||
package a | ||
|
||
import "go/ast" | ||
import "go/token" | ||
import "go/types" | ||
|
||
// package-level func | ||
var _ = types.Imple //@rankl("Imple", "Implements") | ||
var _ = types.Satis //@rankl("Satis", "Satisfies") | ||
|
||
// field | ||
var _ = new(ast.File).Packa //@rankl("Packa", "Package") | ||
var _ = new(ast.File).FileS //@rankl("FileS", "FileStart") | ||
|
||
// method | ||
var _ = new(token.FileSet).Add //@rankl("Add", "AddFile") | ||
var _ = new(token.FileSet).Remove //@rankl("Remove", "RemoveFile") |
2 changes: 2 additions & 0 deletions
2
gopls/internal/test/marker/testdata/completion/unimported-std.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters