golang.org/x/tools/gopls@v0.15.3/internal/test/marker/testdata/completion/comment.txt (about)

     1  This test checks behavior of completion within comments.
     2  
     3  -- flags --
     4  -ignore_extra_diags
     5  
     6  -- go.mod --
     7  module golang.org/lsptests/comment
     8  
     9  go 1.18
    10  
    11  -- p.go --
    12  package comment_completion
    13  
    14  var p bool
    15  
    16  //@complete(re"$")
    17  
    18  func _() {
    19  	var a int
    20  
    21  	switch a {
    22  	case 1:
    23  		//@complete(re"$")
    24  		_ = a
    25  	}
    26  
    27  	var b chan int
    28  	select {
    29  	case <-b:
    30  		//@complete(re"$")
    31  		_ = b
    32  	}
    33  
    34  	var (
    35  		//@complete(re"$")
    36  		_ = a
    37  	)
    38  }
    39  
    40  // //@complete(" ", variableC)
    41  var C string //@item(variableC, "C", "string", "var") //@complete(" ", variableC)
    42  
    43  // //@complete(" ", constant)
    44  const Constant = "example" //@item(constant, "Constant", "string", "const") //@complete(" ", constant)
    45  
    46  // //@complete(" ", structType, fieldB, fieldA)
    47  type StructType struct { //@item(structType, "StructType", "struct{...}", "struct") //@complete(" ", structType, fieldA, fieldB)
    48  	// //@complete(" ", fieldA, structType, fieldB)
    49  	A string //@item(fieldA, "A", "string", "field") //@complete(" ", fieldA, structType, fieldB)
    50  	b int    //@item(fieldB, "b", "int", "field") //@complete(" ", fieldB, structType, fieldA)
    51  }
    52  
    53  // //@complete(" ", method, structRecv, paramX, resultY, fieldB, fieldA)
    54  func (structType *StructType) Method(X int) (Y int) { //@item(structRecv, "structType", "*StructType", "var"),item(method, "Method", "func(X int) (Y int)", "method"),item(paramX, "X", "int", "var"),item(resultY, "Y", "int", "var")
    55  	// //@complete(" ", method, structRecv, paramX, resultY, fieldB, fieldA)
    56  	return
    57  }
    58  
    59  // //@complete(" ", newType)
    60  type NewType string //@item(newType, "NewType", "string", "type") //@complete(" ", newType)
    61  
    62  // //@complete(" ", testInterface, testA, testB)
    63  type TestInterface interface { //@item(testInterface, "TestInterface", "interface{...}", "interface")
    64  	// //@complete(" ", testA, testInterface, testB)
    65  	TestA(L string) (M int) //@item(testA, "TestA", "func(L string) (M int)", "method"),item(paramL, "L", "var", "string"),item(resM, "M", "var", "int") //@complete(" ", testA, testInterface, testB)
    66  	TestB(N int) bool       //@item(testB, "TestB", "func(N int) bool", "method"),item(paramN, "N", "var", "int") //@complete(" ", testB, testInterface, testA)
    67  }
    68  
    69  // //@complete(" ", function)
    70  func Function() int { //@item(function, "Function", "func() int", "func") //@complete(" ", function)
    71  	// //@complete(" ", function)
    72  	return 0
    73  }
    74  
    75  // This tests multiline block comments and completion with prefix
    76  // Lorem Ipsum Multili//@complete("Multi", multiline)
    77  // Lorem ipsum dolor sit ametom
    78  func Multiline() int { //@item(multiline, "Multiline", "func() int", "func")
    79  	// //@complete(" ", multiline)
    80  	return 0
    81  }