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

     1  This test checks completion of Go keywords.
     2  
     3  -- flags --
     4  -ignore_extra_diags
     5  -filter_keywords=false
     6  
     7  -- settings.json --
     8  {
     9  	"completeUnimported": false,
    10  	"matcher": "caseInsensitive",
    11  	"experimentalPostfixCompletions": false
    12  }
    13  
    14  -- keywords.go --
    15  package keywords
    16  
    17  //@rank("", type),rank("", func),rank("", var),rank("", const),rank("", import)
    18  
    19  func _() {
    20  	var test int //@rank(" //", int, interface)
    21  	var tChan chan int
    22  	var _ m //@complete(" //", map)
    23  	var _ f //@complete(" //", func)
    24  	var _ c //@complete(" //", chan)
    25  
    26  	var _ str //@rank(" //", string, struct)
    27  
    28  	type _ int //@rank(" //", interface, int)
    29  
    30  	type _ str //@rank(" //", struct, string)
    31  
    32  	switch test {
    33  	case 1: // TODO: trying to complete case here will break because the parser won't return *ast.Ident
    34  		b //@complete(" //", break)
    35  	case 2:
    36  		f //@complete(" //", fallthrough, for)
    37  		r //@complete(" //", return)
    38  		d //@complete(" //", default, defer)
    39  		c //@complete(" //", case, const)
    40  	}
    41  
    42  	switch test.(type) {
    43  	case fo: //@complete(":")
    44  	case int:
    45  		b //@complete(" //", break)
    46  	case int32:
    47  		f //@complete(" //", for)
    48  		d //@complete(" //", default, defer)
    49  		r //@complete(" //", return)
    50  		c //@complete(" //", case, const)
    51  	}
    52  
    53  	select {
    54  	case <-tChan:
    55  		b //@complete(" //", break)
    56  		c //@complete(" //", case, const)
    57  	}
    58  
    59  	for index := 0; index < test; index++ {
    60  		c //@complete(" //", const, continue)
    61  		b //@complete(" //", break)
    62  	}
    63  
    64  	for range []int{} {
    65  		c //@complete(" //", const, continue)
    66  		b //@complete(" //", break)
    67  	}
    68  
    69  	// Test function level keywords
    70  
    71  	//Using 2 characters to test because map output order is random
    72  	sw //@complete(" //", switch)
    73  	se //@complete(" //", select)
    74  
    75  	f //@complete(" //", for)
    76  	d //@complete(" //", defer)
    77  	g //@rank(" //", go),rank(" //", goto)
    78  	r //@complete(" //", return)
    79  	i //@complete(" //", if)
    80  	e //@complete(" //", else)
    81  	v //@complete(" //", var)
    82  	c //@complete(" //", const)
    83  
    84  	for i := r //@complete(" //", range)
    85  }
    86  
    87  /* package */ //@item(package, "package", "", "keyword")
    88  /* import */ //@item(import, "import", "", "keyword")
    89  /* func */ //@item(func, "func", "", "keyword")
    90  /* type */ //@item(type, "type", "", "keyword")
    91  /* var */ //@item(var, "var", "", "keyword")
    92  /* const */ //@item(const, "const", "", "keyword")
    93  /* break */ //@item(break, "break", "", "keyword")
    94  /* default */ //@item(default, "default", "", "keyword")
    95  /* case */ //@item(case, "case", "", "keyword")
    96  /* defer */ //@item(defer, "defer", "", "keyword")
    97  /* go */ //@item(go, "go", "", "keyword")
    98  /* for */ //@item(for, "for", "", "keyword")
    99  /* if */ //@item(if, "if", "", "keyword")
   100  /* else */ //@item(else, "else", "", "keyword")
   101  /* switch */ //@item(switch, "switch", "", "keyword")
   102  /* select */ //@item(select, "select", "", "keyword")
   103  /* fallthrough */ //@item(fallthrough, "fallthrough", "", "keyword")
   104  /* continue */ //@item(continue, "continue", "", "keyword")
   105  /* return */ //@item(return, "return", "", "keyword")
   106  /* goto */ //@item(goto, "goto", "", "keyword")
   107  /* struct */ //@item(struct, "struct", "", "keyword")
   108  /* interface */ //@item(interface, "interface", "", "keyword")
   109  /* map */ //@item(map, "map", "", "keyword")
   110  /* chan */ //@item(chan, "chan", "", "keyword")
   111  /* range */ //@item(range, "range", "", "keyword")
   112  /* string */ //@item(string, "string", "", "type")
   113  /* int */ //@item(int, "int", "", "type")
   114  
   115  -- accidental_keywords.go --
   116  package keywords
   117  
   118  // non-matching candidate - shouldn't show up as completion
   119  var apple = "apple"
   120  
   121  func _() {
   122  	foo.bar() // insert some extra statements to exercise our AST surgery
   123  	variance := 123 //@item(kwVariance, "variance", "int", "var")
   124  	foo.bar()
   125  	println(var) //@complete(")", kwVariance)
   126  }
   127  
   128  func _() {
   129  	foo.bar()
   130  	var s struct { variance int } //@item(kwVarianceField, "variance", "int", "field")
   131  	foo.bar()
   132  	s.var //@complete(" //", kwVarianceField)
   133  }
   134  
   135  func _() {
   136  	channel := 123 //@item(kwChannel, "channel", "int", "var")
   137  	chan //@complete(" //", kwChannel)
   138  	foo.bar()
   139  }
   140  
   141  func _() {
   142  	foo.bar()
   143  	var typeName string //@item(kwTypeName, "typeName", "string", "var")
   144  	foo.bar()
   145  	type //@complete(" //", kwTypeName)
   146  }
   147  -- empty_select.go --
   148  package keywords
   149  
   150  func _() {
   151  	select {
   152  		c //@complete(" //", case)
   153  	}
   154  }
   155  -- empty_switch.go --
   156  package keywords
   157  
   158  func _() {
   159  	switch {
   160  		//@complete("", case, default)
   161  	}
   162  
   163  	switch test.(type) {
   164  		d //@complete(" //", default)
   165  	}
   166  }