This test checks various ranking of completion results within function call
context.

-- flags --
-ignore_extra_diags

-- settings.json --
{
	"completeUnimported": false,
	"deepCompletion": false
}

-- func_rank.go --
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(re"()tr", stringer)

func _(val stringer) {} //@complete(re"()tr", stringer)

func (stringer) _() {} //@complete(re"()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(re"()\\)", rankAB, rankAA, rankAC)
	fnStr("" + s.A) //@complete(re"()\\)", rankAB, rankAA, rankAC)

	fnInt := func(int) {}
	fnInt(-s.A) //@complete(re"()\\)", rankAA, rankAC, rankAB)

	// no expected type
	fnInt(func() int { s.A }) //@complete(re"() }", rankAA, rankAB, rankAC)
	fnInt(s.A())              //@complete(re"()\\(\\)", rankAA, rankAC, rankAB)
	fnInt([]int{}[s.A])       //@complete(re"()\\]\\)", rankAA, rankAC, rankAB)
	fnInt([]int{}[:s.A])      //@complete(re"()\\]\\)", rankAA, rankAC, rankAB)

	fnInt(s.A.(int)) //@complete(re"()\\.\\(", rankAA, rankAC, rankAB)

	fnPtr := func(*string) {}
	fnPtr(&s.A) //@complete(re"()\\)", rankAB, rankAA, rankAC)

	var aaPtr *string //@item(rankAAPtr, "aaPtr", "*string", "var")
	var abPtr *int    //@item(rankABPtr, "abPtr", "*int", "var")
	fnInt(*a)         //@complete(re"()\\)", rankABPtr, rankAAPtr, stringAVar)

	_ = func() string {
		return s.A //@complete(re"() \\/\\/", 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 _() {
	var _ int = foo{}. //@rank(re"() \\/\\/", rankFooPrivField, rankFooPubField),rank(re"() \\/\\/", rankFooPrivMeth, rankFooPubMeth),rank(re"() \\/\\/", rankFooPrivField, rankFooPrivMeth)
}

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(re"() \\/\\/", httpHandleFunc, httpHandlerFunc)
}
