-
Notifications
You must be signed in to change notification settings - Fork 339
Labels
code actionCode action provided by LSPCode action provided by LSP
Description
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.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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
code actionCode action provided by LSPCode action provided by LSP