This test checks completion related to composite literals.

-- flags --
-ignore_extra_diags

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

-- complit.go --
package complit

// Literal completion results.
/* int() */ //@item(int, "int()", "int", "var")

// general completions

type position struct { //@item(structPosition, "position", "struct{...}", "struct")
	X, Y int //@item(fieldX, "X", "int", "field"),item(fieldY, "Y", "int", "field")
}

func _() {
	_ = position{
		//@complete("", fieldX, fieldY, int, structPosition)
	}
	_ = position{
		X: 1,
		//@complete("", fieldY)
	}
	_ = position{
		//@complete("", fieldX)
		Y: 1,
	}
	_ = []*position{
        {
            //@complete("", fieldX, fieldY, int, structPosition)
        },
	}
}

func _() {
	var (
		aa string //@item(aaVar, "aa", "string", "var")
		ab int    //@item(abVar, "ab", "int", "var")
	)

	_ = map[int]int{
		a: a, //@complete(re"():", abVar, aaVar),complete(re"(),", abVar, aaVar)
	}

	_ = map[int]int{
		//@complete("", abVar, int, aaVar, structPosition)
	}

	_ = []string{a: ""} //@complete(re"():", abVar, aaVar)
	_ = [1]string{a: ""} //@complete(re"():", abVar, aaVar)

	_ = position{X: a}   //@complete(re"()}", abVar, aaVar)
	_ = position{a}      //@complete(re"()}", abVar, aaVar)
	_ = position{a, }      //@complete(re"()}", abVar, int, aaVar, structPosition)

	_ = []int{a}  //@complete(re"()}", abVar, aaVar)
	_ = [1]int{a} //@complete(re"()}", abVar, aaVar)

	type myStruct struct {
		AA int    //@item(fieldAA, "AA", "int", "field")
		AB string //@item(fieldAB, "AB", "string", "field")
	}

	_ = myStruct{
		AB: a, //@complete(re"(),", aaVar, abVar)
	}

	var s myStruct

	_ = map[int]string{1: "" + s.A}                                //@complete(re"()}", fieldAB, fieldAA)
	_ = map[int]string{1: (func(i int) string { return "" })(s.A)} //@complete(re"()\\)}", fieldAA, fieldAB)
	_ = map[int]string{1: func() string { s.A }}                   //@complete(re"() }", fieldAA, fieldAB)

	_ = position{s.A} //@complete(re"()}", fieldAA, fieldAB)

	var X int //@item(varX, "X", "int", "var")
	_ = position{X}      //@complete(re"()}", fieldX, varX)
}

func _() {
	type foo struct{} //@item(complitFoo, "foo", "struct{...}", "struct")

	var _ *foo = &fo{} //@snippet(re"()\\{", complitFoo, "foo")
	var _ *foo = fo{} //@snippet(re"()\\{", complitFoo, "&foo")

	struct { a, b *foo }{
		a: &fo{}, //@rank(re"(){", complitFoo)
		b: fo{}, //@snippet(re"()\\{", complitFoo, "&foo")
	}
}

func _() {
	_ := position{
		X: 1, //@complete(re"()X", fieldX),complete(re"() 1", int, structPosition)
		Y: ,  //@complete(re"():", fieldY),complete(re"() ,", int, structPosition)
	}
}
