From 6778892796fe0c93b9407702b025045af13c0555 Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Wed, 14 Nov 2018 19:25:49 -0500 Subject: [PATCH] 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 Reviewed-by: Rebecca Stambler TryBot-Result: Gobot Gobot --- internal/lsp/lsp_test.go | 8 ++++++++ internal/lsp/testdata/foo/foo.go | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go index 62716cd0..8099328c 100644 --- a/internal/lsp/lsp_test.go +++ b/internal/lsp/lsp_test.go @@ -79,6 +79,14 @@ func testLSP(t *testing.T, exporter packagestest.Exporter) { 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. if err := exported.Expect(map[string]interface{}{ "diag": func(pos token.Position, msg string) { diff --git a/internal/lsp/testdata/foo/foo.go b/internal/lsp/testdata/foo/foo.go index bb92eb1a..27c1b42c 100644 --- a/internal/lsp/testdata/foo/foo.go +++ b/internal/lsp/testdata/foo/foo.go @@ -1,13 +1,13 @@ package foo -type StructFoo struct { //@mark(StructFoo, "StructFoo"),item(StructFoo, "StructFoo", "struct{...}", "struct") - Value int //@mark(Value, "Value"),item(Value, "Value", "int", "field") +type StructFoo struct { //@item(StructFoo, "StructFoo", "struct{...}", "struct") + Value int //@item(Value, "Value", "int", "field") } // 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 err.Error() //@complete("E", Error) } @@ -20,4 +20,4 @@ func _() { } //@complete("", Foo, IntFoo, StructFoo) -type IntFoo int //@mark(IntFoo, "IntFoo"),item(IntFoo, "IntFoo", "int", "type") +type IntFoo int //@item(IntFoo, "IntFoo", "int", "type")