internal/lsp: use the new marker support

We use the custom marker support to allow us to simplify the
annotations, making it much easier to understand the tests.

Change-Id: Id818a286e4e85f48cfe505f14ec82a80498e494c
Reviewed-on: https://go-review.googlesource.com/c/149611
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ian Cottrell 2018-11-14 19:25:49 -05:00
parent cd212e53e1
commit 6778892796
2 changed files with 13 additions and 5 deletions

View File

@ -79,6 +79,14 @@ func testLSP(t *testing.T, exporter packagestest.Exporter) {
dirs[filepath.Dir(filename)] = true dirs[filepath.Dir(filename)] = true
} }
} }
// Do a first pass to collect special markers
if err := exported.Expect(map[string]interface{}{
"item": func(name string, r packagestest.Range, _, _ string) {
exported.Mark(name, r)
},
}); err != nil {
t.Fatal(err)
}
// Collect any data that needs to be used by subsequent tests. // Collect any data that needs to be used by subsequent tests.
if err := exported.Expect(map[string]interface{}{ if err := exported.Expect(map[string]interface{}{
"diag": func(pos token.Position, msg string) { "diag": func(pos token.Position, msg string) {

View File

@ -1,13 +1,13 @@
package foo package foo
type StructFoo struct { //@mark(StructFoo, "StructFoo"),item(StructFoo, "StructFoo", "struct{...}", "struct") type StructFoo struct { //@item(StructFoo, "StructFoo", "struct{...}", "struct")
Value int //@mark(Value, "Value"),item(Value, "Value", "int", "field") Value int //@item(Value, "Value", "int", "field")
} }
// TODO(rstambler): Create pre-set builtins? // TODO(rstambler): Create pre-set builtins?
//@mark(Error, ""),item(Error, "Error()", "string", "method") /* Error() */ //@item(Error, "Error()", "string", "method")
func Foo() { //@mark(Foo, "Foo"),item(Foo, "Foo()", "", "func") func Foo() { //@item(Foo, "Foo()", "", "func")
var err error var err error
err.Error() //@complete("E", Error) err.Error() //@complete("E", Error)
} }
@ -20,4 +20,4 @@ func _() {
} }
//@complete("", Foo, IntFoo, StructFoo) //@complete("", Foo, IntFoo, StructFoo)
type IntFoo int //@mark(IntFoo, "IntFoo"),item(IntFoo, "IntFoo", "int", "type") type IntFoo int //@item(IntFoo, "IntFoo", "int", "type")