(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments)
| 839 | } |
| 840 | |
| 841 | protected async variablesRequest(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments): Promise<void> { |
| 842 | if (!this.vmService) { |
| 843 | this.errorResponse(response, `No VM service connection`); |
| 844 | return; |
| 845 | } |
| 846 | |
| 847 | const variablesReference = args.variablesReference; |
| 848 | |
| 849 | // implement paged arrays |
| 850 | // let filter = args.filter; // optional; either "indexed" or "named" |
| 851 | const requestedStart = args.start; // (optional) index of the first variable to return; if omitted children start at 0 |
| 852 | const startNumeric = requestedStart || 0; |
| 853 | const requestedCount = args.count; // (optional) number of variables to return. If count is missing or 0, all variables are returned |
| 854 | |
| 855 | const data = this.threadManager.getStoredData(variablesReference); |
| 856 | if (!data) { |
| 857 | this.errorResponse(response, `Variable is no longer available (maybe debug session finished?)`); |
| 858 | return; |
| 859 | } |
| 860 | const thread = data.thread; |
| 861 | |
| 862 | if (data.data.type === "Frame") { |
| 863 | const frame: VMFrame = data.data as VMFrame; |
| 864 | let variables: DebugProtocol.Variable[] = []; |
| 865 | if (frame.vars) { |
| 866 | const framePromises = frame.vars |
| 867 | .filter((variable) => !variable.value || variable.value.type !== "@TypeArguments") |
| 868 | .map((variable, i) => this.instanceRefToVariable(thread, true, variable.name, variable.name, variable.value, i <= maxValuesToCallToString)); |
| 869 | const frameVariables = await Promise.all(framePromises); |
| 870 | variables = variables.concat(frameVariables); |
| 871 | } |
| 872 | variables = sortBy(variables, (v) => v.name); |
| 873 | response.body = { variables }; |
| 874 | this.sendResponse(response); |
| 875 | } else if (data.data.type === "MapEntry") { |
| 876 | const mapRef = data.data as VMMapEntry; |
| 877 | |
| 878 | const keyResult = this.vmService.getObject(thread.ref.id, mapRef.keyId); |
| 879 | const valueResult = this.vmService.getObject(thread.ref.id, mapRef.valueId); |
| 880 | |
| 881 | const variables: DebugProtocol.Variable[] = []; |
| 882 | let canEvaluateValueName = false; |
| 883 | let valueEvaluateName = "value"; |
| 884 | |
| 885 | try { |
| 886 | const keyDebuggerResult = await keyResult; |
| 887 | const keyInstanceRef = keyDebuggerResult.result as VMInstanceRef; |
| 888 | |
| 889 | variables.push(await this.instanceRefToVariable(thread, false, "key", "key", keyInstanceRef, true)); |
| 890 | |
| 891 | if (this.isSimpleKind(keyInstanceRef.kind) && mapRef.mapEvaluateName) { |
| 892 | canEvaluateValueName = true; |
| 893 | valueEvaluateName = `${mapRef.mapEvaluateName}[${this.valueAsString(keyInstanceRef)}]`; |
| 894 | } |
| 895 | } catch (error) { |
| 896 | variables.push({ name: "key", value: this.errorAsDisplayValue(error), variablesReference: 0 }); |
| 897 | } |
| 898 |
nothing calls this directly
no test coverage detected