Eg. consider the following new test case:
func testConvertStoredToComputedPropertyWithoutTypeAnnotation() async throws {
try await assertCodeActions(
##"""
1️⃣var 2️⃣foo = "abc"3️⃣
"""##,
markers: ["2️⃣"],
ignoringCodeActions: ["Add documentation"]
) { uri, positions in
[
CodeAction(
title: "Convert to computed property",
kind: .refactorInline,
edit: WorkspaceEdit(
changes: [
uri: [
TextEdit(
range: positions["1️⃣"]..<positions["3️⃣"],
newText: """
var foo { "abc" }
"""
)
]
]
)
)
]
}
}
Notice how the generated code is invalid var foo { "abc" } because it doesn’t have a type annotation. What we should do is:
- In
ConvertStoredPropertyToComputed.Context allow specifying the type of the variable (which LSP can get via a cursor info request). The code action can then insert it. Should it not be possible to determine the type, we should insert an editor placeholder instead.
Eg. consider the following new test case:
Notice how the generated code is invalid
var foo { "abc" }because it doesn’t have a type annotation. What we should do is:ConvertStoredPropertyToComputed.Contextallow specifying the type of the variable (which LSP can get via a cursor info request). The code action can then insert it. Should it not be possible to determine the type, we should insert an editor placeholder instead.