Merge pull request #162 from ono-max/patch-3
ruby: Support `::DEBUGGER__::NaiveString` class
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { DataExtractionResult, DataResult } from "@hediet/debug-visualizer-data-extraction";
|
import { DataExtractionResult, DataExtractorId, DataResult } from "@hediet/debug-visualizer-data-extraction";
|
||||||
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
||||||
import { Config } from "../Config";
|
import { Config } from "../Config";
|
||||||
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
||||||
@@ -96,10 +96,9 @@ class RbVisualizationBackend extends VisualizationBackendBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const preferredId = preferredExtractorId || '';
|
|
||||||
const wrappedExpr = `
|
const wrappedExpr = await this._getExpression(preferredExtractorId || '', expression, frameId);
|
||||||
DebugVisualizer.to_debug_visualizer_protocol_json("${preferredId}", ${expression})
|
|
||||||
`;
|
|
||||||
const reply = await this.debugSession.evaluate({
|
const reply = await this.debugSession.evaluate({
|
||||||
expression: wrappedExpr,
|
expression: wrappedExpr,
|
||||||
frameId,
|
frameId,
|
||||||
@@ -139,4 +138,21 @@ class RbVisualizationBackend extends VisualizationBackendBase {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _getExpression(preferredId: string | DataExtractorId, expression: string, frameId: number | undefined) {
|
||||||
|
// From version 1.7, `::DEBUGGER__::NaiveString` class is introduced to get whole body of String.
|
||||||
|
// https://github.com/ruby/debug/commit/2f510f0ed685da2f78b370fb8898ffbd2a4f1cf7
|
||||||
|
const reply = await this.debugSession.evaluate({
|
||||||
|
expression: "defined? ::DEBUGGER__::NaiveString",
|
||||||
|
frameId,
|
||||||
|
context: this.defaultContext
|
||||||
|
});
|
||||||
|
const wrappedExpr = `DebugVisualizer.to_debug_visualizer_protocol_json("${preferredId}", ${expression})`;
|
||||||
|
// Because reply.result is '"constant"', we use includes method here.
|
||||||
|
if (reply.result.includes('constant')) {
|
||||||
|
return `::DEBUGGER__::NaiveString.new(${wrappedExpr})`;
|
||||||
|
} else {
|
||||||
|
return wrappedExpr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user