| 774 | } |
| 775 | |
| 776 | class OutputVariable extends Variable { |
| 777 | constructor( |
| 778 | context: VariableContext, |
| 779 | private readonly value: string, |
| 780 | private readonly args: ReadonlyArray<Cdp.Runtime.RemoteObject>, |
| 781 | private readonly stackTrace: StackTrace | undefined, |
| 782 | ) { |
| 783 | super(context, { type: args[0]?.type ?? 'string' }); |
| 784 | } |
| 785 | |
| 786 | public override toDap(): Promise<Dap.Variable> { |
| 787 | return Promise.resolve({ |
| 788 | name: this.context.name, |
| 789 | value: this.value, |
| 790 | variablesReference: this.stackTrace || this.args.some(objectPreview.previewAsObject) |
| 791 | ? this.id |
| 792 | : 0, |
| 793 | }); |
| 794 | } |
| 795 | |
| 796 | public override getChildren(_params: Dap.VariablesParams): Promise<Variable[]> { |
| 797 | const vars: Variable[] = []; |
| 798 | const { args, stackTrace } = this; |
| 799 | for (let i = 0; i < args.length; ++i) { |
| 800 | if (objectPreview.previewAsObject(args[i])) { |
| 801 | vars.push(this.context.createVariableByType({ name: `arg${i}`, sortOrder: i }, args[i])); |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | if (stackTrace) { |
| 806 | vars.push( |
| 807 | this.context.createVariable( |
| 808 | StacktraceOutputVariable, |
| 809 | { name: '', sortOrder: Number.MAX_SAFE_INTEGER }, |
| 810 | this.remoteObject, |
| 811 | stackTrace, |
| 812 | ), |
| 813 | ); |
| 814 | } |
| 815 | |
| 816 | return Promise.resolve(vars); |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | class StacktraceOutputVariable extends Variable { |
| 821 | constructor( |
nothing calls this directly
no outgoing calls
no test coverage detected