forked from golang/tools
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from visualfc/rank
gopls/internal/goxls/testdata: add rank test
- Loading branch information
Showing
11 changed files
with
158 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- addimport -- | ||
package addimport //@addimport("", "bytes") | ||
|
||
import "bytes" | ||
|
||
func main() {} | ||
|
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,3 @@ | ||
package addimport //@addimport("", "bytes") | ||
|
||
func main() {} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,31 @@ | ||
package foo //@mark(PackageFoo, "foo"),item(PackageFoo, "foo", "\"golang.org/lsptests/foo\"", "package") | ||
|
||
type StructFoo struct { //@item(StructFoo, "StructFoo", "struct{...}", "struct") | ||
Value int //@item(Value, "Value", "int", "field") | ||
} | ||
|
||
// Pre-set this marker, as we don't have a "source" for it in this package. | ||
/* Error() */ //@item(Error, "Error", "func() string", "method") | ||
|
||
func Foo() { //@item(Foo, "Foo", "func()", "func") | ||
var err error | ||
err.Error() //@complete("E", Error) | ||
} | ||
|
||
func _() { | ||
var sFoo StructFoo //@complete("t", StructFoo) | ||
if x := sFoo; x.Value == 1 { //@complete("V", Value),typdef("sFoo", StructFoo) | ||
return | ||
} | ||
} | ||
|
||
func _() { | ||
shadowed := 123 | ||
{ | ||
shadowed := "hi" //@item(shadowed, "shadowed", "string", "var") | ||
_ = shadowed //@complete("a", shadowed) | ||
} | ||
_ = shadowed | ||
} | ||
|
||
type IntFoo int //@item(IntFoo, "IntFoo", "int", "type") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,79 @@ | ||
package func_rank | ||
|
||
import "net/http" | ||
|
||
var stringAVar = "var" //@item(stringAVar, "stringAVar", "string", "var") | ||
func stringBFunc() string { return "str" } //@item(stringBFunc, "stringBFunc", "func() string", "func") | ||
type stringer struct{} //@item(stringer, "stringer", "struct{...}", "struct") | ||
|
||
func _() stringer //@complete("tr", stringer) | ||
|
||
func _(val stringer) {} //@complete("tr", stringer) | ||
|
||
func (stringer) _() {} //@complete("tr", stringer) | ||
|
||
func _() { | ||
var s struct { | ||
AA int //@item(rankAA, "AA", "int", "field") | ||
AB string //@item(rankAB, "AB", "string", "field") | ||
AC int //@item(rankAC, "AC", "int", "field") | ||
} | ||
fnStr := func(string) {} | ||
fnStr(s.A) //@complete(")", rankAB, rankAA, rankAC) | ||
fnStr("" + s.A) //@complete(")", rankAB, rankAA, rankAC) | ||
|
||
fnInt := func(int) {} | ||
fnInt(-s.A) //@complete(")", rankAA, rankAC, rankAB) | ||
|
||
// no expected type | ||
fnInt(func() int { s.A }) //TODO @complete(" }", rankAA, rankAB, rankAC) | ||
fnInt(s.A()) //@complete("()", rankAA, rankAC, rankAB) | ||
fnInt([]int{}[s.A]) //@complete("])", rankAA, rankAC, rankAB) | ||
fnInt([]int{}[:s.A]) //@complete("])", rankAA, rankAC, rankAB) | ||
|
||
fnInt(s.A.(int)) //@complete(".(", rankAA, rankAC, rankAB) | ||
|
||
fnPtr := func(*string) {} | ||
fnPtr(&s.A) //@complete(")", rankAB, rankAA, rankAC) | ||
|
||
var aaPtr *string //@item(rankAAPtr, "aaPtr", "*string", "var") | ||
var abPtr *int //@item(rankABPtr, "abPtr", "*int", "var") | ||
fnInt(*a) //@complete(")", rankABPtr, rankAAPtr) | ||
|
||
_ = func() string { | ||
return s.A //@complete(" //", rankAB, rankAA, rankAC) | ||
} | ||
} | ||
|
||
type foo struct { | ||
fooPrivateField int //@item(rankFooPrivField, "fooPrivateField", "int", "field") | ||
FooPublicField int //@item(rankFooPubField, "FooPublicField", "int", "field") | ||
} | ||
|
||
func (foo) fooPrivateMethod() int { //@item(rankFooPrivMeth, "fooPrivateMethod", "func() int", "method") | ||
return 0 | ||
} | ||
|
||
func (foo) FooPublicMethod() int { //@item(rankFooPubMeth, "FooPublicMethod", "func() int", "method") | ||
return 0 | ||
} | ||
|
||
func _() { | ||
HandleFunc //@item(httpHandleFunc, "HandleFunc", "func(pattern string, handler func(http.ResponseWriter, *http.Request))", "func") | ||
HandlerFunc //@item(httpHandlerFunc, "HandlerFunc", "func(http.ResponseWriter, *http.Request)", "type") | ||
|
||
http.HandleFunc //@rank(" //", httpHandleFunc, httpHandlerFunc) | ||
} | ||
|
||
func _() { | ||
handleFunc //@item(httpHandleFunc1, "handleFunc", "Go+ alias func\n\nfunc(pattern string, handler func(http.ResponseWriter, *http.Request))", "func") | ||
HandleFunc //@item(httpHandleFunc2, "HandleFunc", "func(pattern string, handler func(http.ResponseWriter, *http.Request))", "func") | ||
HandlerFunc //@item(httpHandlerFunc, "HandlerFunc", "func(http.ResponseWriter, *http.Request)", "type") | ||
|
||
http.handleFunc //@rank(" //", httpHandleFunc1, httpHandleFunc2, httpHandlerFunc) | ||
} | ||
|
||
func _() { | ||
var _ int = foo{}. //@rank(" //", rankFooPrivField, rankFooPubField),rank(" //", rankFooPrivMeth, rankFooPubMeth),rank(" //", rankFooPrivField, rankFooPrivMeth) | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
gopls/internal/goxls/testdata/overload/overload_rank.gop.in
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,18 @@ | ||
import ( | ||
"golang.org/lsptests/overload/a" | ||
) | ||
|
||
func _() { | ||
demo //@item(apkgDemo1, "demo", "Go+ overload funcs\n\n- func()\n- func(n int) int\n- func(n1 int, n2 int)\n- func(s ...string)", "func") | ||
Demo //@item(apkgDemo2, "Demo", "Go+ overload funcs\n\n- func()\n- func(n int) int\n- func(n1 int, n2 int)\n- func(s ...string)", "func") | ||
|
||
a.demo //@rank(" //", apkgDemo1, apkgDemo2) | ||
} | ||
|
||
func _() { | ||
add //@item(apkgAdd1, "add", "Go+ overload funcs\n\n- func(a int)\n- func(a ...string)", "method") | ||
Add //@item(apkgAdd2, "Add", "Go+ overload funcs\n\n- func(a int)\n- func(a ...string)", "method") | ||
|
||
var n N | ||
n.add //@rank(" //", apkgAdd1, apkgAdd2) | ||
} |
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
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