| 1136 | const entriesVariableName = '[[Entries]]'; |
| 1137 | |
| 1138 | class SetOrMapVariable extends ObjectVariable { |
| 1139 | private readonly size?: number; |
| 1140 | public readonly isMap: boolean; |
| 1141 | private readonly baseChildren = once(() => super.getChildren({ variablesReference: this.id })); |
| 1142 | |
| 1143 | constructor(context: VariableContext, remoteObject: Cdp.Runtime.RemoteObject) { |
| 1144 | super(context, remoteObject, NoCustomStringRepr); |
| 1145 | this.isMap = remoteObject.subtype === 'map'; |
| 1146 | const cast = remoteObject.preview as MapPreview | SetPreview | undefined; |
| 1147 | this.size = Number(cast?.properties.find(p => p.name === 'size')?.value) ?? undefined; |
| 1148 | } |
| 1149 | |
| 1150 | public override async toDap(previewContext: PreviewContextType): Promise<Dap.Variable> { |
| 1151 | const dap = await super.toDap(previewContext); |
| 1152 | if (this.size && this.size > 100) { |
| 1153 | dap.indexedVariables = this.size; |
| 1154 | } |
| 1155 | |
| 1156 | return dap; |
| 1157 | } |
| 1158 | |
| 1159 | public override async getChildren(params: Dap.VariablesParams): Promise<Variable[]> { |
| 1160 | const baseChildren = await this.baseChildren(); |
| 1161 | const entryChildren = await baseChildren |
| 1162 | .find(c => c.name === entriesVariableName) |
| 1163 | ?.getChildren(params); |
| 1164 | |
| 1165 | return [ |
| 1166 | // filter to only show the actualy entries, not the array prototype/length |
| 1167 | ...(entryChildren || []).filter(v => v.sortOrder === SortOrder.Default), |
| 1168 | ...baseChildren.filter(c => c.name !== entriesVariableName), |
| 1169 | ]; |
| 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | class ArrayVariable extends ObjectVariable { |
| 1174 | private length = 0; |
nothing calls this directly
no test coverage detected