Minor refactoring of @hediet/debug-visualizer-data-extraction's API. Improved documentation.

This commit is contained in:
Henning Dieterichs
2020-02-10 16:00:17 +01:00
parent a0597d428b
commit 6614198c2a
19 changed files with 400 additions and 123 deletions

View File

@@ -3,3 +3,8 @@
## 0.9.0
- Initial release
## Current
- Minor refactoring of `@hediet/debug-visualizer-data-extraction`'s API
- Improved documentation.

View File

@@ -9,12 +9,15 @@ A VS Code extension for visualizing data structures during debugging.
## Usage
After installing this extension, use the command `Open a new Debug Visualizer View` to open a new visualizer view.
In this view you can enter an expression that is visualized when debugging your application, e.g.
In this view you can enter an expression that is evaluated and visualized while stepping through your application, e.g.
```ts
{ kind: { graph: true }, nodes: [ { id: "1", label: "1" }, { id: "2", label: "2" } ], edges: [{ from: "1", to: "2", label: "edge" }]}
```
You can implement your own functions to extract this debug data from your custom data structures.
See [here](../data-extraction/README.md) for documentation of the `createGraphFromPointers` helper.
## Integrated Visualizers
Visualizers present data extracted by a _Data Extractor_.
@@ -159,6 +162,11 @@ Calls `.getDebugVisualization()` on values and treats the result as direct input
Currently, only JavaScript (and thus TypeScript) values can be visualized and only a few visualizations are supported.
The architecture is solid enough to support other languages in the future.
# `@hediet/debug-visualizer-data-extraction`
A library that provides infrastructure to implement and register custom data extractors.
See [README](../data-extraction/README.md) of the library for more info.
# See Also
This extension works very well together with my library [`@hediet/node-reload`](https://github.com/hediet/node-reload).

View File

@@ -3,8 +3,7 @@ import {
EvaluationWatcher,
EvaluationWatcherOptions,
} from "./DataSource";
import { observable, autorun } from "mobx";
import * as vscode from "vscode";
import { observable, autorun, action } from "mobx";
import { Disposable } from "@hediet/std/disposable";
import {
selfContainedGetInitializedDataExtractorApi,
@@ -156,7 +155,8 @@ export class JsDebuggerSourceImplementation implements JsDataSource {
GetDebugVisualizationDataExtractor,
].map(e => `new (${e.toString()})()`);
expression += `(${selfContainedGetInitializedDataExtractorApi.toString()})()`;
expression += `.registerExtractors([${es.join(",")}])`;
// prefer existing is true, so that manually registered extractors are not overwritten.
expression += `.registerExtractors([${es.join(",")}], true)`;
const reply = await session.evaluate({
expression,
@@ -182,12 +182,13 @@ class ObservableEvaluationWatcher implements EvaluationWatcher {
}
@observable
_preferredDataExtractor: DataExtractorId | undefined = undefined;
private _preferredDataExtractor: DataExtractorId | undefined = undefined;
get preferredDataExtractor(): DataExtractorId | undefined {
public get preferredDataExtractor(): DataExtractorId | undefined {
return this._preferredDataExtractor;
}
@action
public setPreferredDataExtractor(id: DataExtractorId | undefined): void {
this._preferredDataExtractor = id;
this.refresh();