| 1 |
This test checks basic behavior of the textDocument/foldingRange, when the |
| 2 |
editor only supports line folding. |
| 3 |
|
| 4 |
-- capabilities.json -- |
| 5 |
{ |
| 6 |
"textDocument": { |
| 7 |
"foldingRange": { |
| 8 |
"lineFoldingOnly": true |
| 9 |
} |
| 10 |
} |
| 11 |
} |
| 12 |
-- a.go -- |
| 13 |
package folding //@foldingrange(raw) |
| 14 |
|
| 15 |
import ( |
| 16 |
"fmt" |
| 17 |
_ "log" |
| 18 |
"sort" |
| 19 |
"time" |
| 20 |
) |
| 21 |
|
| 22 |
import _ "os" |
| 23 |
|
| 24 |
// Bar is a function. |
| 25 |
// With a multiline doc comment. |
| 26 |
func Bar() string { |
| 27 |
/* This is a single line comment */ |
| 28 |
switch { |
| 29 |
case true: |
| 30 |
if true { |
| 31 |
fmt.Println("true") |
| 32 |
} else { |
| 33 |
fmt.Println("false") |
| 34 |
} |
| 35 |
case false: |
| 36 |
fmt.Println("false") |
| 37 |
default: |
| 38 |
fmt.Println("default") |
| 39 |
} |
| 40 |
/* This is a multiline |
| 41 |
block |
| 42 |
comment */ |
| 43 |
|
| 44 |
/* This is a multiline |
| 45 |
block |
| 46 |
comment */ |
| 47 |
// Followed by another comment. |
| 48 |
_ = []int{ |
| 49 |
1, |
| 50 |
2, |
| 51 |
3, |
| 52 |
} |
| 53 |
_ = [2]string{"d", |
| 54 |
"e", |
| 55 |
} |
| 56 |
_ = map[string]int{ |
| 57 |
"a": 1, |
| 58 |
"b": 2, |
| 59 |
"c": 3, |
| 60 |
} |
| 61 |
type T struct { |
| 62 |
f string |
| 63 |
g int |
| 64 |
h string |
| 65 |
} |
| 66 |
_ = T{ |
| 67 |
f: "j", |
| 68 |
g: 4, |
| 69 |
h: "i", |
| 70 |
} |
| 71 |
x, y := make(chan bool), make(chan bool) |
| 72 |
select { |
| 73 |
case val := <-x: |
| 74 |
if val { |
| 75 |
fmt.Println("true from x") |
| 76 |
} else { |
| 77 |
fmt.Println("false from x") |
| 78 |
} |
| 79 |
case <-y: |
| 80 |
fmt.Println("y") |
| 81 |
default: |
| 82 |
fmt.Println("default") |
| 83 |
} |
| 84 |
// This is a multiline comment |
| 85 |
// that is not a doc comment. |
| 86 |
return ` |
| 87 |
this string |
| 88 |
is not indented` |
| 89 |
} |
| 90 |
|
| 91 |
func _() { |
| 92 |
slice := []int{1, 2, 3} |
| 93 |
sort.Slice(slice, func(i, j int) bool { |
| 94 |
a, b := slice[i], slice[j] |
| 95 |
return a > b |
| 96 |
}) |
| 97 |
|
| 98 |
sort.Slice(slice, func(i, j int) bool { return slice[i] > slice[j] }) |
| 99 |
|
| 100 |
sort.Slice( |
| 101 |
slice, |
| 102 |
func(i, j int) bool { |
| 103 |
return slice[i] > slice[j] |
| 104 |
}, |
| 105 |
) |
| 106 |
|
| 107 |
fmt.Println( |
| 108 |
1, 2, 3, |
| 109 |
4, |
| 110 |
) |
| 111 |
|
| 112 |
fmt.Println(1, 2, 3, |
| 113 |
4, 5, 6, |
| 114 |
7, 8, 9, |
| 115 |
10) |
| 116 |
|
| 117 |
// Call with ellipsis. |
| 118 |
_ = fmt.Errorf( |
| 119 |
"test %d %d", |
| 120 |
[]any{1, 2, 3}..., |
| 121 |
) |
| 122 |
|
| 123 |
// Check multiline string. |
| 124 |
fmt.Println( |
| 125 |
`multi |
| 126 |
line |
| 127 |
string |
| 128 |
`, |
| 129 |
1, 2, 3, |
| 130 |
) |
| 131 |
|
| 132 |
// Call without arguments. |
| 133 |
_ = time.Now() |
| 134 |
} |
| 135 |
|
| 136 |
func _( |
| 137 |
a int, b int, |
| 138 |
c int, |
| 139 |
) { |
| 140 |
} |
| 141 |
-- @raw -- |
| 142 |
package folding //@foldingrange(raw) |
| 143 |
|
| 144 |
import (<0 kind="imports"> |
| 145 |
"fmt" |
| 146 |
_ "log" |
| 147 |
"sort" |
| 148 |
"time"</0> |
| 149 |
) |
| 150 |
|
| 151 |
import _ "os" |
| 152 |
|
| 153 |
// Bar is a function.<1 kind="comment"> |
| 154 |
// With a multiline doc comment.</1> |
| 155 |
func Bar() string {<2 kind=""> |
| 156 |
/* This is a single line comment */ |
| 157 |
switch {<3 kind=""> |
| 158 |
case true:<4 kind=""> |
| 159 |
if true {<5 kind=""> |
| 160 |
fmt.Println("true")</5> |
| 161 |
} else {<6 kind=""> |
| 162 |
fmt.Println("false")</6> |
| 163 |
}</4> |
| 164 |
case false:<7 kind=""> |
| 165 |
fmt.Println("false")</7> |
| 166 |
default:<8 kind=""> |
| 167 |
fmt.Println("default")</3></8> |
| 168 |
} |
| 169 |
/* This is a multiline<9 kind="comment"> |
| 170 |
block |
| 171 |
comment */</9> |
| 172 |
|
| 173 |
/* This is a multiline<10 kind="comment"> |
| 174 |
block |
| 175 |
comment */ |
| 176 |
// Followed by another comment.</10> |
| 177 |
_ = []int{<11 kind=""> |
| 178 |
1, |
| 179 |
2, |
| 180 |
3,</11> |
| 181 |
} |
| 182 |
_ = [2]string{<12 kind="">"d", |
| 183 |
"e",</12> |
| 184 |
} |
| 185 |
_ = map[string]int{<13 kind=""> |
| 186 |
"a": 1, |
| 187 |
"b": 2, |
| 188 |
"c": 3,</13> |
| 189 |
} |
| 190 |
type T struct {<14 kind=""> |
| 191 |
f string |
| 192 |
g int |
| 193 |
h string</14> |
| 194 |
} |
| 195 |
_ = T{<15 kind=""> |
| 196 |
f: "j", |
| 197 |
g: 4, |
| 198 |
h: "i",</15> |
| 199 |
} |
| 200 |
x, y := make(chan bool), make(chan bool) |
| 201 |
select {<16 kind=""> |
| 202 |
case val := <-x:<17 kind=""> |
| 203 |
if val {<18 kind=""> |
| 204 |
fmt.Println("true from x")</18> |
| 205 |
} else {<19 kind=""> |
| 206 |
fmt.Println("false from x")</19> |
| 207 |
}</17> |
| 208 |
case <-y:<20 kind=""> |
| 209 |
fmt.Println("y")</20> |
| 210 |
default:<21 kind=""> |
| 211 |
fmt.Println("default")</16></21> |
| 212 |
} |
| 213 |
// This is a multiline comment<22 kind="comment"> |
| 214 |
// that is not a doc comment.</22> |
| 215 |
return <23 kind="">` |
| 216 |
this string |
| 217 |
is not indented`</2></23> |
| 218 |
} |
| 219 |
|
| 220 |
func _() {<24 kind=""> |
| 221 |
slice := []int{1, 2, 3} |
| 222 |
sort.Slice(<25 kind="">slice, func(i, j int) bool {<26 kind=""> |
| 223 |
a, b := slice[i], slice[j] |
| 224 |
return a > b</25></26> |
| 225 |
}) |
| 226 |
|
| 227 |
sort.Slice(slice, func(i, j int) bool { return slice[i] > slice[j] }) |
| 228 |
|
| 229 |
sort.Slice(<27 kind=""> |
| 230 |
slice, |
| 231 |
func(i, j int) bool {<28 kind=""> |
| 232 |
return slice[i] > slice[j]</28> |
| 233 |
},</27> |
| 234 |
) |
| 235 |
|
| 236 |
fmt.Println(<29 kind=""> |
| 237 |
1, 2, 3, |
| 238 |
4,</29> |
| 239 |
) |
| 240 |
|
| 241 |
fmt.Println(<30 kind="">1, 2, 3, |
| 242 |
4, 5, 6, |
| 243 |
7, 8, 9,</30> |
| 244 |
10) |
| 245 |
|
| 246 |
// Call with ellipsis. |
| 247 |
_ = fmt.Errorf(<31 kind=""> |
| 248 |
"test %d %d", |
| 249 |
[]any{1, 2, 3}...,</31> |
| 250 |
) |
| 251 |
|
| 252 |
// Check multiline string. |
| 253 |
fmt.Println(<32 kind=""> |
| 254 |
<33 kind="">`multi |
| 255 |
line |
| 256 |
string |
| 257 |
`</33>, |
| 258 |
1, 2, 3,</32> |
| 259 |
) |
| 260 |
|
| 261 |
// Call without arguments. |
| 262 |
_ = time.Now()</24> |
| 263 |
} |
| 264 |
|
| 265 |
func _(<34 kind=""> |
| 266 |
a int, b int, |
| 267 |
c int,</34> |
| 268 |
) { |
| 269 |
} |