|
1 |
| -import { DataExtractionResult, DataResult } from "@hediet/debug-visualizer-data-extraction"; |
| 1 | +import { DataExtractionResult, DataExtractorId, DataResult } from "@hediet/debug-visualizer-data-extraction"; |
2 | 2 | import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
3 | 3 | import { Config } from "../Config";
|
4 | 4 | import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
@@ -96,10 +96,9 @@ class RbVisualizationBackend extends VisualizationBackendBase {
|
96 | 96 | }
|
97 | 97 | };
|
98 | 98 | }
|
99 |
| - const preferredId = preferredExtractorId || ''; |
100 |
| - const wrappedExpr = ` |
101 |
| - DebugVisualizer.to_debug_visualizer_protocol_json("${preferredId}", ${expression}) |
102 |
| - `; |
| 99 | + |
| 100 | + const wrappedExpr = await this._getExpression(preferredExtractorId || '', expression, frameId); |
| 101 | + |
103 | 102 | const reply = await this.debugSession.evaluate({
|
104 | 103 | expression: wrappedExpr,
|
105 | 104 | frameId,
|
@@ -139,4 +138,21 @@ class RbVisualizationBackend extends VisualizationBackendBase {
|
139 | 138 | };
|
140 | 139 | }
|
141 | 140 | }
|
| 141 | + |
| 142 | + private async _getExpression(preferredId: string | DataExtractorId, expression: string, frameId: number | undefined) { |
| 143 | + // From version 1.7, `::DEBUGGER__::NaiveString` class is introduced to get whole body of String. |
| 144 | + // https://github.com/ruby/debug/commit/2f510f0ed685da2f78b370fb8898ffbd2a4f1cf7 |
| 145 | + const reply = await this.debugSession.evaluate({ |
| 146 | + expression: "defined? ::DEBUGGER__::NaiveString", |
| 147 | + frameId, |
| 148 | + context: this.defaultContext |
| 149 | + }); |
| 150 | + const wrappedExpr = `DebugVisualizer.to_debug_visualizer_protocol_json("${preferredId}", ${expression})`; |
| 151 | + // Because reply.result is '"constant"', we use includes method here. |
| 152 | + if (reply.result.includes('constant')) { |
| 153 | + return `::DEBUGGER__::NaiveString.new(${wrappedExpr})`; |
| 154 | + } else { |
| 155 | + return wrappedExpr; |
| 156 | + } |
| 157 | + } |
142 | 158 | }
|
0 commit comments