| 1 |
This test checks that failing to produce edits doesn't fail the |
| 2 |
codeAction/resolve operation. Instead, we simply return the action |
| 3 |
with its command, and let the action fail when its command is applied |
| 4 |
(golang/go#75442). |
| 5 |
|
| 6 |
-- flags -- |
| 7 |
-ignore_extra_diags |
| 8 |
|
| 9 |
-- go.mod -- |
| 10 |
module golang.org/lsptests/failedresolve |
| 11 |
|
| 12 |
go 1.18 |
| 13 |
|
| 14 |
-- resolve.go -- |
| 15 |
package extract |
| 16 |
|
| 17 |
func _() { |
| 18 |
if x := 1; true { |
| 19 |
|
| 20 |
} else if y := x + 1; true { //@codeaction("x + 1", "refactor.extract.variable", action=act) |
| 21 |
|
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
-- apply.go -- |
| 26 |
package extract |
| 27 |
|
| 28 |
func _() { |
| 29 |
if x := 1; true { |
| 30 |
|
| 31 |
} else if y := x + 1; true { //@codeaction("x + 1", "refactor.extract.variable", err=re"cannot find location to insert") |
| 32 |
|
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
-- @act -- |
| 37 |
{ |
| 38 |
"title": "Extract variable", |
| 39 |
"kind": "refactor.extract.variable", |
| 40 |
"command": { |
| 41 |
"title": "Extract variable", |
| 42 |
"command": "gopls.apply_fix", |
| 43 |
"arguments": [ |
| 44 |
{ |
| 45 |
"Fix": "extract_variable", |
| 46 |
"Location": { |
| 47 |
"uri": "$WORKDIR/resolve.go", |
| 48 |
"range": { |
| 49 |
"start": { |
| 50 |
"line": 5, |
| 51 |
"character": 16 |
| 52 |
}, |
| 53 |
"end": { |
| 54 |
"line": 5, |
| 55 |
"character": 21 |
| 56 |
} |
| 57 |
} |
| 58 |
}, |
| 59 |
"ResolveEdits": true |
| 60 |
} |
| 61 |
] |
| 62 |
} |
| 63 |
} |