Skip to content

Commit

Permalink
gopls/internal/goxls/testdata: update testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Mar 20, 2024
1 parent 9d79a89 commit 4c67aac
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 11 deletions.
47 changes: 47 additions & 0 deletions gopls/internal/goxls/testdata/bar/bar.go.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// +build go1.11

package bar

import (
"golang.org/lsptests/foo" //@item(foo, "foo", "\"golang.org/lsptests/foo\"", "package")
)

func helper(i foo.IntFoo) {} //@item(helper, "helper", "func(i foo.IntFoo)", "func")

func _() {
help //@complete("l", helper)
_ = foo.StructFoo{} //@complete("S", IntFoo, StructFoo)
}

// Bar is a function.
func Bar() { //@item(Bar, "Bar", "func()", "func", "Bar is a function.")
foo.Foo() //@complete("F", Foo, IntFoo, StructFoo)
var _ foo.IntFoo //@complete("I", IntFoo, StructFoo)
foo.() //@complete("(", Foo, IntFoo, StructFoo)
}

func _() {
var Valentine int //@item(Valentine, "Valentine", "int", "var")

_ = foo.StructFoo{
Valu //@complete(" //", Value)
}
_ = foo.StructFoo{
Va //@complete("a", Value, Valentine)
}
_ = foo.StructFoo{
Value: 5, //@complete("a", Value)
}
_ = foo.StructFoo{
//@complete("", Value, Valentine, foo, helper, Bar)
}
_ = foo.StructFoo{
Value: Valen //@complete("le", Valentine)
}
_ = foo.StructFoo{
Value: //@complete(" //", Valentine, foo, helper, Bar)
}
_ = foo.StructFoo{
Value: //@complete(" ", Valentine, foo, helper, Bar)
}
}
33 changes: 33 additions & 0 deletions gopls/internal/goxls/testdata/baz/baz.go.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// +build go1.11

package baz

import (
"golang.org/lsptests/bar"

f "golang.org/lsptests/foo"
)

var FooStruct f.StructFoo

func Baz() {
defer bar.Bar() //@complete("B", Bar)
// TODO(rstambler): Test completion here.
defer bar.B
var x f.IntFoo //@complete("n", IntFoo),typdef("x", IntFoo)
bar.Bar() //@complete("B", Bar)
}

func _() {
bob := f.StructFoo{Value: 5}
if x := bob. //@complete(" //", Value)
switch true == false {
case true:
if x := bob. //@complete(" //", Value)
case false:
}
if x := bob.Va //@complete("a", Value)
switch true == true {
default:
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ func _() {
shadowed := 123
{
shadowed := "hi" //@item(shadowed, "shadowed", "string", "var")
_ = shadowed //@complete("a", shadowed)
sha //@complete("a", shadowed)
}
_ = shadowed
}

type IntFoo int //@item(IntFoo, "IntFoo", "int", "type")
3 changes: 0 additions & 3 deletions gopls/internal/goxls/testdata/foo/gop_autogen.go

This file was deleted.

4 changes: 2 additions & 2 deletions gopls/internal/goxls/testdata/summary.txt.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- summary --
CallHierarchyCount = 0
CodeLensCount = 4
CompletionsCount = 18
CompletionsCount = 36
CompletionSnippetCount = 12
UnimportedCompletionsCount = 0
DeepCompletionsCount = 0
Expand All @@ -14,7 +14,7 @@ SemanticTokenCount = 0
SuggestedFixCount = 0
MethodExtractionCount = 0
DefinitionsCount = 23
TypeDefinitionsCount = 1
TypeDefinitionsCount = 2
HighlightsCount = 0
InlayHintsCount = 0
RenamesCount = 0
Expand Down
4 changes: 2 additions & 2 deletions gopls/internal/goxls/testdata/summary_go1.18.txt.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- summary --
CallHierarchyCount = 0
CodeLensCount = 4
CompletionsCount = 18
CompletionsCount = 36
CompletionSnippetCount = 12
UnimportedCompletionsCount = 0
DeepCompletionsCount = 0
Expand All @@ -14,7 +14,7 @@ SemanticTokenCount = 0
SuggestedFixCount = 0
MethodExtractionCount = 0
DefinitionsCount = 23
TypeDefinitionsCount = 1
TypeDefinitionsCount = 2
HighlightsCount = 0
InlayHintsCount = 0
RenamesCount = 0
Expand Down
4 changes: 2 additions & 2 deletions gopls/internal/goxls/testdata/summary_go1.21.txt.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- summary --
CallHierarchyCount = 0
CodeLensCount = 4
CompletionsCount = 18
CompletionsCount = 36
CompletionSnippetCount = 12
UnimportedCompletionsCount = 0
DeepCompletionsCount = 0
Expand All @@ -14,7 +14,7 @@ SemanticTokenCount = 0
SuggestedFixCount = 0
MethodExtractionCount = 0
DefinitionsCount = 23
TypeDefinitionsCount = 1
TypeDefinitionsCount = 2
HighlightsCount = 0
InlayHintsCount = 0
RenamesCount = 0
Expand Down
3 changes: 3 additions & 0 deletions gopls/internal/goxls/testdata/unimported/export_test.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package unimported

var TestExport int //@item(testexport, "TestExport", "var (from \"golang.org/lsptests/unimported\")", "var")
23 changes: 23 additions & 0 deletions gopls/internal/goxls/testdata/unimported/unimported.gop.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package unimported

func _() {
http //@unimported("p", nethttp)
// container/ring is extremely unlikely to be imported by anything, so shouldn't have type information.
ring.Ring //@unimported("Ring", ringring)
signature.Foo //@unimported("Foo", signaturefoo)

context.Bac //@unimported(" //", contextBackground)
}

// Create markers for unimported std lib packages. Only for use by this test.
/* http */ //@item(nethttp, "http", "\"net/http\"", "package")

/* ring.Ring */ //@item(ringring, "Ring", "(from \"container/ring\")", "var")

/* signature.Foo */ //@item(signaturefoo, "Foo", "func (from \"golang.org/lsptests/signature\")", "func")

/* context.Background */ //@item(contextBackground, "Background", "func (from \"context\")", "func")

// Now that we no longer type-check imported completions,
// we don't expect the context.Background().Err method (see golang/go#58663).
/* context.Background().Err */ //@item(contextBackgroundErr, "Background().Err", "func (from \"context\")", "method")
16 changes: 16 additions & 0 deletions gopls/internal/goxls/testdata/unimported/unimported_cand_type.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package unimported

import (
_ "context"

"golang.org/lsptests/baz"
_ "golang.org/lsptests/signature" // provide type information for unimported completions in the other file
)

func _() {
foo.StructFoo{} //@item(litFooStructFoo, "foo.StructFoo{}", "struct{...}", "struct")

// We get the literal completion for "foo.StructFoo{}" even though we haven't
// imported "foo" yet.
baz.FooStruct = f //@snippet(" //", litFooStructFoo, "foo.StructFoo{$0\\}", "foo.StructFoo{$0\\}")
}
9 changes: 9 additions & 0 deletions gopls/internal/goxls/testdata/unimported/x_test.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package unimported_test

import (
"testing"
)

func TestSomething(t *testing.T) {
_ = unimported.TestExport //@unimported("TestExport", testexport)
}

0 comments on commit 4c67aac

Please sign in to comment.