| 1 |
|
| 2 |
-- flags -- |
| 3 |
-ignore_extra_diags |
| 4 |
|
| 5 |
-- go.mod -- |
| 6 |
module unimported.test |
| 7 |
|
| 8 |
go 1.18 |
| 9 |
|
| 10 |
-- unimported/export_test.go -- |
| 11 |
package unimported |
| 12 |
|
| 13 |
var TestExport int //@item(testexport, "TestExport", "var (from \"unimported.test/unimported\")", "var") |
| 14 |
|
| 15 |
-- signature/signature.go -- |
| 16 |
package signature |
| 17 |
|
| 18 |
func Foo() {} |
| 19 |
|
| 20 |
-- foo/foo.go -- |
| 21 |
package foo |
| 22 |
|
| 23 |
type StructFoo struct{ F int } |
| 24 |
|
| 25 |
-- baz/baz.go -- |
| 26 |
package baz |
| 27 |
|
| 28 |
import ( |
| 29 |
f "unimported.test/foo" |
| 30 |
) |
| 31 |
|
| 32 |
var FooStruct f.StructFoo |
| 33 |
|
| 34 |
-- unimported/unimported.go -- |
| 35 |
package unimported |
| 36 |
|
| 37 |
func _() { |
| 38 |
http //@complete(re"()p", http, httptest, httptrace, httputil) |
| 39 |
// container/ring is extremely unlikely to be imported by anything, so shouldn't have type information. |
| 40 |
ring.Ring //@complete(re"R()ing", ringring) |
| 41 |
signature.Foo //@complete(re"()Foo", signaturefoo) |
| 42 |
|
| 43 |
context.Bac //@complete(re"() \\/\\/", contextBackground) |
| 44 |
} |
| 45 |
|
| 46 |
// Create markers for unimported std lib packages. Only for use by this test. |
| 47 |
/* http */ //@item(http, "http", "\"net/http\"", "package") |
| 48 |
/* httptest */ //@item(httptest, "httptest", "\"net/http/httptest\"", "package") |
| 49 |
/* httptrace */ //@item(httptrace, "httptrace", "\"net/http/httptrace\"", "package") |
| 50 |
/* httputil */ //@item(httputil, "httputil", "\"net/http/httputil\"", "package") |
| 51 |
|
| 52 |
/* ring.Ring */ //@item(ringring, "Ring", "type (from \"container/ring\")", "var") |
| 53 |
|
| 54 |
/* signature.Foo */ //@item(signaturefoo, "Foo", "func (from \"unimported.test/signature\")", "func") |
| 55 |
|
| 56 |
/* context.Background */ //@item(contextBackground, "Background", "func (from \"context\")", "func") |
| 57 |
|
| 58 |
// Now that we no longer type-check imported completions, |
| 59 |
// we don't expect the context.Background().Err method (see golang/go#58663). |
| 60 |
/* context.Background().Err */ //@item(contextBackgroundErr, "Background().Err", "func (from \"context\")", "method") |
| 61 |
|
| 62 |
-- unimported/unimported_cand_type.go -- |
| 63 |
package unimported |
| 64 |
|
| 65 |
import ( |
| 66 |
_ "context" |
| 67 |
|
| 68 |
"unimported.test/baz" |
| 69 |
) |
| 70 |
|
| 71 |
func _() { |
| 72 |
foo.StructFoo{} //@item(litFooStructFoo, "foo.StructFoo{}", "struct{...}", "struct") |
| 73 |
|
| 74 |
// We get the literal completion for "foo.StructFoo{}" even though we haven't |
| 75 |
// imported "foo" yet. |
| 76 |
baz.FooStruct = f //@snippet(re"() \\/\\/", litFooStructFoo, "foo.StructFoo{$0\\}") |
| 77 |
} |
| 78 |
|
| 79 |
-- unimported/x_test.go -- |
| 80 |
package unimported_test |
| 81 |
|
| 82 |
import ( |
| 83 |
"testing" |
| 84 |
) |
| 85 |
|
| 86 |
func TestSomething(t *testing.T) { |
| 87 |
_ = unimported.TestExport //@complete(re"()TestExport", testexport) |
| 88 |
} |