(Edit 2023-12-04: This request has changed slightly throughout the discussion - see #1802 (comment) below)
(from microsoft/vscode-languageserver-node#1237 (comment))
There's an itemDefaults.data field for completion that allows data to be included once in a completion response rather than duplicated across all items.
For Dart, the data field contains a mix of data that is the same for all items (eg. the file the completion is being inserted into so we can compute edits for adding imports where required - since /resolve doesn't get any context) and data that is different (an ID to get back to the element being inserted so we can resolve things like documentation). Since itemDefaults.data replaces the whole of data we can't use it here, so we end up with a large payload with a lot of duplicated into.
It would be very helpful to have an option to merge data from items over the default (for ex. Object.assign(itemDefaults.data, item.data)?).
I'm happy to send PRs for this, but I want to agree an approach first:
- Do we support merge only for
data or all fields?
- What should the merged default be called? (
itemDefaults.mergedData?)
- Is
Object.assign(itemDefaults.data, item.data) flexible enough? (you can use null to erase something from the defaults for a given item?)
- The capability can just be the client including the new field (eg.
mergedData) in the completionList.itemDefaults set?
@dbaeumer WDYT?
(Edit 2023-12-04: This request has changed slightly throughout the discussion - see #1802 (comment) below)
(from microsoft/vscode-languageserver-node#1237 (comment))
There's an
itemDefaults.datafield for completion that allowsdatato be included once in a completion response rather than duplicated across all items.For Dart, the
datafield contains a mix of data that is the same for all items (eg. the file the completion is being inserted into so we can compute edits for addingimports where required - since/resolvedoesn't get any context) and data that is different (an ID to get back to the element being inserted so we can resolve things like documentation). SinceitemDefaults.datareplaces the whole ofdatawe can't use it here, so we end up with a large payload with a lot of duplicated into.It would be very helpful to have an option to merge
datafrom items over the default (for ex.Object.assign(itemDefaults.data, item.data)?).I'm happy to send PRs for this, but I want to agree an approach first:
dataor all fields?itemDefaults.mergedData?)Object.assign(itemDefaults.data, item.data)flexible enough? (you can usenullto erase something from the defaults for a given item?)mergedData) in thecompletionList.itemDefaultsset?@dbaeumer WDYT?