Correct, but these would group them per workspace edit, which isn’t really what we want the label for. For example in the context of a code action (which is what would be used in LSP), the action has a single edit, which is a WorkspaceEdit. Within that edit we really don’t care about the grouping, but we care about ensuring that each individual code action has a distinguishable title.
Just to give an idea of what this would look like in a code action, here was something I was testing today:
it’s a bit nonsensical, but again, just an example
[Trace - 02:55:41 pm] Sending response 'textDocument/codeAction - (11)'. Processing request took 54ms
Result: [
{
"title": "Apply suggestion: \"pprint is outdated, update to 0.8.1\"",
"kind": "quickfix",
"diagnostics": [...],
"edit": {
"changes": {},
"documentChanges": [
{
"textDocument": {
"version": 0
},
"edits": [
{
"annotationId": "update",
"range": {
"start": {
"line": 1,
"character": 15
},
"end": {
"line": 1,
"character": 40
}
},
"newText": "com.lihaoyi::pprint:0.8.1"
}
]
}
]
}
},
{
"title": "Apply suggestion: \"pprint is outdated, update to 0.8.1\"",
"kind": "quickfix",
"diagnostics": [
{
"range": {
"start": {
"line": 1,
"character": 0
},
"end": {
"line": 1,
"character": 41
}
},
"severity": 4,
"source": "scala-cli",
"message": "\"pprint is outdated, update to 0.8.1\"\n pprint 0.8.0 -\u003e com.lihaoyi::pprint:0.8.1",
"data": {
"edits": [
{
"changes": {
"file:///Users/ckipp/Documents/scratch-workspace/actionable-diagnostic/Main.scala": [
{
"annotationId": "update",
"range": {
"start": {
"line": 1,
"character": 15
},
"end": {
"line": 1,
"character": 40
}
},
"newText": "com.lihaoyi::pprint:0.8.1"
}
]
},
"changeAnnotations": {
"update": {
"label": "Update the dep"
}
}
},
{
"changes": {
"file:///Users/ckipp/Documents/scratch-workspace/actionable-diagnostic/Main.scala": [
{
"annotationId": "remove",
"range": {
"start": {
"line": 1,
"character": 15
},
"end": {
"line": 1,
"character": 40
}
},
"newText": ""
}
]
},
"changeAnnotations": {
"remove": {
"label": "Remove the dep"
}
}
}
]
}
}
],
"edit": {
"changes": {},
"documentChanges": [
{
"textDocument": {
"version": 0
},
"edits": [
{
"annotationId": "remove",
"range": {
"start": {
"line": 1,
"character": 15
},
"end": {
"line": 1,
"character": 40
}
},
"newText": ""
}
]
}
]
}
}
]
So this example would have two independent workspace edits with a single edit each. I can’t really think of a situation where within a single workspace edit we wouldn’t want to apply all of the edits. I also can’t figure out what this looks like because for some reason in the above scenario it shows that there are no code actions available. Why? I’m not really sure. Once I switched over to documentChanges from changes everything got more convoluted and I paused because I don’t think we need this level of granularity with annotations. I’d rather just stick with the edits/resource operations and add in our own title/description at the workspace edit level that can be used when the code action is put together. It’s more minimal, would be supported by all the clients (instead of just one), and would still allow for as rich of a feature set as we need.