Compare commits
80 Commits
v2.0.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbde004311 | ||
|
|
f4f227428d | ||
|
|
3d49570341 | ||
|
|
f8c740a317 | ||
|
|
8b4fc34802 | ||
|
|
b66c30b610 | ||
|
|
1d70b99f19 | ||
|
|
84762b2413 | ||
|
|
a9656e1e12 | ||
|
|
d45dfdaa71 | ||
|
|
904d0060ea | ||
|
|
1b6fabfe29 | ||
|
|
a368584adb | ||
|
|
b6a7d5e869 | ||
|
|
9684af8f94 | ||
|
|
d20d421c37 | ||
|
|
017cc54e17 | ||
|
|
5668efba0a | ||
|
|
307adad2b0 | ||
|
|
51370a519d | ||
|
|
7551b764f1 | ||
|
|
2453c8bf9c | ||
|
|
9fb1e8127a | ||
|
|
a2a5d1b873 | ||
|
|
e7e76ccfb9 | ||
|
|
e01c09eac5 | ||
|
|
86e71ae534 | ||
|
|
e46cdef402 | ||
|
|
2af8ef9a53 | ||
|
|
aa3412e6ac | ||
|
|
6543180591 | ||
|
|
cd88168211 | ||
|
|
683f1e1f76 | ||
|
|
f2b4f620fe | ||
|
|
d22e5d4111 | ||
|
|
6ce5d666a3 | ||
|
|
6da44bd722 | ||
|
|
db1e5a8086 | ||
|
|
28d02ca4ab | ||
|
|
1e65dd1990 | ||
|
|
76fa30f71a | ||
|
|
3c8ccd9a53 | ||
|
|
9c70e06ee7 | ||
|
|
8f83a1d96e | ||
|
|
9cd290ab57 | ||
|
|
061ccdca33 | ||
|
|
12099d6152 | ||
|
|
b47efb7176 | ||
|
|
ee9f405033 | ||
|
|
cc272acb06 | ||
|
|
4a81e9910b | ||
|
|
d8840bf33b | ||
|
|
e882593cea | ||
|
|
7ab4e0c4b5 | ||
|
|
4aca50f67a | ||
|
|
6ef0ecb60f | ||
|
|
0ce1b02b2c | ||
|
|
abfa44b4f9 | ||
|
|
fa1432ffc8 | ||
|
|
fc142926b8 | ||
|
|
d68d3b4076 | ||
|
|
f8c3b73d4f | ||
|
|
a8e1a5a36c | ||
|
|
d421fa1497 | ||
|
|
118d02e797 | ||
|
|
c420ff7f6f | ||
|
|
7aaebf0332 | ||
|
|
2f44c2d6f8 | ||
|
|
f5f6f5d56d | ||
|
|
3e64d3b05c | ||
|
|
0429eac23e | ||
|
|
dc9b07a4b6 | ||
|
|
2b6dbf52e9 | ||
|
|
e4606a4ae3 | ||
|
|
508062768c | ||
|
|
d7dc1f27e0 | ||
|
|
4525c226c8 | ||
|
|
c09dadb199 | ||
|
|
c88e98cc24 | ||
|
|
17be602906 |
2
.github/workflows/ci.yml
vendored
@@ -18,6 +18,6 @@ jobs:
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10.x
|
||||
node-version: 20.x
|
||||
- run: yarn install
|
||||
- run: yarn build
|
||||
|
||||
9
.gitignore
vendored
@@ -80,4 +80,11 @@ typings/
|
||||
.dynamodb/
|
||||
|
||||
dist/
|
||||
out/
|
||||
out/
|
||||
|
||||
# Python byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
*.vsix
|
||||
@@ -2,5 +2,6 @@
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 4,
|
||||
"semi": true,
|
||||
"useTabs": true
|
||||
"useTabs": true,
|
||||
"printWidth": 120
|
||||
}
|
||||
|
||||
8
.vscode/launch.json
vendored
@@ -47,7 +47,7 @@
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/extension",
|
||||
"${workspaceFolder}/demos/python"
|
||||
"${workspaceFolder}/demos/js"
|
||||
],
|
||||
"env": {
|
||||
"HOT_RELOAD": "",
|
||||
@@ -70,6 +70,12 @@
|
||||
},
|
||||
"outFiles": ["${workspaceFolder}/extension/dist/**/*.js"],
|
||||
"preLaunchTask": "npm: dev - extension"
|
||||
},
|
||||
{
|
||||
"type": "dart",
|
||||
"request": "launch",
|
||||
"name": "Run Dart samples",
|
||||
"program": "demos/dart/demo.dart"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
11
.vscode/settings.json
vendored
@@ -8,5 +8,14 @@
|
||||
"typescript.updateImportsOnFileMove.enabled": "prompt",
|
||||
"mochaExplorer.files": "./data-extraction/test/**/*.test.ts",
|
||||
"mochaExplorer.require": ["ts-node/register", "source-map-support/register"],
|
||||
"tasksStatusbar.taskLabelFilter": "dev"
|
||||
"tasksStatusbar.taskLabelFilter": "dev",
|
||||
"editor.formatOnSave": true,
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib",
|
||||
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"prettier.prettierPath": "node_modules/prettier",
|
||||
"prettier.printWidth": 120,
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,16 +42,10 @@ Implements the UI and is hosted inside a webview in VS Code.
|
||||
Can be opened in a browser window.
|
||||
Uses websockets and JSON RPC to communicate with the extension.
|
||||
|
||||
### visualization
|
||||
### hediet/visualization
|
||||
|
||||
Contains React components that visualize various JSON documents.
|
||||
Also provides infrastructure for selecting the best visualization for a given JSON document.
|
||||
|
||||
### visualization-playground
|
||||
|
||||
A playground to test and play with the visualizations for the web.
|
||||
Is hosted at [https://hediet.github.io/vscode-debug-visualizer/](https://hediet.github.io/vscode-debug-visualizer/).
|
||||
Aims to have fast build times.
|
||||
Contains all the visualizers and visualization infrastructure.
|
||||
This external project can be found [here](https://github.com/hediet/visualization).
|
||||
|
||||
### extension
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hediet/debug-visualizer-data-extraction",
|
||||
"description": "A library that helps implementing data extractors for the Debug Visualizer VS Code extension.",
|
||||
"version": "0.13.0",
|
||||
"version": "0.14.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"author": {
|
||||
@@ -28,18 +28,21 @@
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"@types/copy-webpack-plugin": "^10.1.0",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/node": "^13.7.4",
|
||||
"@types/plotly.js": "1.44.28",
|
||||
"coveralls": "^3.0.11",
|
||||
"mocha": "^7.1.1",
|
||||
"mocha-lcov-reporter": "^1.3.0",
|
||||
"nyc": "^15.0.0",
|
||||
"source-map-support": "^0.5.16",
|
||||
"typescript": "^3.8.2",
|
||||
"@types/plotly.js": "1.44.28",
|
||||
"@types/node": "^13.7.4",
|
||||
"tslint": "^6.0.0",
|
||||
"webpack": "^4.41.6",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"ts-loader": "^6.2.1"
|
||||
"tslint": "^6.1.3",
|
||||
"typescript": "^5.1.6",
|
||||
"webpack": "^5.88.1",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"ts-loader": "^9.4.4",
|
||||
"ts-node": "^10.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ export type KnownVisualizationData =
|
||||
| GridVisualizationData
|
||||
| ImageVisualizationData
|
||||
| MonacoTextVisualizationData
|
||||
| MonacoTextDiffVisualizationData
|
||||
| TableVisualizationData
|
||||
| PlotlyVisualizationData
|
||||
| SimpleTextVisualizationData
|
||||
@@ -106,7 +107,7 @@ export type GraphEdge = {
|
||||
label?: string;
|
||||
id?: string;
|
||||
color?: string;
|
||||
dashes?: boolean;
|
||||
style?: "solid" | "dashed" | "dotted";
|
||||
};
|
||||
|
||||
export type GridVisualizationData = {
|
||||
@@ -156,6 +157,50 @@ export type MonacoTextVisualizationData = {
|
||||
* The text to show
|
||||
*/
|
||||
text: string;
|
||||
decorations?: {
|
||||
range: LineColumnRange;
|
||||
label?: string;
|
||||
}[];
|
||||
/**
|
||||
* An optional filename that might be used for chosing a syntax highlighter
|
||||
*/
|
||||
fileName?: string;
|
||||
};
|
||||
|
||||
export type LineColumnRange = {
|
||||
/**
|
||||
* The start position
|
||||
*/
|
||||
start: LineColumnPosition;
|
||||
/**
|
||||
* The end position
|
||||
*/
|
||||
end: LineColumnPosition;
|
||||
};
|
||||
|
||||
export type LineColumnPosition = {
|
||||
/**
|
||||
* The 0-based line number
|
||||
*/
|
||||
line: number;
|
||||
/**
|
||||
* The 0-based column number
|
||||
*/
|
||||
column: number;
|
||||
};
|
||||
|
||||
export type MonacoTextDiffVisualizationData = {
|
||||
kind: {
|
||||
text: true;
|
||||
};
|
||||
/**
|
||||
* The text to show
|
||||
*/
|
||||
text: string;
|
||||
/**
|
||||
* The text to compare against
|
||||
*/
|
||||
otherText: string;
|
||||
/**
|
||||
* An optional filename that might be used for chosing a syntax highlighter
|
||||
*/
|
||||
@@ -183,6 +228,16 @@ export type PlotlyVisualizationData = {
|
||||
text?: string | string[];
|
||||
xaxis?: string;
|
||||
yaxis?: string;
|
||||
cells?: {
|
||||
values?: string[][];
|
||||
};
|
||||
header?: {
|
||||
values?: string[];
|
||||
};
|
||||
domain?: {
|
||||
x?: number[],
|
||||
y?: number[],
|
||||
};
|
||||
x?: (string | number | null)[] | (string | number | null)[][];
|
||||
y?: (string | number | null)[] | (string | number | null)[][];
|
||||
z?: (string | number | null)[] | (string | number | null)[][];
|
||||
@@ -212,7 +267,8 @@ export type PlotlyVisualizationData = {
|
||||
| "waterfall"
|
||||
| "funnel"
|
||||
| "funnelarea"
|
||||
| "scattermapbox";
|
||||
| "scattermapbox"
|
||||
| "table";
|
||||
mode?:
|
||||
| "lines"
|
||||
| "markers"
|
||||
|
||||
10
data-extraction/src/getGlobal.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export function getGlobal(): any {
|
||||
if (typeof globalThis === "object") {
|
||||
return globalThis;
|
||||
} else if (typeof global === "object") {
|
||||
return global;
|
||||
} else if (typeof window === "object") {
|
||||
return window;
|
||||
}
|
||||
throw new Error("No global available");
|
||||
}
|
||||
@@ -1,89 +1,133 @@
|
||||
import {
|
||||
VisualizationData,
|
||||
DataExtractionResult,
|
||||
} from "../../DataExtractionResult";
|
||||
|
||||
export interface DataExtractorApi {
|
||||
/**
|
||||
* Registers a single extractor.
|
||||
*/
|
||||
registerExtractor(extractor: DataExtractor): void;
|
||||
|
||||
/**
|
||||
* Registers multiple extractors.
|
||||
*/
|
||||
registerExtractors(extractors: DataExtractor[]): void;
|
||||
|
||||
/**
|
||||
* Extracts data from the result of `valueFn`.
|
||||
* @valueFn a function returning the value to extract the data from.
|
||||
* Is a function so that it's evaluation can depend on `evalFn`.
|
||||
*/
|
||||
getData(
|
||||
valueFn: () => unknown,
|
||||
evalFn: <T>(expression: string) => T,
|
||||
preferredDataExtractorId: string | undefined
|
||||
): JSONString<DataResult>;
|
||||
|
||||
/**
|
||||
* Registers all default (built-in) extractors.
|
||||
* @preferExisting if `true`, existing extractors with the same id are not overwritten.
|
||||
*/
|
||||
registerDefaultExtractors(preferExisting?: boolean): void;
|
||||
}
|
||||
|
||||
export type DataResult =
|
||||
| {
|
||||
kind: "Data";
|
||||
extractionResult: DataExtractionResult;
|
||||
}
|
||||
| { kind: "NoExtractors" }
|
||||
| { kind: "Error"; message: string };
|
||||
|
||||
export interface JSONString<T> extends String {
|
||||
__brand: { json: T };
|
||||
}
|
||||
|
||||
export interface DataExtractor {
|
||||
/**
|
||||
* Must be unique among all data extractors.
|
||||
*/
|
||||
id: string;
|
||||
getExtractions(
|
||||
data: unknown,
|
||||
extractionCollector: ExtractionCollector,
|
||||
context: DataExtractorContext
|
||||
): void;
|
||||
}
|
||||
|
||||
export interface ExtractionCollector {
|
||||
/**
|
||||
* Suggests a possible extraction.
|
||||
*/
|
||||
addExtraction(extraction: DataExtraction): void;
|
||||
}
|
||||
|
||||
export interface DataExtractorContext {
|
||||
/**
|
||||
* Evaluates an expression in the context of the active stack frame.
|
||||
*/
|
||||
evalFn: <TEval>(expression: string) => TEval;
|
||||
}
|
||||
|
||||
export interface DataExtraction {
|
||||
/**
|
||||
* Higher priorities are preferred.
|
||||
*/
|
||||
priority: number;
|
||||
|
||||
/**
|
||||
* A unique id identifying this extraction among all extractions.
|
||||
* Required to express extraction preferences.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* A user friendly name of this extraction.
|
||||
*/
|
||||
name: string;
|
||||
extractData(): VisualizationData;
|
||||
}
|
||||
import { DataExtractionResult, VisualizationData } from "../../DataExtractionResult";
|
||||
import { LoadDataExtractorsFn } from "./LoadDataExtractorsFn";
|
||||
|
||||
export interface DataExtractorApi {
|
||||
/**
|
||||
* Registers a single extractor.
|
||||
*/
|
||||
registerExtractor(extractor: DataExtractor): void;
|
||||
|
||||
/**
|
||||
* Registers multiple extractors.
|
||||
*/
|
||||
registerExtractors(extractors: DataExtractor[]): void;
|
||||
|
||||
/**
|
||||
* Extracts data from the result of `valueFn`.
|
||||
* @valueFn a function returning the value to extract the data from.
|
||||
* Is a function so that it's evaluation can depend on `evalFn`.
|
||||
*/
|
||||
getData(
|
||||
valueFn: () => unknown,
|
||||
evalFn: <T>(expression: string) => T,
|
||||
preferredDataExtractorId: string | undefined,
|
||||
variablesInScope: Record<string, unknown>,
|
||||
callFramesSnapshot: CallFramesSnapshot | null
|
||||
): JSONString<DataResult>;
|
||||
|
||||
/**
|
||||
* Registers all default (built-in) extractors.
|
||||
* @preferExisting if `true`, existing extractors with the same id are not overwritten.
|
||||
*/
|
||||
registerDefaultExtractors(preferExisting?: boolean): void;
|
||||
|
||||
setDataExtractorFn(id: string, fn: LoadDataExtractorsFn | undefined): void;
|
||||
}
|
||||
|
||||
export type DataResult =
|
||||
| {
|
||||
kind: "Data";
|
||||
extractionResult: DataExtractionResult;
|
||||
}
|
||||
| { kind: "NoExtractors" }
|
||||
| { kind: "Error"; message: string }
|
||||
| {
|
||||
kind: "OutdatedCallFrameSnapshot";
|
||||
callFramesRequest: CallFramesRequest;
|
||||
};
|
||||
|
||||
export interface JSONString<T> extends String {
|
||||
__brand: { json: T };
|
||||
}
|
||||
|
||||
export interface CallFramesRequest {
|
||||
requestId: string;
|
||||
requestedCallFrames: CallFrameRequest[];
|
||||
}
|
||||
|
||||
export interface CallFrameRequest {
|
||||
methodName: string;
|
||||
pathRegExp: string | undefined;
|
||||
}
|
||||
|
||||
export interface CallFramesSnapshot {
|
||||
requestId: string;
|
||||
frames: (CallFrameInfo | SkippedCallFrames)[];
|
||||
}
|
||||
|
||||
export interface SkippedCallFrames {
|
||||
skippedFrames: number;
|
||||
}
|
||||
|
||||
export interface CallFrameInfo {
|
||||
methodName: string;
|
||||
source: { name: string; path: string };
|
||||
vars: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface DataExtractor {
|
||||
/**
|
||||
* Must be unique among all data extractors.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Filters the data to be extracted.
|
||||
*/
|
||||
dataCtor?: string;
|
||||
getExtractions(data: unknown, extractionCollector: ExtractionCollector, context: DataExtractorContext): void;
|
||||
}
|
||||
|
||||
export interface ExtractionCollector {
|
||||
/**
|
||||
* Suggests a possible extraction.
|
||||
*/
|
||||
addExtraction(extraction: DataExtraction): void;
|
||||
}
|
||||
|
||||
export interface DataExtractorContext {
|
||||
/**
|
||||
* Evaluates an expression in the context of the active stack frame.
|
||||
*/
|
||||
evalFn: <TEval>(expression: string) => TEval;
|
||||
|
||||
readonly expression: string | undefined;
|
||||
|
||||
readonly variablesInScope: Record<string, () => unknown>;
|
||||
|
||||
extract(value: unknown): VisualizationData | undefined;
|
||||
|
||||
readonly callFrameInfos: readonly (CallFrameInfo | SkippedCallFrames)[];
|
||||
|
||||
addCallFrameRequest(request: CallFrameRequest): void;
|
||||
}
|
||||
|
||||
export interface DataExtraction {
|
||||
/**
|
||||
* Higher priorities are preferred.
|
||||
*/
|
||||
priority: number;
|
||||
|
||||
/**
|
||||
* A unique id identifying this extraction among all extractions.
|
||||
* Required to express extraction preferences.
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* A user friendly name of this extraction.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
extractData(): VisualizationData;
|
||||
}
|
||||
|
||||
@@ -1,91 +1,294 @@
|
||||
import {
|
||||
DataExtractorApi,
|
||||
DataResult,
|
||||
JSONString,
|
||||
DataExtractor,
|
||||
DataExtraction,
|
||||
ExtractionCollector,
|
||||
} from "./DataExtractorApi";
|
||||
import { DataExtractorInfo } from "../../DataExtractionResult";
|
||||
import { registerDefaultExtractors } from "./default-extractors";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class DataExtractorApiImpl implements DataExtractorApi {
|
||||
public static lastEvalFn: (<T>(expression: string) => T) | undefined;
|
||||
|
||||
private readonly extractors = new Map<string, DataExtractor>();
|
||||
|
||||
private toJson<TData>(data: TData): JSONString<TData> {
|
||||
return JSON.stringify(data) as any;
|
||||
}
|
||||
|
||||
public registerExtractor(extractor: DataExtractor): void {
|
||||
this.extractors.set(extractor.id, extractor);
|
||||
}
|
||||
|
||||
public registerExtractors(extractors: DataExtractor[]): void {
|
||||
for (const e of extractors) {
|
||||
this.registerExtractor(e);
|
||||
}
|
||||
}
|
||||
|
||||
public getData(
|
||||
valueFn: () => unknown,
|
||||
evalFn: <T>(expression: string) => T,
|
||||
preferredDataExtractorId: string | undefined
|
||||
): JSONString<DataResult> {
|
||||
const extractions = new Array<DataExtraction>();
|
||||
const extractionCollector: ExtractionCollector = {
|
||||
addExtraction(extraction) {
|
||||
extractions.push(extraction);
|
||||
},
|
||||
};
|
||||
|
||||
DataExtractorApiImpl.lastEvalFn = evalFn;
|
||||
const value = valueFn();
|
||||
DataExtractorApiImpl.lastEvalFn = undefined;
|
||||
|
||||
for (const e of this.extractors.values()) {
|
||||
e.getExtractions(value, extractionCollector, { evalFn });
|
||||
}
|
||||
extractions.sort((a, b) => b.priority - a.priority);
|
||||
let usedExtraction = extractions[0];
|
||||
if (!usedExtraction) {
|
||||
return this.toJson({ kind: "NoExtractors" } as DataResult);
|
||||
}
|
||||
|
||||
if (preferredDataExtractorId) {
|
||||
const preferred = extractions.find(
|
||||
e => e.id === preferredDataExtractorId
|
||||
);
|
||||
if (preferred) {
|
||||
usedExtraction = preferred;
|
||||
}
|
||||
}
|
||||
|
||||
function mapExtractor(e: DataExtraction): DataExtractorInfo {
|
||||
return {
|
||||
id: e.id as any,
|
||||
name: e.name,
|
||||
priority: e.priority,
|
||||
};
|
||||
}
|
||||
|
||||
const data = usedExtraction.extractData();
|
||||
return this.toJson({
|
||||
kind: "Data",
|
||||
extractionResult: {
|
||||
data,
|
||||
usedExtractor: mapExtractor(usedExtraction),
|
||||
availableExtractors: extractions.map(mapExtractor),
|
||||
},
|
||||
} as DataResult);
|
||||
}
|
||||
|
||||
public registerDefaultExtractors(preferExisting: boolean = false): void {
|
||||
// TODO consider preferExisting
|
||||
registerDefaultExtractors(this);
|
||||
}
|
||||
}
|
||||
import {
|
||||
DataExtractorInfo,
|
||||
VisualizationData,
|
||||
} from "../../DataExtractionResult";
|
||||
import * as helpers from "../helpers";
|
||||
import {
|
||||
CallFrameInfo,
|
||||
CallFrameRequest,
|
||||
CallFramesSnapshot,
|
||||
DataExtraction,
|
||||
DataExtractor,
|
||||
DataExtractorApi,
|
||||
DataExtractorContext,
|
||||
DataResult,
|
||||
JSONString,
|
||||
SkippedCallFrames,
|
||||
} from "./DataExtractorApi";
|
||||
import { LoadDataExtractorsFn } from "./LoadDataExtractorsFn";
|
||||
import { registerDefaultExtractors } from "./default-extractors";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export class DataExtractorApiImpl implements DataExtractorApi {
|
||||
public static lastContext: DataExtractorContext | undefined = undefined;
|
||||
|
||||
private readonly extractors = new Map<string, DataExtractor>();
|
||||
private readonly extractorSources = new Map<string, LoadDataExtractorsFn>();
|
||||
|
||||
private toJson<TData>(data: TData): JSONString<TData> {
|
||||
return JSON.stringify(data) as any;
|
||||
}
|
||||
|
||||
public registerExtractor(extractor: DataExtractor): void {
|
||||
this.extractors.set(extractor.id, extractor);
|
||||
}
|
||||
|
||||
public registerExtractors(extractors: DataExtractor[]): void {
|
||||
for (const e of extractors) {
|
||||
this.registerExtractor(e);
|
||||
}
|
||||
}
|
||||
|
||||
public getData(
|
||||
valueFn: () => unknown,
|
||||
evalFn: <T>(expression: string) => T,
|
||||
preferredDataExtractorId: string | undefined,
|
||||
variablesInScope: Record<string, () => unknown>,
|
||||
callFramesSnapshot: CallFramesSnapshot | null
|
||||
): JSONString<DataResult> {
|
||||
const callFrameRequests: CallFrameRequest[] = [];
|
||||
const rootContext = new ContextImpl(
|
||||
variablesInScope,
|
||||
removeEnd(removeStart(valueFn.toString(), "() => ("), ")").trim(),
|
||||
evalFn,
|
||||
this,
|
||||
undefined,
|
||||
callFramesSnapshot?.frames ?? [],
|
||||
callFrameRequests
|
||||
);
|
||||
|
||||
DataExtractorApiImpl.lastContext = rootContext;
|
||||
const value = valueFn();
|
||||
const extractions = this.getExtractions(value, rootContext);
|
||||
DataExtractorApiImpl.lastContext = undefined;
|
||||
|
||||
const requestId =
|
||||
callFrameRequests.length === 0
|
||||
? ""
|
||||
: "" + cyrb53(JSON.stringify(callFrameRequests));
|
||||
if ((callFramesSnapshot?.requestId ?? "") !== requestId) {
|
||||
return this.toJson({
|
||||
kind: "OutdatedCallFrameSnapshot",
|
||||
callFramesRequest: {
|
||||
requestId,
|
||||
requestedCallFrames: callFrameRequests,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let usedExtraction = extractions[0];
|
||||
if (!usedExtraction) {
|
||||
return this.toJson({ kind: "NoExtractors" } as DataResult);
|
||||
}
|
||||
|
||||
if (preferredDataExtractorId) {
|
||||
const preferred = extractions.find(
|
||||
(e) => e.id === preferredDataExtractorId
|
||||
);
|
||||
if (preferred) {
|
||||
usedExtraction = preferred;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const data = usedExtraction.extractData();
|
||||
|
||||
return this.toJson({
|
||||
kind: "Data",
|
||||
extractionResult: {
|
||||
data,
|
||||
usedExtractor: mapExtractor(usedExtraction),
|
||||
availableExtractors: extractions.map(mapExtractor),
|
||||
},
|
||||
} as DataResult);
|
||||
|
||||
} catch (e) {
|
||||
return this.toJson({
|
||||
kind: "Data",
|
||||
extractionResult: {
|
||||
data: visualizeError(e),
|
||||
usedExtractor: mapExtractor(usedExtraction),
|
||||
availableExtractors: extractions.map(mapExtractor),
|
||||
},
|
||||
} as DataResult);
|
||||
}
|
||||
}
|
||||
|
||||
public getExtractions(
|
||||
value: unknown,
|
||||
context: DataExtractorContext
|
||||
): DataExtraction[] {
|
||||
const extractions = new Array<DataExtraction>();
|
||||
const extractors = new Array<DataExtractor>();
|
||||
|
||||
for (const fn of this.extractorSources.values()) {
|
||||
try {
|
||||
fn((extractor) => {
|
||||
extractors.push(extractor);
|
||||
}, helpers);
|
||||
} catch (e) {
|
||||
console.error('Error in data extractor source', fn, e);
|
||||
}
|
||||
}
|
||||
|
||||
for (const extractor of [...this.extractors.values(), ...extractors]) {
|
||||
if (extractor.dataCtor !== undefined) {
|
||||
if (
|
||||
typeof value !== "object" ||
|
||||
value === null ||
|
||||
value.constructor.name !== extractor.dataCtor
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
extractor.getExtractions(
|
||||
value,
|
||||
{
|
||||
addExtraction(extraction) {
|
||||
if (extraction.id === undefined) {
|
||||
extraction.id = extractor.id;
|
||||
}
|
||||
if (extraction.name === undefined) {
|
||||
extraction.name = extractor.id;
|
||||
}
|
||||
extractions.push(extraction);
|
||||
},
|
||||
},
|
||||
context
|
||||
);
|
||||
} catch (e) {
|
||||
extractions.push({
|
||||
id: extractor.id,
|
||||
name: extractor.id,
|
||||
priority: 0,
|
||||
extractData() {
|
||||
return visualizeError(e);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
extractions.sort((a, b) => b.priority - a.priority);
|
||||
|
||||
return extractions;
|
||||
}
|
||||
|
||||
public registerDefaultExtractors(preferExisting: boolean = false): void {
|
||||
// TODO consider preferExisting
|
||||
registerDefaultExtractors(this);
|
||||
}
|
||||
|
||||
public setDataExtractorFn(
|
||||
id: string,
|
||||
fn: LoadDataExtractorsFn | undefined
|
||||
): void {
|
||||
if (fn) {
|
||||
this.extractorSources.set(id, fn);
|
||||
} else {
|
||||
this.extractorSources.delete(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function visualizeError(e: unknown | Error): VisualizationData {
|
||||
return helpers.asData({
|
||||
kind: { text: true },
|
||||
fileName: 'error.md',
|
||||
text: `# Error while running data extractor\n\n${formatErrorStr(e)}`,
|
||||
});
|
||||
}
|
||||
|
||||
function formatErrorStr(e: unknown | Error): string {
|
||||
if (e instanceof Error) {
|
||||
return `${e.message}\n\nStack:\n${e.stack}`;
|
||||
}
|
||||
return "" + e;
|
||||
}
|
||||
|
||||
function mapExtractor(e: DataExtraction): DataExtractorInfo {
|
||||
return {
|
||||
id: e.id! as any,
|
||||
name: e.name!,
|
||||
priority: e.priority,
|
||||
};
|
||||
}
|
||||
|
||||
class ContextImpl implements DataExtractorContext {
|
||||
constructor(
|
||||
public readonly variablesInScope: Record<string, () => unknown>,
|
||||
public readonly expression: string | undefined,
|
||||
public readonly evalFn: <T>(expression: string) => T,
|
||||
private readonly _api: DataExtractorApiImpl,
|
||||
private readonly _parent: ContextImpl | undefined,
|
||||
public readonly callFrameInfos: readonly (
|
||||
| CallFrameInfo
|
||||
| SkippedCallFrames
|
||||
)[],
|
||||
private readonly _callFrameRequests: CallFrameRequest[]
|
||||
) { }
|
||||
|
||||
addCallFrameRequest(request: CallFrameRequest): void {
|
||||
this._callFrameRequests.push(request);
|
||||
}
|
||||
|
||||
get _level(): number {
|
||||
return this._parent ? this._parent._level + 1 : 0;
|
||||
}
|
||||
|
||||
extract(value: any): VisualizationData | undefined {
|
||||
if (this._level > 10) {
|
||||
throw new Error("extract() called too many times recursively");
|
||||
}
|
||||
|
||||
const extractions = this._api.getExtractions(
|
||||
value,
|
||||
new ContextImpl(
|
||||
this.variablesInScope,
|
||||
undefined,
|
||||
this.evalFn,
|
||||
this._api,
|
||||
this,
|
||||
this.callFrameInfos,
|
||||
this._callFrameRequests
|
||||
)
|
||||
);
|
||||
if (extractions.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return extractions[0].extractData();
|
||||
}
|
||||
}
|
||||
|
||||
function removeStart(str: string, start: string): string {
|
||||
if (str.startsWith(start)) {
|
||||
return str.substr(start.length);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function removeEnd(str: string, end: string): string {
|
||||
if (str.endsWith(end)) {
|
||||
return str.substr(0, str.length - end.length);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
// From https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
|
||||
function cyrb53(str: string, seed = 0) {
|
||||
let h1 = 0xdeadbeef ^ seed,
|
||||
h2 = 0x41c6ce57 ^ seed;
|
||||
for (let i = 0, ch; i < str.length; i++) {
|
||||
ch = str.charCodeAt(i);
|
||||
h1 = Math.imul(h1 ^ ch, 2654435761);
|
||||
h2 = Math.imul(h2 ^ ch, 1597334677);
|
||||
}
|
||||
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
|
||||
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
|
||||
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
|
||||
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
|
||||
|
||||
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
|
||||
}
|
||||
|
||||
7
data-extraction/src/js/api/LoadDataExtractorsFn.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { DataExtractor } from "./DataExtractorApi";
|
||||
import type * as helpersTypes from "../helpers"
|
||||
|
||||
export type LoadDataExtractorsFn = (
|
||||
register: (extractor: DataExtractor) => void,
|
||||
helpers: typeof helpersTypes
|
||||
) => void;
|
||||
@@ -24,7 +24,7 @@ export class GridExtractor implements DataExtractor {
|
||||
extractData: () =>
|
||||
expect<GridVisualizationData>({
|
||||
kind: { grid: true },
|
||||
rows: [{ columns: data.map(d => ({ tag: d })) }],
|
||||
rows: [{ columns: data.map(d => ({ tag: "" + d })) }],
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { DataExtractor, ExtractionCollector, DataExtractorContext } from "..";
|
||||
import { LineColumnRange } from "../../../CommonDataTypes";
|
||||
import { asData, markedGrid, tryEval } from "../../helpers";
|
||||
|
||||
export class MarkedGridFromArrayExtractor implements DataExtractor {
|
||||
readonly id = "markedGridFromArray";
|
||||
getExtractions(
|
||||
data: unknown,
|
||||
collector: ExtractionCollector,
|
||||
context: DataExtractorContext
|
||||
): void {
|
||||
if (!Array.isArray(data)) {
|
||||
return;
|
||||
}
|
||||
if (!Array.isArray(data[0])) {
|
||||
return;
|
||||
}
|
||||
|
||||
let markers: any;
|
||||
if (data.length === 2 && typeof data[1] === "object") {
|
||||
markers = data[1];
|
||||
} else {
|
||||
for (let i = 1; i < data.length; i++) {
|
||||
if (typeof data[i] !== "string") {
|
||||
return;
|
||||
}
|
||||
}
|
||||
markers = tryEval(data.slice(1));
|
||||
}
|
||||
|
||||
collector.addExtraction({
|
||||
id: "markedGridFromArray",
|
||||
name: "Marked Grid from Array",
|
||||
priority: 1000,
|
||||
extractData() {
|
||||
return markedGrid(data[0], markers as any);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,12 @@ import {
|
||||
ExtractionCollector,
|
||||
DataExtractorContext,
|
||||
} from "../DataExtractorApi";
|
||||
import { createGraph, CreateGraphEdge } from "../../helpers";
|
||||
import {
|
||||
createGraph,
|
||||
CreateGraphEdge,
|
||||
createGraphFromPointers,
|
||||
} from "../../helpers";
|
||||
import { GraphNode } from "../../..";
|
||||
|
||||
export class ObjectGraphExtractor implements DataExtractor {
|
||||
readonly id = "object-graph";
|
||||
@@ -27,53 +32,83 @@ export class ObjectGraphExtractor implements DataExtractor {
|
||||
return;
|
||||
}
|
||||
|
||||
const infoSelector: (item: object) => {
|
||||
id?: string | number;
|
||||
edges: CreateGraphEdge<object>[];
|
||||
} & Omit<GraphNode, "id"> = (item) => {
|
||||
let label = "";
|
||||
const edges = new Array<CreateGraphEdge<any>>();
|
||||
if (item instanceof Set) {
|
||||
label = "Set";
|
||||
for (const value of item.values()) {
|
||||
if (isObject(value)) {
|
||||
edges.push({ label: "item", to: value });
|
||||
}
|
||||
}
|
||||
} else if (item instanceof Map) {
|
||||
label = "Map";
|
||||
for (const [key, value] of item.entries()) {
|
||||
if (isObject(value)) {
|
||||
edges.push({ label: key, to: value });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const [key, val] of Object.entries(item)) {
|
||||
if (isObject(val)) {
|
||||
edges.push({ label: key, to: val });
|
||||
}
|
||||
}
|
||||
|
||||
const className = item.constructor
|
||||
? item.constructor.name
|
||||
: "?";
|
||||
label = className;
|
||||
if (!Array.isArray(item)) {
|
||||
try {
|
||||
let toStrVal = item.toString();
|
||||
if (toStrVal !== "[object Object]") {
|
||||
if (toStrVal.length > 15) {
|
||||
toStrVal += ` "${toStrVal.substr(0, 15)}..."`;
|
||||
}
|
||||
label += `${className}: ${toStrVal}`;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
shape: "box",
|
||||
edges,
|
||||
color: item === data ? "lightblue" : undefined,
|
||||
label,
|
||||
};
|
||||
};
|
||||
|
||||
collector.addExtraction({
|
||||
id: "object-graph",
|
||||
name: "Object Graph",
|
||||
priority: 99,
|
||||
priority: 98,
|
||||
extractData() {
|
||||
return createGraph(
|
||||
[data],
|
||||
item => {
|
||||
let label = "";
|
||||
const edges = new Array<CreateGraphEdge<any>>();
|
||||
if (item instanceof Set) {
|
||||
label = "Set";
|
||||
for (const value of item.values()) {
|
||||
if (isObject(value)) {
|
||||
edges.push({ label: "item", to: value });
|
||||
}
|
||||
}
|
||||
} else if (item instanceof Map) {
|
||||
label = "Map";
|
||||
for (const [key, value] of item.entries()) {
|
||||
if (isObject(value)) {
|
||||
edges.push({ label: key, to: value });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const [key, val] of Object.entries(item)) {
|
||||
if (isObject(val)) {
|
||||
edges.push({ label: key, to: val });
|
||||
}
|
||||
}
|
||||
|
||||
const className = item.constructor
|
||||
? item.constructor.name
|
||||
: "?";
|
||||
label = className;
|
||||
}
|
||||
|
||||
return {
|
||||
shape: "box",
|
||||
edges,
|
||||
color: item === data ? "lightblue" : undefined,
|
||||
label,
|
||||
};
|
||||
},
|
||||
{ maxSize: 50 }
|
||||
);
|
||||
return createGraph([data], infoSelector, { maxSize: 50 });
|
||||
},
|
||||
});
|
||||
|
||||
if (
|
||||
data.constructor === Object &&
|
||||
Object.values(data).every(
|
||||
(v) => v === undefined || v === null || typeof v === "object"
|
||||
)
|
||||
) {
|
||||
collector.addExtraction({
|
||||
id: "object-graph-pointers",
|
||||
name: "Object Graph With Pointers",
|
||||
priority: 99,
|
||||
extractData() {
|
||||
return createGraphFromPointers(data as any, infoSelector, {
|
||||
maxSize: 50,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
DataExtractor,
|
||||
DataExtractorContext,
|
||||
ExtractionCollector,
|
||||
} from "../..";
|
||||
|
||||
export class StringDiffExtractor implements DataExtractor {
|
||||
public readonly id = "string-diff";
|
||||
|
||||
public getExtractions(
|
||||
data: unknown,
|
||||
collector: ExtractionCollector,
|
||||
context: DataExtractorContext
|
||||
) {
|
||||
if (
|
||||
Array.isArray(data) &&
|
||||
data.length === 2 &&
|
||||
typeof data[0] === "string" &&
|
||||
typeof data[1] === "string"
|
||||
) {
|
||||
collector.addExtraction({
|
||||
id: "string-diff",
|
||||
name: "String Diff",
|
||||
priority: 1300,
|
||||
extractData: () => ({
|
||||
kind: { text: true },
|
||||
text: data[0],
|
||||
otherText: data[1],
|
||||
}),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { DataExtractor, ExtractionCollector, DataExtractorContext } from "..";
|
||||
import { LineColumnRange } from "../../../CommonDataTypes";
|
||||
import { asData } from "../../helpers";
|
||||
|
||||
export class StringRangeExtractor implements DataExtractor {
|
||||
readonly id = "stringRange";
|
||||
getExtractions(
|
||||
data: unknown,
|
||||
collector: ExtractionCollector,
|
||||
context: DataExtractorContext
|
||||
): void {
|
||||
if (!Array.isArray(data)) {
|
||||
return;
|
||||
}
|
||||
if (typeof data[0] !== "string") {
|
||||
return;
|
||||
}
|
||||
|
||||
const text = data[0];
|
||||
|
||||
const decorations1: { range: LineColumnRange; label?: string }[] = [];
|
||||
const decorations2: { range: LineColumnRange; label?: string }[] = [];
|
||||
|
||||
function offsetToLineColumn(offset: number) {
|
||||
let line = 0;
|
||||
let column = 0;
|
||||
for (let idx = 0; idx < text.length; idx++) {
|
||||
if (idx === offset) {
|
||||
return { line, column };
|
||||
}
|
||||
if (text[idx] === "\n") {
|
||||
line++;
|
||||
column = 0;
|
||||
} else {
|
||||
column++;
|
||||
}
|
||||
}
|
||||
return { line, column }; // TODO
|
||||
}
|
||||
|
||||
if (
|
||||
data.length === 2 &&
|
||||
typeof data[1] === "object" &&
|
||||
!Array.isArray(data[1])
|
||||
) {
|
||||
data = [data[0], ...Object.values(data[1])] as [
|
||||
number | [number, number]
|
||||
][];
|
||||
}
|
||||
|
||||
for (let item of (data as (number | [number, number])[]).slice(1)) {
|
||||
if (typeof item === "string") {
|
||||
try {
|
||||
item = context.evalFn(item);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
if (item === undefined) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof item === "number") {
|
||||
const pos = offsetToLineColumn(item);
|
||||
decorations1.push({ range: { start: pos, end: pos } });
|
||||
decorations2.push({
|
||||
range: {
|
||||
start: pos,
|
||||
end: { line: pos.line, column: pos.column + 1 },
|
||||
},
|
||||
});
|
||||
} else if (
|
||||
Array.isArray(item) &&
|
||||
item.length === 2 &&
|
||||
typeof item[0] === "number" &&
|
||||
typeof item[1] === "number"
|
||||
) {
|
||||
decorations1.push({
|
||||
range: {
|
||||
start: offsetToLineColumn(item[0]),
|
||||
end: offsetToLineColumn(item[1]),
|
||||
},
|
||||
});
|
||||
decorations2.push(decorations1[decorations1.length - 1]);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
collector.addExtraction({
|
||||
priority: 1200,
|
||||
id: "stringRange",
|
||||
name: "String Range",
|
||||
extractData() {
|
||||
return asData({
|
||||
kind: { text: true },
|
||||
text,
|
||||
decorations: decorations1,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
collector.addExtraction({
|
||||
priority: 1000,
|
||||
id: "stringRangeFullCharacters",
|
||||
name: "String Range (Full Character)",
|
||||
extractData() {
|
||||
return asData({
|
||||
kind: { text: true },
|
||||
text,
|
||||
decorations: decorations2,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { isAssertionExpression } from "typescript";
|
||||
import { DataExtractor, ExtractionCollector, DataExtractorContext } from "..";
|
||||
import { TableVisualizationData } from "../../../CommonDataTypes";
|
||||
import { expect } from "../../../util";
|
||||
|
||||
function assert<T>(value: unknown): asserts value {}
|
||||
|
||||
export class TableDataExtractor implements DataExtractor {
|
||||
readonly id = "table";
|
||||
|
||||
getExtractions(
|
||||
data: unknown,
|
||||
collector: ExtractionCollector,
|
||||
context: DataExtractorContext
|
||||
): void {
|
||||
if (!Array.isArray(data)) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!data.every((d) => typeof d === "object" && d && !Array.isArray(d))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
assert<object[]>(data);
|
||||
|
||||
collector.addExtraction({
|
||||
id: "table",
|
||||
name: "Table",
|
||||
priority: 1000,
|
||||
extractData() {
|
||||
return expect<TableVisualizationData>({
|
||||
kind: {
|
||||
table: true,
|
||||
},
|
||||
rows: data,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
collector.addExtraction({
|
||||
id: "table-with-type-name",
|
||||
name: "Table (With Type Name)",
|
||||
priority: 950,
|
||||
extractData() {
|
||||
return expect<TableVisualizationData>({
|
||||
kind: {
|
||||
table: true,
|
||||
},
|
||||
rows: data.map((d) => ({ type: d.constructor.name, ...d })),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,7 @@ export class TypeScriptAstDataExtractor implements DataExtractor {
|
||||
root: helper.toTreeNode(
|
||||
rootNode || finalRootSourceFile,
|
||||
"root",
|
||||
"",
|
||||
marked,
|
||||
fn
|
||||
),
|
||||
@@ -121,19 +122,24 @@ export class TypeScriptAstDataExtractor implements DataExtractor {
|
||||
class Helper {
|
||||
constructor(private readonly tsApi: typeof ts) {}
|
||||
|
||||
findKey(value: any, object: any): string | null {
|
||||
for (var key in object) {
|
||||
if (key.startsWith("_")) continue;
|
||||
getPropertyNameInParent(value: any, parent: any): string | undefined {
|
||||
for (const propertyName in parent) {
|
||||
if (propertyName.startsWith("_")) continue;
|
||||
|
||||
var member = object[key];
|
||||
if (member === value) return key;
|
||||
const member = parent[propertyName];
|
||||
if (member === value) {
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
if (Array.isArray(member) && member.indexOf(value) !== -1) {
|
||||
return key;
|
||||
if (Array.isArray(member)) {
|
||||
const index = member.indexOf(value);
|
||||
if (index !== -1) {
|
||||
return `${propertyName}[${index}]`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getChildren(node: ts.Node): ts.Node[] {
|
||||
@@ -147,30 +153,38 @@ class Helper {
|
||||
toTreeNode(
|
||||
node: ts.Node,
|
||||
memberName: string,
|
||||
segmentName: string,
|
||||
marked: Set<ts.Node>,
|
||||
emphasizedValueFn: (node: ts.Node) => string | undefined
|
||||
): AstTreeNode {
|
||||
const name = this.tsApi.SyntaxKind[node.kind];
|
||||
const children = this.getChildren(node)
|
||||
.map((childNode, idx) => {
|
||||
let parentPropertyName = this.findKey(childNode, node) || "";
|
||||
let parentPropertyName =
|
||||
this.getPropertyNameInParent(childNode, node) || "";
|
||||
|
||||
if (childNode.kind == this.tsApi.SyntaxKind.SyntaxList) {
|
||||
const children = this.getChildren(childNode);
|
||||
children.some(c => {
|
||||
parentPropertyName = this.findKey(c, node) || "";
|
||||
return !!parentPropertyName;
|
||||
});
|
||||
|
||||
if (children.length === 0) return null!;
|
||||
for (const c of children) {
|
||||
const name =
|
||||
this.getPropertyNameInParent(c, node) || "";
|
||||
if (name) {
|
||||
parentPropertyName = name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let segmentName = "." + parentPropertyName;
|
||||
if (node.kind == this.tsApi.SyntaxKind.SyntaxList) {
|
||||
parentPropertyName = "" + idx;
|
||||
segmentName = `[${idx}]`;
|
||||
}
|
||||
|
||||
return this.toTreeNode(
|
||||
childNode,
|
||||
parentPropertyName,
|
||||
segmentName,
|
||||
marked,
|
||||
emphasizedValueFn
|
||||
);
|
||||
@@ -201,6 +215,7 @@ class Helper {
|
||||
return {
|
||||
items,
|
||||
children: children,
|
||||
segment: segmentName,
|
||||
span: {
|
||||
length: node.end - node.pos,
|
||||
start: node.pos,
|
||||
|
||||
@@ -7,6 +7,10 @@ import { PlotlyDataExtractor } from "./PlotlyDataExtractor";
|
||||
import { ObjectGraphExtractor } from "./ObjectGraphExtractor";
|
||||
import { getDataExtractorApi } from "../injection";
|
||||
import { GridExtractor } from "./GridExtractor";
|
||||
import { TableDataExtractor } from "./TableExtractor";
|
||||
import { StringDiffExtractor } from "./StringDiffExtractor";
|
||||
import { StringRangeExtractor } from "./StringRangeExtractor";
|
||||
import { MarkedGridFromArrayExtractor } from "./MarkedGridExtractor";
|
||||
|
||||
/**
|
||||
* The default data extractors should be registered by VS Code automatically.
|
||||
@@ -23,6 +27,10 @@ export function registerDefaultExtractors(
|
||||
new PlotlyDataExtractor(),
|
||||
new ObjectGraphExtractor(),
|
||||
new GridExtractor(),
|
||||
new TableDataExtractor(),
|
||||
new StringDiffExtractor(),
|
||||
new StringRangeExtractor(),
|
||||
new MarkedGridFromArrayExtractor(),
|
||||
]) {
|
||||
api.registerExtractor(item);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./DataExtractorApi";
|
||||
export * from "./injection";
|
||||
export { DataExtractorApiImpl } from "./DataExtractorApiImpl";
|
||||
export * from "./LoadDataExtractorsFn";
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import * as fs from "fs";
|
||||
import { getGlobal } from "../../getGlobal";
|
||||
import * as globalHelpers from "../global-helpers";
|
||||
import * as helpers from "../helpers";
|
||||
import { DataExtractorApi } from "./DataExtractorApi";
|
||||
import { DataExtractorApiImpl } from "./DataExtractorApiImpl";
|
||||
import * as helpers from "../helpers";
|
||||
import * as globalHelpers from "../global-helpers";
|
||||
|
||||
/**
|
||||
* Returns standalone JS code representing an expression that initializes the data extraction API.
|
||||
@@ -20,22 +21,19 @@ export function getExpressionToInitializeDataExtractorApi(): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns standalone JS code representing an expression returns the data extraction API.
|
||||
* Returns standalone JS code representing an expression that returns the data extraction API.
|
||||
* This expression returns an object of type `DataExtractorApi`.
|
||||
* If the API must be initialized with `getExpressionToInitializeDataExtractorApi()`,
|
||||
* it throws an exception containing the text of `ApiHasNotBeenInitializedCode`.
|
||||
* This function is called in the VS Code extension, the expression is evaluated in the debugee.
|
||||
*/
|
||||
export function getExpressionForDataExtractorApi(): string {
|
||||
return `((${selfContainedGetInitializedDataExtractorApi.toString()})())`;
|
||||
}
|
||||
|
||||
const apiKey = "@hediet/data-extractor-api/v2";
|
||||
const apiKey = "@hediet/data-extractor-api/v3";
|
||||
|
||||
export function getDataExtractorApi(): DataExtractorApi {
|
||||
installHelpers();
|
||||
const globalObj =
|
||||
typeof window === "object" ? (window as any) : (global as any);
|
||||
const globalObj = getGlobal();
|
||||
if (!globalObj[apiKey]) {
|
||||
globalObj[apiKey] = new DataExtractorApiImpl();
|
||||
}
|
||||
@@ -46,29 +44,38 @@ export function getDataExtractorApi(): DataExtractorApi {
|
||||
* This code is used to detect if the API has not been initialized yet.
|
||||
* @internal
|
||||
*/
|
||||
export const ApiHasNotBeenInitializedCode = "EgH0cybXij1jYUozyakO" as const;
|
||||
export const ApiHasNotBeenInitializedCode = "EgH0cybXij1jYUozyakO" as const;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function selfContainedGetInitializedDataExtractorApi(): DataExtractorApi {
|
||||
const globalObj =
|
||||
typeof window === "object" ? (window as any) : (global as any);
|
||||
const key: typeof apiKey = "@hediet/data-extractor-api/v2";
|
||||
let api: DataExtractorApi | undefined = globalObj[key];
|
||||
if (!api) {
|
||||
const code: typeof ApiHasNotBeenInitializedCode =
|
||||
"EgH0cybXij1jYUozyakO";
|
||||
throw new Error(
|
||||
`Data Extractor API has not been initialized. Code: ${code}`
|
||||
);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function selfContainedGetInitializedDataExtractorApi(): DataExtractorApi {
|
||||
function getGlobal(): any {
|
||||
if (typeof globalThis === "object") {
|
||||
return globalThis;
|
||||
} else if (typeof global === "object") {
|
||||
return global;
|
||||
} else if (typeof window === "object") {
|
||||
return window;
|
||||
}
|
||||
throw new Error("No global available");
|
||||
}
|
||||
return api;
|
||||
}
|
||||
|
||||
const globalObj = getGlobal();
|
||||
const key: typeof apiKey = "@hediet/data-extractor-api/v3";
|
||||
let api: DataExtractorApi | undefined = globalObj[key];
|
||||
if (!api) {
|
||||
const code: typeof ApiHasNotBeenInitializedCode =
|
||||
"EgH0cybXij1jYUozyakO";
|
||||
throw new Error(
|
||||
`Data Extractor API has not been initialized. Code: ${code}`
|
||||
);
|
||||
}
|
||||
return api;
|
||||
}
|
||||
|
||||
export function installHelpers(): void {
|
||||
const globalObj =
|
||||
typeof window === "object" ? (window as any) : (global as any);
|
||||
const globalObj = getGlobal();
|
||||
// `hediet` as prefix to avoid name collision (I own `hediet.de`).
|
||||
globalObj["hedietDbgVis"] = { ...helpers, ...globalHelpers };
|
||||
}
|
||||
|
||||
6
data-extraction/src/js/helpers/asData.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { KnownVisualizationData } from "../../CommonDataTypes";
|
||||
import { VisualizationData } from "../../DataExtractionResult";
|
||||
|
||||
export function asData(data: KnownVisualizationData): VisualizationData {
|
||||
return data;
|
||||
}
|
||||
@@ -12,8 +12,8 @@ export function cache<T>(
|
||||
let resultFn: () => any;
|
||||
let key: string;
|
||||
if (typeof expression === "string") {
|
||||
const evalFn = DataExtractorApiImpl.lastEvalFn!;
|
||||
resultFn = () => evalFn(expression);
|
||||
const context = DataExtractorApiImpl.lastContext!;
|
||||
resultFn = () => context.evalFn(expression);
|
||||
key = JSON.stringify({ expr: expression, id });
|
||||
} else {
|
||||
resultFn = () => expression();
|
||||
|
||||
@@ -4,7 +4,8 @@ import {
|
||||
GraphVisualizationData,
|
||||
} from "../../CommonDataTypes";
|
||||
|
||||
export type CreateGraphEdge<T> = { to: T } & Omit<GraphEdge, "from" | "to">;
|
||||
export type CreateGraphEdge<T> = ({ to: T } | { from: T } | { include: T }) &
|
||||
Omit<GraphEdge, "from" | "to">;
|
||||
|
||||
/**
|
||||
* Given a list of roots, it creates a graph by following their edges recursively.
|
||||
@@ -58,13 +59,31 @@ export function createGraph<T>(
|
||||
const fromId = getId(item);
|
||||
r.nodes.push({ ...nodeInfo, id: fromId, ["edges" as any]: undefined });
|
||||
for (const e of nodeInfo.edges) {
|
||||
const toId = getId(e.to);
|
||||
r.edges.push({
|
||||
...e,
|
||||
from: fromId,
|
||||
to: toId,
|
||||
});
|
||||
let shouldPush = !processed.has(e.to);
|
||||
let other: T;
|
||||
let toId: string | undefined;
|
||||
let fromId_: string | undefined;
|
||||
if ("to" in e) {
|
||||
other = e.to;
|
||||
toId = getId(e.to);
|
||||
fromId_ = fromId;
|
||||
} else if ("from" in e) {
|
||||
other = e.from;
|
||||
toId = getId(e.from);
|
||||
fromId_ = fromId;
|
||||
} else if ("include" in e) {
|
||||
other = e.include;
|
||||
} else {
|
||||
throw new Error("Every edge must either have 'to' or 'from'");
|
||||
}
|
||||
|
||||
if (fromId_ !== undefined && toId !== undefined) {
|
||||
r.edges.push({
|
||||
...e,
|
||||
from: fromId_,
|
||||
to: toId,
|
||||
});
|
||||
}
|
||||
let shouldPush = !processed.has(other);
|
||||
if (
|
||||
options.maxSize &&
|
||||
processed.size + queue.length > options.maxSize
|
||||
@@ -72,7 +91,7 @@ export function createGraph<T>(
|
||||
shouldPush = false;
|
||||
}
|
||||
if (shouldPush) {
|
||||
queue.push({ item: e.to, dist: dist + 1 });
|
||||
queue.push({ item: other, dist: dist + 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,11 @@ import { CreateGraphEdge, createGraph } from "./createGraph";
|
||||
*/
|
||||
export function createGraphFromPointers<T>(
|
||||
roots: Record<string, T | undefined | null>,
|
||||
infoSelector: (
|
||||
item: T
|
||||
) => {
|
||||
infoSelector: (item: T) => {
|
||||
id?: string | number;
|
||||
edges: CreateGraphEdge<T>[];
|
||||
} & Omit<GraphNode, "id">
|
||||
} & Omit<GraphNode, "id">,
|
||||
options: { maxSize?: number } = {}
|
||||
): GraphVisualizationData {
|
||||
const marker = {};
|
||||
|
||||
@@ -28,18 +27,27 @@ export function createGraphFromPointers<T>(
|
||||
value,
|
||||
}));
|
||||
|
||||
return createGraph<T | Pointer>(items, item => {
|
||||
if ("marker" in item && item["marker"] === marker) {
|
||||
return {
|
||||
id: "label____" + item.name,
|
||||
color: "orange",
|
||||
label: item.name,
|
||||
edges: [{ to: item.value!, color: "orange", label: "" }].filter(
|
||||
t => !!t.to
|
||||
),
|
||||
};
|
||||
} else {
|
||||
return infoSelector(item as T);
|
||||
}
|
||||
});
|
||||
return createGraph<T | Pointer>(
|
||||
items,
|
||||
(item) => {
|
||||
if (
|
||||
typeof item === "object" &&
|
||||
item &&
|
||||
"marker" in item &&
|
||||
item["marker"] === marker
|
||||
) {
|
||||
return {
|
||||
id: "label____" + item.name,
|
||||
color: "orange",
|
||||
label: item.name,
|
||||
edges: [
|
||||
{ to: item.value!, color: "orange", label: "" },
|
||||
].filter((t) => !!t.to),
|
||||
};
|
||||
} else {
|
||||
return infoSelector(item as T);
|
||||
}
|
||||
},
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
136
data-extraction/src/js/helpers/find.ts
Normal file
@@ -0,0 +1,136 @@
|
||||
import { DataExtractorApiImpl } from "../api";
|
||||
|
||||
export function find(predicate: (obj: unknown) => boolean): unknown {
|
||||
const processed = new Set();
|
||||
if (!DataExtractorApiImpl.lastContext) {
|
||||
throw new Error("No data extractor context!");
|
||||
}
|
||||
|
||||
const values = Object.values(
|
||||
DataExtractorApiImpl.lastContext.variablesInScope
|
||||
);
|
||||
const queue = [
|
||||
...values.map((v) => {
|
||||
try {
|
||||
return v();
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}),
|
||||
];
|
||||
|
||||
let i = 10000;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
|
||||
const top = queue.shift();
|
||||
processed.add(top);
|
||||
|
||||
if (predicate(top)) {
|
||||
return top;
|
||||
}
|
||||
|
||||
if (typeof top === "object" && top) {
|
||||
for (const val of Object.values(top)) {
|
||||
if (!processed.has(val)) {
|
||||
processed.add(val);
|
||||
queue.push(val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function findVar(
|
||||
options: { nameSimilarTo?: string; ctor?: string },
|
||||
predicate?: (value: any) => boolean
|
||||
): unknown | undefined {
|
||||
if (!DataExtractorApiImpl.lastContext) {
|
||||
throw new Error("No data extractor context!");
|
||||
}
|
||||
|
||||
let bestValue = undefined;
|
||||
let bestValueScore = undefined; // minimized
|
||||
|
||||
for (const [name, value] of Object.entries(
|
||||
DataExtractorApiImpl.lastContext.variablesInScope
|
||||
)) {
|
||||
const v = value();
|
||||
if (options.ctor !== undefined) {
|
||||
if (
|
||||
typeof v !== "object" ||
|
||||
!v ||
|
||||
v.constructor.name !== options.ctor
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (predicate) {
|
||||
if (!predicate(v)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let score = 0;
|
||||
if (options.nameSimilarTo !== undefined) {
|
||||
score += similarityScore(name, options.nameSimilarTo);
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
if (bestValueScore === undefined || score < bestValueScore) {
|
||||
bestValue = v;
|
||||
bestValueScore = score;
|
||||
}
|
||||
}
|
||||
|
||||
return bestValue;
|
||||
}
|
||||
|
||||
function similarityScore(a: string, b: string): number {
|
||||
const distance = levenshteinDistance(a, b);
|
||||
|
||||
const aSorted = a.split("").sort().join("");
|
||||
const bSorted = b.split("").sort().join("");
|
||||
const distance2 = levenshteinDistance(aSorted, bSorted);
|
||||
|
||||
return distance * 10 + distance2;
|
||||
}
|
||||
|
||||
function levenshteinDistance(a: string, b: string): number {
|
||||
if (a.length === 0) return b.length;
|
||||
if (b.length === 0) return a.length;
|
||||
|
||||
const matrix = [];
|
||||
|
||||
// increment along the first column of each row
|
||||
let i;
|
||||
for (i = 0; i <= b.length; i++) {
|
||||
matrix[i] = [i];
|
||||
}
|
||||
|
||||
// increment each column in the first row
|
||||
let j;
|
||||
for (j = 0; j <= a.length; j++) {
|
||||
matrix[0][j] = j;
|
||||
}
|
||||
|
||||
// Fill in the rest of the matrix
|
||||
for (i = 1; i <= b.length; i++) {
|
||||
for (j = 1; j <= a.length; j++) {
|
||||
if (b.charAt(i - 1) == a.charAt(j - 1)) {
|
||||
matrix[i][j] = matrix[i - 1][j - 1];
|
||||
} else {
|
||||
matrix[i][j] = Math.min(
|
||||
matrix[i - 1][j - 1] + 1, // substitution
|
||||
Math.min(
|
||||
matrix[i][j - 1] + 1, // insertion
|
||||
matrix[i - 1][j] + 1
|
||||
)
|
||||
); // deletion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matrix[b.length][a.length];
|
||||
}
|
||||
@@ -3,3 +3,5 @@ export * from "./createGraphFromPointers";
|
||||
export * from "./tryEval";
|
||||
export * from "./markedGrid";
|
||||
export * from "./cache";
|
||||
export * from "./asData";
|
||||
export * from "./find";
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
import { GridVisualizationData } from "../../CommonDataTypes";
|
||||
|
||||
export function markedGrid(
|
||||
arr: any[],
|
||||
marked: Record<string, number>
|
||||
arr: unknown[],
|
||||
marked: Record<string, number | undefined>
|
||||
): GridVisualizationData {
|
||||
if (!Array.isArray(arr)) {
|
||||
arr = [...(arr as any)];
|
||||
}
|
||||
|
||||
return {
|
||||
kind: { grid: true },
|
||||
rows: [{ columns: arr.map(d => ({ tag: d })) }],
|
||||
markers: Object.entries(marked).map(([key, val]) => ({
|
||||
id: key,
|
||||
row: 0,
|
||||
column: val,
|
||||
})),
|
||||
rows: [
|
||||
{
|
||||
columns: arr.map((d) => ({
|
||||
content: "" + d,
|
||||
tag: "" + d,
|
||||
})),
|
||||
},
|
||||
],
|
||||
markers: marked
|
||||
? Object.entries(marked)
|
||||
.map(([key, val]) => ({
|
||||
id: "" + key,
|
||||
row: 0,
|
||||
column: val!,
|
||||
}))
|
||||
.filter((c) => c.column !== undefined)
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,17 +30,17 @@ export function tryEval(
|
||||
obj: Record<string, string> | string[] | string
|
||||
): Record<string, unknown> | unknown {
|
||||
const result: Record<string, unknown> = {};
|
||||
const evalFn = DataExtractorApiImpl.lastEvalFn!;
|
||||
const context = DataExtractorApiImpl.lastContext!;
|
||||
if (Array.isArray(obj)) {
|
||||
for (const val of obj) {
|
||||
try {
|
||||
result[val] = evalFn(val);
|
||||
result[val] = context.evalFn(val);
|
||||
} catch (e) {}
|
||||
}
|
||||
} else {
|
||||
for (const [key, val] of Object.entries(obj)) {
|
||||
try {
|
||||
result[key] = evalFn(val);
|
||||
result[key] = context.evalFn(val);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"target": "ES2018",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"outDir": "./dist",
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
require("ts-node").register();
|
||||
module.exports = require("./webpack.config.ts");
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as webpack from "webpack";
|
||||
import path = require("path");
|
||||
import { CleanWebpackPlugin } from "clean-webpack-plugin";
|
||||
import * as path from "path";
|
||||
import * as webpack from "webpack";
|
||||
|
||||
const r = (file: string) => path.resolve(__dirname, file);
|
||||
|
||||
|
||||
2920
data-extraction/yarn.lock
Normal file
85
demos/dart/debug_visualizers.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'dart:convert';
|
||||
|
||||
String graph(List<GraphNode> nodes, List<GraphEdge> edges) {
|
||||
return jsonEncode({
|
||||
'kind': {'graph': true},
|
||||
'nodes': nodes,
|
||||
'edges': edges,
|
||||
});
|
||||
}
|
||||
|
||||
String plotly(List<num> values) {
|
||||
return jsonEncode({
|
||||
'kind': {'plotly': true},
|
||||
'data': [
|
||||
{'y': values}
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
String tree(TreeNode root) {
|
||||
return jsonEncode({
|
||||
'kind': {'tree': true},
|
||||
'root': root,
|
||||
});
|
||||
}
|
||||
|
||||
class Graph {
|
||||
List<GraphNode> nodes;
|
||||
List<GraphEdge> edges;
|
||||
}
|
||||
|
||||
class GraphEdge {
|
||||
final String from;
|
||||
final String to;
|
||||
final String label;
|
||||
|
||||
GraphEdge(this.from, this.to, this.label);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'from': from,
|
||||
'to': to,
|
||||
'label': label,
|
||||
};
|
||||
}
|
||||
|
||||
class GraphNode {
|
||||
final String id;
|
||||
final String label;
|
||||
|
||||
GraphNode(
|
||||
this.id,
|
||||
this.label,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'label': label,
|
||||
};
|
||||
}
|
||||
|
||||
class TreeNode {
|
||||
final List<TreeNode> children;
|
||||
final List<TreeNodeItem> items;
|
||||
final String segment;
|
||||
final bool isMarked;
|
||||
|
||||
TreeNode(this.children, this.items, this.segment, [this.isMarked = false]);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'children': children ?? [],
|
||||
'items': items,
|
||||
'segment': segment,
|
||||
'isMarked': isMarked,
|
||||
};
|
||||
}
|
||||
|
||||
class TreeNodeItem {
|
||||
final String text;
|
||||
|
||||
TreeNodeItem(this.text);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'text': text,
|
||||
};
|
||||
}
|
||||
83
demos/dart/demo.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'dart:collection';
|
||||
import 'dart:developer';
|
||||
import 'dart:math';
|
||||
|
||||
// ignore: unused_import
|
||||
import 'debug_visualizers.dart';
|
||||
|
||||
final _rnd = Random();
|
||||
|
||||
String Function() visualize;
|
||||
|
||||
void main() {
|
||||
debugger();
|
||||
// Open a Debug Visualizer window and evalute the expression "visualize()"
|
||||
// and then press Continue to step through the samples.
|
||||
plotly_demo();
|
||||
graph_demo();
|
||||
tree_demo();
|
||||
}
|
||||
|
||||
void plotly_demo() {
|
||||
final values = <int>[];
|
||||
visualize = () => plotly(values);
|
||||
for (var i = 0; i < 20; i++) {
|
||||
debugger();
|
||||
values.add(i + _rnd.nextInt(5) - 2);
|
||||
}
|
||||
}
|
||||
|
||||
void graph_demo() {
|
||||
graphFromDoubleLinked<T>(
|
||||
DoubleLinkedQueue<T> values, String Function(T) toString) {
|
||||
node(T s) => GraphNode(toString(s), toString(s));
|
||||
edge(DoubleLinkedQueueEntry<T> e) => [
|
||||
if (e.nextEntry() != null)
|
||||
GraphEdge(
|
||||
toString(e.element),
|
||||
toString(e.nextEntry().element),
|
||||
"next",
|
||||
),
|
||||
if (e.previousEntry() != null)
|
||||
GraphEdge(
|
||||
toString(e.element),
|
||||
toString(e.previousEntry().element),
|
||||
"prev",
|
||||
),
|
||||
];
|
||||
|
||||
final nodes = values.map(node).toList();
|
||||
final edges = <GraphEdge>[];
|
||||
values.forEachEntry((e) => edges.addAll(edge(e)));
|
||||
return graph(nodes, edges);
|
||||
}
|
||||
|
||||
final values = DoubleLinkedQueue<String>();
|
||||
visualize = () => graphFromDoubleLinked(values, (s) => s);
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
debugger();
|
||||
values.addLast('Node $i');
|
||||
}
|
||||
}
|
||||
|
||||
void tree_demo() {
|
||||
var nodeNum = 1;
|
||||
TreeNode createNode(int levels) {
|
||||
final name = 'Node ${nodeNum++}';
|
||||
final children =
|
||||
levels > 0 ? List.generate(2, (_) => createNode(levels - 1)) : null;
|
||||
return TreeNode(children, [TreeNodeItem(name)], name);
|
||||
}
|
||||
|
||||
var levels = 0;
|
||||
visualize = () {
|
||||
nodeNum = 1;
|
||||
return tree(createNode(levels));
|
||||
};
|
||||
|
||||
for (var i = 1; i < 5; i++) {
|
||||
debugger();
|
||||
levels = i;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>java</name>
|
||||
<comment/>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
<name>java</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1599063072264</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
|
||||
8
demos/js/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"editor.minimap.enabled": false,
|
||||
"git.enabled": false,
|
||||
"typescript.tsc.autoDetect": "off",
|
||||
"debugVisualizer.js.customScriptPaths": [
|
||||
"${workspaceFolder}/custom-visualizer.js",
|
||||
]
|
||||
}
|
||||
59
demos/js/custom-visualizer.js
Normal file
@@ -0,0 +1,59 @@
|
||||
// @ts-check
|
||||
/**
|
||||
* @type {import("@hediet/debug-visualizer-data-extraction").LoadDataExtractorsFn}
|
||||
*/
|
||||
module.exports = (register, helpers) => {
|
||||
register({
|
||||
id: "map",
|
||||
getExtractions(data, collector, context) {
|
||||
if (!(data instanceof Map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
collector.addExtraction({
|
||||
priority: 1000,
|
||||
id: "map",
|
||||
name: "Map",
|
||||
extractData() {
|
||||
return helpers.asData({
|
||||
kind: { table: true },
|
||||
rows: [...data].map(([k, v]) => ({ key: k, value: v }))
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
register({
|
||||
id: "binaryViewer",
|
||||
getExtractions(data, collector, context) {
|
||||
if (typeof data !== "number") {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
context.addCallFrameRequest({
|
||||
methodName: "Module._load",
|
||||
pathRegExp: ".*",
|
||||
});
|
||||
|
||||
context.addCallFrameRequest({
|
||||
methodName: "LinkedList.insertAt",
|
||||
pathRegExp: ".*",
|
||||
});*/
|
||||
|
||||
collector.addExtraction({
|
||||
priority: 10000,
|
||||
id: "binary",
|
||||
name: "Bits of Integer",
|
||||
extractData() {
|
||||
return context.extract(JSON.stringify(context.callFrameInfos, undefined, 4));
|
||||
|
||||
return helpers.asData({
|
||||
kind: { text: true },
|
||||
text: data.toString(2),
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -5,6 +5,7 @@
|
||||
"dependencies": {
|
||||
"@hediet/node-reload": "0.7.3",
|
||||
"@types/node": "^13.7.4",
|
||||
"node-fetch": "^2.6.1",
|
||||
"typescript": "^3.8.2"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
807
demos/js/src/demo_address_book.ts
Normal file
@@ -0,0 +1,807 @@
|
||||
|
||||
class Person {
|
||||
constructor(public id: number, public firstName: string, public lastName: string, public email: string, public gender: string, public company: string) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Company {
|
||||
constructor(public id: number, public name: string, public street: string, public email: string) { }
|
||||
}
|
||||
|
||||
class AddressBook {
|
||||
public static loadPersons(): Person[] {
|
||||
const contactsData = [{
|
||||
"id": 1,
|
||||
"first_name": "Burg",
|
||||
"last_name": "Legg",
|
||||
"email": "blegg0@elpais.com",
|
||||
"gender": "Male",
|
||||
"company": "Zoozzy"
|
||||
}, {
|
||||
"id": 2,
|
||||
"first_name": "Erminia",
|
||||
"last_name": "Heersema",
|
||||
"email": "eheersema1@jugem.jp",
|
||||
"gender": "Female",
|
||||
"company": "Skipfire"
|
||||
}, {
|
||||
"id": 3,
|
||||
"first_name": "Penrod",
|
||||
"last_name": "Claxton",
|
||||
"email": "pclaxton2@furl.net",
|
||||
"gender": "Male",
|
||||
"company": "Dabvine"
|
||||
}, {
|
||||
"id": 4,
|
||||
"first_name": "Peterus",
|
||||
"last_name": "Alabone",
|
||||
"email": "palabone3@icio.us",
|
||||
"gender": "Male",
|
||||
"company": "Gabtune"
|
||||
}, {
|
||||
"id": 5,
|
||||
"first_name": "Rickie",
|
||||
"last_name": "Belsher",
|
||||
"email": "rbelsher4@marketwatch.com",
|
||||
"gender": "Male",
|
||||
"company": "Digitube"
|
||||
}, {
|
||||
"id": 6,
|
||||
"first_name": "Griffie",
|
||||
"last_name": "Poulsum",
|
||||
"email": "gpoulsum5@printfriendly.com",
|
||||
"gender": "Male",
|
||||
"company": "Mymm"
|
||||
}, {
|
||||
"id": 7,
|
||||
"first_name": "Fidelio",
|
||||
"last_name": "Gateland",
|
||||
"email": "fgateland6@intel.com",
|
||||
"gender": "Male",
|
||||
"company": "Meeveo"
|
||||
}, {
|
||||
"id": 8,
|
||||
"first_name": "Fayth",
|
||||
"last_name": "D'Oyly",
|
||||
"email": "fdoyly7@twitter.com",
|
||||
"gender": "Female",
|
||||
"company": "Podcat"
|
||||
}, {
|
||||
"id": 9,
|
||||
"first_name": "Janela",
|
||||
"last_name": "Shelton",
|
||||
"email": "jshelton8@dion.ne.jp",
|
||||
"gender": "Female",
|
||||
"company": "Kayveo"
|
||||
}, {
|
||||
"id": 10,
|
||||
"first_name": "Yance",
|
||||
"last_name": "Vatcher",
|
||||
"email": "yvatcher9@ask.com",
|
||||
"gender": "Male",
|
||||
"company": "Photobug"
|
||||
}, {
|
||||
"id": 11,
|
||||
"first_name": "Filippo",
|
||||
"last_name": "Timoney",
|
||||
"email": "ftimoneya@spotify.com",
|
||||
"gender": "Male",
|
||||
"company": "Rhyzio"
|
||||
}, {
|
||||
"id": 12,
|
||||
"first_name": "Helli",
|
||||
"last_name": "Friskey",
|
||||
"email": "hfriskeyb@usa.gov",
|
||||
"gender": "Female",
|
||||
"company": "Eare"
|
||||
}, {
|
||||
"id": 13,
|
||||
"first_name": "Enos",
|
||||
"last_name": "Connick",
|
||||
"email": "econnickc@sitemeter.com",
|
||||
"gender": "Male",
|
||||
"company": "Meetz"
|
||||
}, {
|
||||
"id": 14,
|
||||
"first_name": "Lorri",
|
||||
"last_name": "Chessun",
|
||||
"email": "lchessund@wp.com",
|
||||
"gender": "Female",
|
||||
"company": "Jaxworks"
|
||||
}, {
|
||||
"id": 15,
|
||||
"first_name": "Justina",
|
||||
"last_name": "Spedroni",
|
||||
"email": "jspedronie@abc.net.au",
|
||||
"gender": "Female",
|
||||
"company": "Rhyzio"
|
||||
}, {
|
||||
"id": 16,
|
||||
"first_name": "Odilia",
|
||||
"last_name": "Ealden",
|
||||
"email": "oealdenf@fastcompany.com",
|
||||
"gender": "Female",
|
||||
"company": "Blognation"
|
||||
}, {
|
||||
"id": 17,
|
||||
"first_name": "Dale",
|
||||
"last_name": "Bretherick",
|
||||
"email": "dbretherickg@dmoz.org",
|
||||
"gender": "Male",
|
||||
"company": "Skipfire"
|
||||
}, {
|
||||
"id": 18,
|
||||
"first_name": "Syman",
|
||||
"last_name": "Lawdham",
|
||||
"email": "slawdhamh@so-net.ne.jp",
|
||||
"gender": "Male",
|
||||
"company": "Wordify"
|
||||
}, {
|
||||
"id": 19,
|
||||
"first_name": "Catarina",
|
||||
"last_name": "Stoile",
|
||||
"email": "cstoilei@hud.gov",
|
||||
"gender": "Female",
|
||||
"company": "Avaveo"
|
||||
}, {
|
||||
"id": 20,
|
||||
"first_name": "Simonette",
|
||||
"last_name": "Danett",
|
||||
"email": "sdanettj@eepurl.com",
|
||||
"gender": "Female",
|
||||
"company": "Realblab"
|
||||
}, {
|
||||
"id": 21,
|
||||
"first_name": "Fielding",
|
||||
"last_name": "MacHarg",
|
||||
"email": "fmachargk@blogtalkradio.com",
|
||||
"gender": "Male",
|
||||
"company": "Photolist"
|
||||
}, {
|
||||
"id": 22,
|
||||
"first_name": "Anni",
|
||||
"last_name": "Hounsom",
|
||||
"email": "ahounsoml@wikia.com",
|
||||
"gender": "Female",
|
||||
"company": "Devify"
|
||||
}, {
|
||||
"id": 23,
|
||||
"first_name": "Evelin",
|
||||
"last_name": "Gaytor",
|
||||
"email": "egaytorm@myspace.com",
|
||||
"gender": "Male",
|
||||
"company": "Aivee"
|
||||
}, {
|
||||
"id": 24,
|
||||
"first_name": "Lynde",
|
||||
"last_name": "Itscowicz",
|
||||
"email": "litscowiczn@fc2.com",
|
||||
"gender": "Female",
|
||||
"company": "Skipfire"
|
||||
}, {
|
||||
"id": 25,
|
||||
"first_name": "Reta",
|
||||
"last_name": "Felipe",
|
||||
"email": "rfelipeo@free.fr",
|
||||
"gender": "Female",
|
||||
"company": "Ainyx"
|
||||
}, {
|
||||
"id": 26,
|
||||
"first_name": "Bar",
|
||||
"last_name": "Shillingford",
|
||||
"email": "bshillingfordp@sun.com",
|
||||
"gender": "Male",
|
||||
"company": "Skilith"
|
||||
}, {
|
||||
"id": 27,
|
||||
"first_name": "Mel",
|
||||
"last_name": "Cooch",
|
||||
"email": "mcoochq@icq.com",
|
||||
"gender": "Female",
|
||||
"company": "Meevee"
|
||||
}, {
|
||||
"id": 28,
|
||||
"first_name": "Wheeler",
|
||||
"last_name": "Kettlesting",
|
||||
"email": "wkettlestingr@miitbeian.gov.cn",
|
||||
"gender": "Male",
|
||||
"company": "Mybuzz"
|
||||
}, {
|
||||
"id": 29,
|
||||
"first_name": "Corabel",
|
||||
"last_name": "Pordall",
|
||||
"email": "cpordalls@sourceforge.net",
|
||||
"gender": "Female",
|
||||
"company": "Blogtag"
|
||||
}, {
|
||||
"id": 30,
|
||||
"first_name": "Merrily",
|
||||
"last_name": "Weatherhill",
|
||||
"email": "mweatherhillt@printfriendly.com",
|
||||
"gender": "Female",
|
||||
"company": "Divape"
|
||||
}, {
|
||||
"id": 31,
|
||||
"first_name": "Reynard",
|
||||
"last_name": "Osgodby",
|
||||
"email": "rosgodbyu@eepurl.com",
|
||||
"gender": "Male",
|
||||
"company": "Yakijo"
|
||||
}, {
|
||||
"id": 32,
|
||||
"first_name": "Guilbert",
|
||||
"last_name": "Bilston",
|
||||
"email": "gbilstonv@devhub.com",
|
||||
"gender": "Male",
|
||||
"company": "Vinder"
|
||||
}, {
|
||||
"id": 33,
|
||||
"first_name": "Farr",
|
||||
"last_name": "Skehan",
|
||||
"email": "fskehanw@t-online.de",
|
||||
"gender": "Male",
|
||||
"company": "Linkbuzz"
|
||||
}, {
|
||||
"id": 34,
|
||||
"first_name": "Roger",
|
||||
"last_name": "Langelay",
|
||||
"email": "rlangelayx@pcworld.com",
|
||||
"gender": "Male",
|
||||
"company": "Tekfly"
|
||||
}, {
|
||||
"id": 35,
|
||||
"first_name": "Jemmy",
|
||||
"last_name": "Yggo",
|
||||
"email": "jyggoy@ifeng.com",
|
||||
"gender": "Female",
|
||||
"company": "Jabberstorm"
|
||||
}, {
|
||||
"id": 36,
|
||||
"first_name": "Cybill",
|
||||
"last_name": "Chastaing",
|
||||
"email": "cchastaingz@mayoclinic.com",
|
||||
"gender": "Female",
|
||||
"company": "Riffpedia"
|
||||
}, {
|
||||
"id": 37,
|
||||
"first_name": "Samuele",
|
||||
"last_name": "Zorzoni",
|
||||
"email": "szorzoni10@opensource.org",
|
||||
"gender": "Male",
|
||||
"company": "Devcast"
|
||||
}, {
|
||||
"id": 38,
|
||||
"first_name": "Svend",
|
||||
"last_name": "Hamill",
|
||||
"email": "shamill11@google.co.jp",
|
||||
"gender": "Male",
|
||||
"company": "Kwilith"
|
||||
}, {
|
||||
"id": 39,
|
||||
"first_name": "Carlin",
|
||||
"last_name": "Roote",
|
||||
"email": "croote12@gov.uk",
|
||||
"gender": "Male",
|
||||
"company": "Twitterlist"
|
||||
}, {
|
||||
"id": 40,
|
||||
"first_name": "Dawna",
|
||||
"last_name": "Lanfer",
|
||||
"email": "dlanfer13@mlb.com",
|
||||
"gender": "Female",
|
||||
"company": "Jayo"
|
||||
}, {
|
||||
"id": 41,
|
||||
"first_name": "Melissa",
|
||||
"last_name": "Chappelow",
|
||||
"email": "mchappelow14@usa.gov",
|
||||
"gender": "Female",
|
||||
"company": "Skibox"
|
||||
}, {
|
||||
"id": 42,
|
||||
"first_name": "George",
|
||||
"last_name": "Hargreaves",
|
||||
"email": "ghargreaves15@pagesperso-orange.fr",
|
||||
"gender": "Female",
|
||||
"company": "Zazio"
|
||||
}, {
|
||||
"id": 43,
|
||||
"first_name": "Sampson",
|
||||
"last_name": "Steaning",
|
||||
"email": "ssteaning16@state.gov",
|
||||
"gender": "Male",
|
||||
"company": "Jaxworks"
|
||||
}, {
|
||||
"id": 44,
|
||||
"first_name": "Brana",
|
||||
"last_name": "Wims",
|
||||
"email": "bwims17@icio.us",
|
||||
"gender": "Female",
|
||||
"company": "Flashset"
|
||||
}, {
|
||||
"id": 45,
|
||||
"first_name": "Shawn",
|
||||
"last_name": "Saffen",
|
||||
"email": "ssaffen18@shutterfly.com",
|
||||
"gender": "Male",
|
||||
"company": "Twitterwire"
|
||||
}, {
|
||||
"id": 46,
|
||||
"first_name": "Alessandro",
|
||||
"last_name": "Gasker",
|
||||
"email": "agasker19@slashdot.org",
|
||||
"gender": "Male",
|
||||
"company": "Dabtype"
|
||||
}, {
|
||||
"id": 47,
|
||||
"first_name": "Bobby",
|
||||
"last_name": "Mulcock",
|
||||
"email": "bmulcock1a@time.com",
|
||||
"gender": "Female",
|
||||
"company": "Quamba"
|
||||
}, {
|
||||
"id": 48,
|
||||
"first_name": "Ashlen",
|
||||
"last_name": "Midner",
|
||||
"email": "amidner1b@devhub.com",
|
||||
"gender": "Female",
|
||||
"company": "Thoughtstorm"
|
||||
}, {
|
||||
"id": 49,
|
||||
"first_name": "Mallory",
|
||||
"last_name": "Joel",
|
||||
"email": "mjoel1c@upenn.edu",
|
||||
"gender": "Male",
|
||||
"company": "Twitterbeat"
|
||||
}, {
|
||||
"id": 50,
|
||||
"first_name": "Maximilian",
|
||||
"last_name": "Scraggs",
|
||||
"email": "mscraggs1d@ucla.edu",
|
||||
"gender": "Male",
|
||||
"company": "Twiyo"
|
||||
}, {
|
||||
"id": 51,
|
||||
"first_name": "Beverlie",
|
||||
"last_name": "Pittet",
|
||||
"email": "bpittet1e@github.io",
|
||||
"gender": "Female",
|
||||
"company": "Riffpath"
|
||||
}, {
|
||||
"id": 52,
|
||||
"first_name": "Enrique",
|
||||
"last_name": "Rentilll",
|
||||
"email": "erentilll1f@smugmug.com",
|
||||
"gender": "Male",
|
||||
"company": "Blognation"
|
||||
}, {
|
||||
"id": 53,
|
||||
"first_name": "Cathrin",
|
||||
"last_name": "McKendry",
|
||||
"email": "cmckendry1g@hc360.com",
|
||||
"gender": "Female",
|
||||
"company": "Shuffledrive"
|
||||
}, {
|
||||
"id": 54,
|
||||
"first_name": "Isabeau",
|
||||
"last_name": "Quincey",
|
||||
"email": "iquincey1h@msn.com",
|
||||
"gender": "Female",
|
||||
"company": "Tagcat"
|
||||
}, {
|
||||
"id": 55,
|
||||
"first_name": "Geoffrey",
|
||||
"last_name": "Grzegorczyk",
|
||||
"email": "ggrzegorczyk1i@loc.gov",
|
||||
"gender": "Male",
|
||||
"company": "Youfeed"
|
||||
}, {
|
||||
"id": 56,
|
||||
"first_name": "Ruggiero",
|
||||
"last_name": "Vaar",
|
||||
"email": "rvaar1j@unesco.org",
|
||||
"gender": "Male",
|
||||
"company": "Babbleset"
|
||||
}, {
|
||||
"id": 57,
|
||||
"first_name": "Alfonso",
|
||||
"last_name": "Tarzey",
|
||||
"email": "atarzey1k@weebly.com",
|
||||
"gender": "Male",
|
||||
"company": "Pixonyx"
|
||||
}, {
|
||||
"id": 58,
|
||||
"first_name": "Marylin",
|
||||
"last_name": "Bissex",
|
||||
"email": "mbissex1l@microsoft.com",
|
||||
"gender": "Female",
|
||||
"company": "Tagfeed"
|
||||
}, {
|
||||
"id": 59,
|
||||
"first_name": "Cathryn",
|
||||
"last_name": "Morhall",
|
||||
"email": "cmorhall1m@irs.gov",
|
||||
"gender": "Female",
|
||||
"company": "Tagopia"
|
||||
}, {
|
||||
"id": 60,
|
||||
"first_name": "Terza",
|
||||
"last_name": "Easey",
|
||||
"email": "teasey1n@thetimes.co.uk",
|
||||
"gender": "Female",
|
||||
"company": "Devcast"
|
||||
}, {
|
||||
"id": 61,
|
||||
"first_name": "Hale",
|
||||
"last_name": "Gaudon",
|
||||
"email": "hgaudon1o@webnode.com",
|
||||
"gender": "Male",
|
||||
"company": "Quinu"
|
||||
}, {
|
||||
"id": 62,
|
||||
"first_name": "Hadley",
|
||||
"last_name": "Elwood",
|
||||
"email": "helwood1p@japanpost.jp",
|
||||
"gender": "Male",
|
||||
"company": "Plajo"
|
||||
}, {
|
||||
"id": 63,
|
||||
"first_name": "Seamus",
|
||||
"last_name": "Straker",
|
||||
"email": "sstraker1q@live.com",
|
||||
"gender": "Male",
|
||||
"company": "Yoveo"
|
||||
}, {
|
||||
"id": 64,
|
||||
"first_name": "Urbano",
|
||||
"last_name": "Gisbey",
|
||||
"email": "ugisbey1r@sitemeter.com",
|
||||
"gender": "Male",
|
||||
"company": "Quinu"
|
||||
}, {
|
||||
"id": 65,
|
||||
"first_name": "Gerri",
|
||||
"last_name": "McInulty",
|
||||
"email": "gmcinulty1s@businessinsider.com",
|
||||
"gender": "Male",
|
||||
"company": "Agimba"
|
||||
}, {
|
||||
"id": 66,
|
||||
"first_name": "Lena",
|
||||
"last_name": "Gonthier",
|
||||
"email": "lgonthier1t@newsvine.com",
|
||||
"gender": "Female",
|
||||
"company": "Geba"
|
||||
}, {
|
||||
"id": 67,
|
||||
"first_name": "Ameline",
|
||||
"last_name": "Wheatcroft",
|
||||
"email": "awheatcroft1u@163.com",
|
||||
"gender": "Female",
|
||||
"company": "Twitternation"
|
||||
}, {
|
||||
"id": 68,
|
||||
"first_name": "Kathryn",
|
||||
"last_name": "Castelli",
|
||||
"email": "kcastelli1v@about.com",
|
||||
"gender": "Female",
|
||||
"company": "Photospace"
|
||||
}, {
|
||||
"id": 69,
|
||||
"first_name": "Terrell",
|
||||
"last_name": "Walicki",
|
||||
"email": "twalicki1w@amazon.co.jp",
|
||||
"gender": "Male",
|
||||
"company": "Babblestorm"
|
||||
}, {
|
||||
"id": 70,
|
||||
"first_name": "Claudianus",
|
||||
"last_name": "Tremathack",
|
||||
"email": "ctremathack1x@walmart.com",
|
||||
"gender": "Male",
|
||||
"company": "Skyndu"
|
||||
}, {
|
||||
"id": 71,
|
||||
"first_name": "Sanford",
|
||||
"last_name": "Devinn",
|
||||
"email": "sdevinn1y@ehow.com",
|
||||
"gender": "Male",
|
||||
"company": "Dynazzy"
|
||||
}, {
|
||||
"id": 72,
|
||||
"first_name": "Gwendolen",
|
||||
"last_name": "Turfrey",
|
||||
"email": "gturfrey1z@va.gov",
|
||||
"gender": "Female",
|
||||
"company": "Yacero"
|
||||
}, {
|
||||
"id": 73,
|
||||
"first_name": "Alta",
|
||||
"last_name": "Leap",
|
||||
"email": "aleap20@ezinearticles.com",
|
||||
"gender": "Female",
|
||||
"company": "Twitterlist"
|
||||
}, {
|
||||
"id": 74,
|
||||
"first_name": "Johnath",
|
||||
"last_name": "Andrzejowski",
|
||||
"email": "jandrzejowski21@google.com.hk",
|
||||
"gender": "Female",
|
||||
"company": "Lazzy"
|
||||
}, {
|
||||
"id": 75,
|
||||
"first_name": "Yancy",
|
||||
"last_name": "Askham",
|
||||
"email": "yaskham22@sciencedaily.com",
|
||||
"gender": "Male",
|
||||
"company": "Yabox"
|
||||
}, {
|
||||
"id": 76,
|
||||
"first_name": "Paula",
|
||||
"last_name": "Warder",
|
||||
"email": "pwarder23@harvard.edu",
|
||||
"gender": "Female",
|
||||
"company": "Zooxo"
|
||||
}, {
|
||||
"id": 77,
|
||||
"first_name": "Grannie",
|
||||
"last_name": "Hauxley",
|
||||
"email": "ghauxley24@symantec.com",
|
||||
"gender": "Male",
|
||||
"company": "Yakidoo"
|
||||
}, {
|
||||
"id": 78,
|
||||
"first_name": "Enid",
|
||||
"last_name": "Grealy",
|
||||
"email": "egrealy25@homestead.com",
|
||||
"gender": "Female",
|
||||
"company": "Gabcube"
|
||||
}, {
|
||||
"id": 79,
|
||||
"first_name": "Lazarus",
|
||||
"last_name": "Itscowicz",
|
||||
"email": "litscowicz26@epa.gov",
|
||||
"gender": "Male",
|
||||
"company": "Demizz"
|
||||
}, {
|
||||
"id": 80,
|
||||
"first_name": "Marmaduke",
|
||||
"last_name": "Gilligan",
|
||||
"email": "mgilligan27@tiny.cc",
|
||||
"gender": "Male",
|
||||
"company": "Yombu"
|
||||
}, {
|
||||
"id": 81,
|
||||
"first_name": "Linnell",
|
||||
"last_name": "Chree",
|
||||
"email": "lchree28@ocn.ne.jp",
|
||||
"gender": "Female",
|
||||
"company": "Buzzshare"
|
||||
}, {
|
||||
"id": 82,
|
||||
"first_name": "Pavia",
|
||||
"last_name": "Pocke",
|
||||
"email": "ppocke29@newsvine.com",
|
||||
"gender": "Female",
|
||||
"company": "Eidel"
|
||||
}, {
|
||||
"id": 83,
|
||||
"first_name": "Golda",
|
||||
"last_name": "Stuchburie",
|
||||
"email": "gstuchburie2a@oaic.gov.au",
|
||||
"gender": "Female",
|
||||
"company": "Flipstorm"
|
||||
}, {
|
||||
"id": 84,
|
||||
"first_name": "Trace",
|
||||
"last_name": "Lodge",
|
||||
"email": "tlodge2b@whitehouse.gov",
|
||||
"gender": "Male",
|
||||
"company": "Zazio"
|
||||
}, {
|
||||
"id": 85,
|
||||
"first_name": "Nikolia",
|
||||
"last_name": "Bartolomivis",
|
||||
"email": "nbartolomivis2c@opensource.org",
|
||||
"gender": "Female",
|
||||
"company": "Devshare"
|
||||
}, {
|
||||
"id": 86,
|
||||
"first_name": "Dela",
|
||||
"last_name": "Wimp",
|
||||
"email": "dwimp2d@miitbeian.gov.cn",
|
||||
"gender": "Female",
|
||||
"company": "Wordware"
|
||||
}, {
|
||||
"id": 87,
|
||||
"first_name": "Rustie",
|
||||
"last_name": "Drury",
|
||||
"email": "rdrury2e@sun.com",
|
||||
"gender": "Male",
|
||||
"company": "Youbridge"
|
||||
}, {
|
||||
"id": 88,
|
||||
"first_name": "Phedra",
|
||||
"last_name": "Shrimptone",
|
||||
"email": "pshrimptone2f@unicef.org",
|
||||
"gender": "Female",
|
||||
"company": "Realcube"
|
||||
}, {
|
||||
"id": 89,
|
||||
"first_name": "Alaster",
|
||||
"last_name": "Vittori",
|
||||
"email": "avittori2g@senate.gov",
|
||||
"gender": "Male",
|
||||
"company": "Livepath"
|
||||
}, {
|
||||
"id": 90,
|
||||
"first_name": "Pascal",
|
||||
"last_name": "Neissen",
|
||||
"email": "pneissen2h@mediafire.com",
|
||||
"gender": "Male",
|
||||
"company": "Mydo"
|
||||
}, {
|
||||
"id": 91,
|
||||
"first_name": "Brian",
|
||||
"last_name": "Manuel",
|
||||
"email": "bmanuel2i@blog.com",
|
||||
"gender": "Male",
|
||||
"company": "Roomm"
|
||||
}, {
|
||||
"id": 92,
|
||||
"first_name": "Jen",
|
||||
"last_name": "Laydon",
|
||||
"email": "jlaydon2j@hubpages.com",
|
||||
"gender": "Female",
|
||||
"company": "Plambee"
|
||||
}, {
|
||||
"id": 93,
|
||||
"first_name": "Beltran",
|
||||
"last_name": "Brandoni",
|
||||
"email": "bbrandoni2k@digg.com",
|
||||
"gender": "Male",
|
||||
"company": "Yacero"
|
||||
}, {
|
||||
"id": 94,
|
||||
"first_name": "Sarene",
|
||||
"last_name": "Gaymar",
|
||||
"email": "sgaymar2l@surveymonkey.com",
|
||||
"gender": "Female",
|
||||
"company": "Katz"
|
||||
}, {
|
||||
"id": 95,
|
||||
"first_name": "Iormina",
|
||||
"last_name": "Peedell",
|
||||
"email": "ipeedell2m@seattletimes.com",
|
||||
"gender": "Female",
|
||||
"company": "Youfeed"
|
||||
}, {
|
||||
"id": 96,
|
||||
"first_name": "Abigail",
|
||||
"last_name": "Kielty",
|
||||
"email": "akielty2n@npr.org",
|
||||
"gender": "Female",
|
||||
"company": "Reallinks"
|
||||
}, {
|
||||
"id": 97,
|
||||
"first_name": "Hallie",
|
||||
"last_name": "Toomey",
|
||||
"email": "htoomey2o@google.com.au",
|
||||
"gender": "Female",
|
||||
"company": "Flipbug"
|
||||
}, {
|
||||
"id": 98,
|
||||
"first_name": "Sergeant",
|
||||
"last_name": "Pourveer",
|
||||
"email": "spourveer2p@amazon.co.uk",
|
||||
"gender": "Male",
|
||||
"company": "Skinix"
|
||||
}, {
|
||||
"id": 99,
|
||||
"first_name": "Elfie",
|
||||
"last_name": "McKinlay",
|
||||
"email": "emckinlay2q@xrea.com",
|
||||
"gender": "Female",
|
||||
"company": "Devcast"
|
||||
}, {
|
||||
"id": 100,
|
||||
"first_name": "Wainwright",
|
||||
"last_name": "Juggins",
|
||||
"email": "wjuggins2r@tamu.edu",
|
||||
"gender": "Male",
|
||||
"company": "Topiclounge"
|
||||
}];
|
||||
|
||||
|
||||
|
||||
const contacts = contactsData.map(d => new Person(d.id, d.first_name, d.last_name, d.email, d.gender, d.company));
|
||||
return contacts;
|
||||
}
|
||||
|
||||
public static loadCompanies() {
|
||||
const companies = [{
|
||||
"id": 101,
|
||||
"city": "Lakshmīpur",
|
||||
"street": "36300 Lake View Center",
|
||||
"email": "ogovier0@gmpg.org",
|
||||
"company": "Fiveclub"
|
||||
}, {
|
||||
"id": 102,
|
||||
"city": "El Quetzal",
|
||||
"street": "551 New Castle Parkway",
|
||||
"email": "elander1@g.co",
|
||||
"company": "Twitterwire"
|
||||
}, {
|
||||
"id": 103,
|
||||
"city": "Mayakovski",
|
||||
"street": "1 Norway Maple Center",
|
||||
"email": "dcustance2@hostgator.com",
|
||||
"company": "Jabbersphere"
|
||||
}, {
|
||||
"id": 104,
|
||||
"city": "Al Jawādīyah",
|
||||
"street": "02 Carey Hill",
|
||||
"email": "evanoort3@sciencedaily.com",
|
||||
"company": "Zoovu"
|
||||
}, {
|
||||
"id": 105,
|
||||
"city": "Girona",
|
||||
"street": "3 Lillian Center",
|
||||
"email": "dducker4@cbsnews.com",
|
||||
"company": "Innojam"
|
||||
}, {
|
||||
"id": 106,
|
||||
"city": "Vouani",
|
||||
"street": "5165 Vera Avenue",
|
||||
"email": "orzehorz5@arizona.edu",
|
||||
"company": "Zoovu"
|
||||
}, {
|
||||
"id": 107,
|
||||
"city": "Caibarién",
|
||||
"street": "3739 Burrows Drive",
|
||||
"email": "ltrahair6@pinterest.com",
|
||||
"company": "Quamba"
|
||||
}, {
|
||||
"id": 108,
|
||||
"city": "Wushi",
|
||||
"street": "88 Bay Hill",
|
||||
"email": "plebourn7@springer.com",
|
||||
"company": "Feednation"
|
||||
}, {
|
||||
"id": 109,
|
||||
"city": "Zbýšov",
|
||||
"street": "38 Dovetail Place",
|
||||
"email": "slace8@netscape.com",
|
||||
"company": "Zoomzone"
|
||||
}, {
|
||||
"id": 110,
|
||||
"city": "Nová Cerekev",
|
||||
"street": "90194 Dixon Avenue",
|
||||
"email": "mdoxey9@goo.gl",
|
||||
"company": "Devpoint"
|
||||
}];
|
||||
|
||||
return companies.map(c => new Company(c.id, c.company, c.street, c.email));
|
||||
}
|
||||
|
||||
public static loadContacts() {
|
||||
const result = new Array<Person | Company>();
|
||||
result.push(...this.loadPersons());
|
||||
result.push(...this.loadCompanies());
|
||||
let idx = 0;
|
||||
while (idx++ < 1000) {
|
||||
const i = Math.round(Math.random() * (result.length - 1));
|
||||
const j = Math.round(Math.random() * (result.length - 1));
|
||||
const temp = result[i];
|
||||
result[i] = result[j];
|
||||
result[j] = temp;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const contacts = AddressBook.loadContacts();
|
||||
|
||||
debugger;
|
||||
@@ -10,49 +10,70 @@ setTimeout(() => {
|
||||
}, 0);
|
||||
|
||||
class Main {
|
||||
/** @pure */
|
||||
run() {
|
||||
const list = new DoublyLinkedList("1");
|
||||
list.setNext(new DoublyLinkedList("2"));
|
||||
list.next!.setNext(new DoublyLinkedList("3"));
|
||||
list.next!.next!.setNext(new DoublyLinkedList("4"));
|
||||
|
||||
// Use `visualize()` as expression to visualize in the Debug Visualizer!
|
||||
const visualize = () =>
|
||||
createGraphFromPointers({ list, last, cur }, i => ({
|
||||
id: i.id,
|
||||
label: i.name,
|
||||
color: finished.has(i) ? "lime" : undefined,
|
||||
edges: [
|
||||
{ to: i.next!, label: "next" },
|
||||
{ to: i.prev!, label: "prev", color: "lightgray" },
|
||||
].filter(r => !!r.to),
|
||||
}));
|
||||
|
||||
const finished = new Set();
|
||||
var cur: DoublyLinkedList | undefined = list;
|
||||
// Reverses `list`. Finished nodes have correct pointers,
|
||||
// their next node is also finished.
|
||||
var last: DoublyLinkedList | undefined = undefined;
|
||||
while (cur) {
|
||||
cur.prev = cur.next;
|
||||
cur.next = last;
|
||||
finished.add(cur);
|
||||
last = cur;
|
||||
cur = cur.prev;
|
||||
}
|
||||
id = 0;
|
||||
const head = new DoublyLinkedListNode("1");
|
||||
head.setNext(new DoublyLinkedListNode("2"));
|
||||
head.next!.setNext(new DoublyLinkedListNode("3"));
|
||||
const tail = new DoublyLinkedListNode("4");
|
||||
head.next!.next!.setNext(tail);
|
||||
reverse(new DoublyLinkedList(head, tail));
|
||||
console.log("finished");
|
||||
}
|
||||
}
|
||||
|
||||
let id = 0;
|
||||
function reverse(list: DoublyLinkedList) {
|
||||
// Open a new Debug Visualizer
|
||||
// and enter `visualize()`!
|
||||
const visualize = () =>
|
||||
createGraphFromPointers(
|
||||
{
|
||||
last,
|
||||
"list.head": list.head,
|
||||
"list.tail": list.tail
|
||||
},
|
||||
i => ({
|
||||
id: i.id,
|
||||
label: i.name,
|
||||
color: finished.has(i) ? "lime" : "lightblue",
|
||||
edges: [
|
||||
{ to: i.next!, label: "next", color: "lightblue", },
|
||||
{ to: i.prev!, label: "prev", color: "lightgray" },
|
||||
].filter(r => !!r.to),
|
||||
}));
|
||||
|
||||
// Finished nodes have correct pointers,
|
||||
// their next node is also finished.
|
||||
const finished = new Set();
|
||||
var last: DoublyLinkedListNode | null = null;
|
||||
list.tail = list.head;
|
||||
while (list.head) {
|
||||
list.head.prev = list.head.next;
|
||||
list.head.next = last;
|
||||
finished.add(list.head);
|
||||
last = list.head;
|
||||
list.head = list.head.prev;
|
||||
}
|
||||
list.head = last;
|
||||
}
|
||||
|
||||
class DoublyLinkedList {
|
||||
constructor(
|
||||
public head: DoublyLinkedListNode | null,
|
||||
public tail: DoublyLinkedListNode | null
|
||||
) { }
|
||||
}
|
||||
|
||||
let id = 0;
|
||||
class DoublyLinkedListNode {
|
||||
public readonly id = (id++).toString();
|
||||
constructor(public name: string) {}
|
||||
constructor(public name: string) { }
|
||||
|
||||
next: DoublyLinkedList | undefined;
|
||||
prev: DoublyLinkedList | undefined;
|
||||
next: DoublyLinkedListNode | null = null;
|
||||
prev: DoublyLinkedListNode | null = null;
|
||||
|
||||
public setNext(val: DoublyLinkedList): void {
|
||||
public setNext(val: DoublyLinkedListNode): void {
|
||||
val.prev = this;
|
||||
this.next = val;
|
||||
}
|
||||
|
||||
7
demos/js/src/demo_fetch.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
fetch("https://jsonplaceholder.typicode.com/users")
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
debugger;
|
||||
});
|
||||
@@ -1,12 +1,20 @@
|
||||
// visualize `data`
|
||||
const data = new Array<number>();
|
||||
let value = 0;
|
||||
for (let i = 0; i < 100000; i++) {
|
||||
const delta = Math.random() > 0.5 ? 1 : -1;
|
||||
data.push(value);
|
||||
value += delta;
|
||||
let curValue = 0;
|
||||
|
||||
if (i % 1000 === 0) {
|
||||
debugger;
|
||||
for (let j = 0; j < 100; j++) {
|
||||
addManyRandomValues();
|
||||
}
|
||||
|
||||
function addManyRandomValues() {
|
||||
for (let i = 0; i < 100; i++) {
|
||||
addRandomValue();
|
||||
}
|
||||
}
|
||||
|
||||
function addRandomValue() {
|
||||
const delta = Math.random()
|
||||
> 0.5 ? 1 : -1;
|
||||
data.push(curValue);
|
||||
curValue += delta;
|
||||
}
|
||||
@@ -13,9 +13,13 @@ hedietDbgVis.markedGrid(
|
||||
*/
|
||||
|
||||
// From https://github.com/AvraamMavridis/Algorithms-Data-Structures-in-Typescript/blob/master/algorithms/quickSort.md
|
||||
const array = [1, 2, 33, 31, 1, 2, 63, 123, 6, 32, 943, 346, 24];
|
||||
const sorted = quickSort(array, 0, array.length - 1);
|
||||
console.log(sorted);
|
||||
/** @pure */
|
||||
function main() {
|
||||
const array = [1, 2, 33, 31, 1, 2, 63, 123, 6, 32, 943, 346, 24];
|
||||
const sorted = quickSort(array, 0, array.length - 1);
|
||||
console.log(sorted);
|
||||
}
|
||||
main();
|
||||
|
||||
function swap(array: Array<number>, i: number, j: number) {
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
|
||||
8
demos/js/src/demo_stack-frames.js
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
function test() {
|
||||
let i = 1;
|
||||
debugger;
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
test();
|
||||
@@ -11,13 +11,14 @@ setTimeout(() => {
|
||||
|
||||
class Main {
|
||||
run() {
|
||||
const files = new Map<string, string>([
|
||||
/*const files = new Map<string, string>([
|
||||
[
|
||||
"main.ts",
|
||||
`
|
||||
class Test1 {
|
||||
public foo(a: number) {
|
||||
const x = { a: 5 };
|
||||
const y = { a: 5 };
|
||||
}
|
||||
}
|
||||
`,
|
||||
@@ -34,7 +35,7 @@ class Test1 {
|
||||
const c = prog.getTypeChecker();
|
||||
let myValue = undefined; // Visualize `myValue` here!
|
||||
const sourceFileAst = prog.getSourceFiles()[0];
|
||||
myValue = sourceFileAst.getText();
|
||||
myValue = sourceFileAst;
|
||||
console.log("myValue is the source code of the AST");
|
||||
debugger;
|
||||
|
||||
@@ -64,7 +65,24 @@ class Test1 {
|
||||
},
|
||||
};
|
||||
console.log("myValue is AST, annotated with symbol information");
|
||||
debugger;
|
||||
debugger;*/
|
||||
require;
|
||||
|
||||
const sf = ts.createSourceFile("main.ts",
|
||||
`
|
||||
class Test1 {
|
||||
public foo(a: number) {
|
||||
const x = { a: 5 };
|
||||
const y = { a: 24 };
|
||||
}
|
||||
}
|
||||
`, ts.ScriptTarget.ESNext, true);
|
||||
const traverse = (node: ts.Node) => {
|
||||
ts.forEachChild(node, child => {
|
||||
traverse(child);
|
||||
});
|
||||
};
|
||||
traverse(sf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,6 +271,11 @@ fsevents@^2.0.6:
|
||||
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.0.7.tgz#382c9b443c6cbac4c57187cdda23aa3bf1ccfc2a"
|
||||
integrity sha512-a7YT0SV3RB+DjYcppwVDLtn13UQnmg0SWZS7ezZD0UjnLwXmy8Zm21GMVGLaFGimIqcvyMQaOJBrop8MyOp1kQ==
|
||||
|
||||
function-bind@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
|
||||
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
|
||||
|
||||
get-func-name@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
|
||||
@@ -296,6 +301,13 @@ has-flag@^3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
|
||||
integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
|
||||
|
||||
has@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
|
||||
integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==
|
||||
dependencies:
|
||||
function-bind "^1.1.1"
|
||||
|
||||
io-ts@^1.8.6:
|
||||
version "1.10.4"
|
||||
resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-1.10.4.tgz#cd5401b138de88e4f920adbcb7026e2d1967e6e2"
|
||||
@@ -310,6 +322,13 @@ is-binary-path@^2.1.0:
|
||||
dependencies:
|
||||
binary-extensions "^2.0.0"
|
||||
|
||||
is-core-module@^2.2.0:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1"
|
||||
integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==
|
||||
dependencies:
|
||||
has "^1.0.3"
|
||||
|
||||
is-extglob@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
|
||||
@@ -368,11 +387,21 @@ nise@^1.4.10:
|
||||
lolex "^4.1.0"
|
||||
path-to-regexp "^1.7.0"
|
||||
|
||||
node-fetch@^2.6.1:
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
|
||||
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
|
||||
|
||||
normalize-path@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
|
||||
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
|
||||
|
||||
path-parse@^1.0.6:
|
||||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
|
||||
integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
|
||||
|
||||
path-to-regexp@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
|
||||
@@ -402,6 +431,14 @@ readdirp@^3.1.1:
|
||||
dependencies:
|
||||
picomatch "^2.0.4"
|
||||
|
||||
resolve@>=1.9.0:
|
||||
version "1.20.0"
|
||||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
|
||||
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
|
||||
dependencies:
|
||||
is-core-module "^2.2.0"
|
||||
path-parse "^1.0.6"
|
||||
|
||||
sinon@^7.2.7:
|
||||
version "7.3.2"
|
||||
resolved "https://registry.yarnpkg.com/sinon/-/sinon-7.3.2.tgz#82dba3a6d85f6d2181e1eca2c10d8657c2161f28"
|
||||
@@ -447,15 +484,22 @@ to-regex-range@^5.0.1:
|
||||
dependencies:
|
||||
is-number "^7.0.0"
|
||||
|
||||
ttypescript@^1.5.12:
|
||||
version "1.5.12"
|
||||
resolved "https://registry.yarnpkg.com/ttypescript/-/ttypescript-1.5.12.tgz#27a8356d7d4e719d0075a8feb4df14b52384f044"
|
||||
integrity sha512-1ojRyJvpnmgN9kIHmUnQPlEV1gq+VVsxVYjk/NfvMlHSmYxjK5hEvOOU2MQASrbekTUiUM7pR/nXeCc8bzvMOQ==
|
||||
dependencies:
|
||||
resolve ">=1.9.0"
|
||||
|
||||
type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.5:
|
||||
version "4.0.8"
|
||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
|
||||
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==
|
||||
|
||||
typescript@^3.8.2:
|
||||
version "3.9.7"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
|
||||
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
|
||||
typescript@^3.9.0:
|
||||
version "3.9.9"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.9.tgz#e69905c54bc0681d0518bd4d587cc6f2d0b1a674"
|
||||
integrity sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w==
|
||||
|
||||
ws@^7.0.0:
|
||||
version "7.1.1"
|
||||
|
||||
7
demos/python/Person.py
Normal file
@@ -0,0 +1,7 @@
|
||||
class Person:
|
||||
def __init__(self, name, parents=None) -> None:
|
||||
self.name = name
|
||||
self.parents = [] if parents is None else parents
|
||||
|
||||
def addParent(self, parent: "Person"):
|
||||
self.parents.append(parent)
|
||||
44
demos/python/debugvisualizer.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from Person import Person
|
||||
import json
|
||||
from vscodedebugvisualizer import globalVisualizationFactory
|
||||
|
||||
|
||||
class PersonVisualizer:
|
||||
def checkType(self, t):
|
||||
return isinstance(t, Person)
|
||||
|
||||
def visualizePerson(self, person: Person, nodes=[], edges=[]):
|
||||
if person.name in [n["id"] for n in nodes]:
|
||||
return nodes, edges
|
||||
|
||||
nodes.append(
|
||||
{
|
||||
"id": person.name,
|
||||
"label": person.name,
|
||||
}
|
||||
)
|
||||
|
||||
for p in person.parents:
|
||||
nodes, edges = self.visualizePerson(p, nodes, edges)
|
||||
edges.append(
|
||||
{
|
||||
"from": p.name,
|
||||
"to": person.name,
|
||||
}
|
||||
)
|
||||
|
||||
return nodes, edges
|
||||
|
||||
def visualize(self, person: Person):
|
||||
jsonDict = {
|
||||
"kind": {"graph": True},
|
||||
"nodes": [],
|
||||
"edges": [],
|
||||
}
|
||||
|
||||
self.visualizePerson(person, jsonDict["nodes"], jsonDict["edges"])
|
||||
|
||||
return json.dumps(jsonDict)
|
||||
|
||||
|
||||
globalVisualizationFactory.addVisualizer(PersonVisualizer())
|
||||
123
demos/python/demo.py
Normal file
@@ -0,0 +1,123 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
# put "x" in the Debug Visualizer and use step by step
|
||||
# debugging to see the diffrent types of data visualization
|
||||
|
||||
|
||||
x = 5
|
||||
x = "asdf"
|
||||
x = 5.5
|
||||
x = [1, 2, 3, 4, 5, 6, "a", "b"]
|
||||
x = ["b", "a", "c", "d", "e"]
|
||||
x.sort()
|
||||
x = {
|
||||
"asdf1": "dasdf",
|
||||
"asdf2": "dasdf",
|
||||
"asdf3": {"foo": "bar"},
|
||||
}
|
||||
|
||||
x = [1, 2, 3, 4, 5, 6]
|
||||
# histogram
|
||||
x = np.concatenate([np.arange(i) for i in range(9)])
|
||||
x = x.reshape(2, -1)
|
||||
|
||||
|
||||
# one dimension
|
||||
x = np.arange(100)
|
||||
x = np.linspace(-np.pi, np.pi, 100)
|
||||
x = np.sin(x)
|
||||
|
||||
# 2 dimension
|
||||
x = x.reshape(5, 20)
|
||||
# 2 dimension transpose
|
||||
x = x.transpose()
|
||||
x = x.transpose()
|
||||
|
||||
# 3 dimensions
|
||||
x = x.reshape(2, 5, 10)
|
||||
|
||||
# 4 dimensions
|
||||
x = x.reshape(2, 5, 2, 5)
|
||||
|
||||
# big number
|
||||
x = np.empty(2 ** 24)
|
||||
x[0:1000000] = 1
|
||||
x[1000000:10000000] = 5
|
||||
|
||||
# pyTorch
|
||||
try:
|
||||
import torch
|
||||
|
||||
x = np.concatenate([np.arange(i) for i in range(9)])
|
||||
x = x.reshape(2, -1)
|
||||
x = torch.Tensor(x)
|
||||
pass
|
||||
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
# tensorflow
|
||||
|
||||
try:
|
||||
import tensorflow as tf
|
||||
|
||||
x = np.concatenate([np.arange(i) for i in range(9)])
|
||||
x = x.reshape(2, -1)
|
||||
x = tf.convert_to_tensor(x)
|
||||
pass
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
# pandas
|
||||
|
||||
try:
|
||||
import pandas as pd
|
||||
import plotly.express as px
|
||||
|
||||
x = px.data.gapminder().query("year == 2007")
|
||||
pass
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# custom visualizer defined in ./debugvisualizer.py (this file is included automatically)
|
||||
|
||||
from Person import Person
|
||||
|
||||
x = Person("Aria")
|
||||
parent1 = Person("Eduart")
|
||||
parent2 = Person("Catelyn")
|
||||
x.addParent(parent1)
|
||||
x.addParent(parent2)
|
||||
parent1.addParent(Person("Benjen"))
|
||||
|
||||
# direct debug-visualizer json as dict with property "kind"
|
||||
|
||||
x = {
|
||||
"kind": {"dotGraph": True},
|
||||
"text": '\ndigraph G {\n subgraph cluster_0 {\n style=filled;\n color=lightgrey;\n node [style=filled,color=white];\n a0 -> a1 -> a2 -> a3;\n label = "process #1";\n }\n \n subgraph cluster_1 {\n node [style=filled];\n b0 -> b1 -> b2 -> b3;\n label = "process #2";\n color=blue\n }\n start -> a0;\n start -> b0;\n a1 -> b3;\n b2 -> a3;\n a3 -> a0;\n a3 -> end;\n b3 -> end;\n \n start [shape=Mdiamond];\n end [shape=Msquare];\n}\n',
|
||||
}
|
||||
|
||||
x = {
|
||||
"kind": {"plotly": True},
|
||||
"data": [
|
||||
{
|
||||
"mode": "lines",
|
||||
"type": "scatter",
|
||||
"x": ["A", "B", "C"],
|
||||
"xaxis": "x",
|
||||
"y": [4488916, 3918072, 3892124],
|
||||
"yaxis": "y",
|
||||
},
|
||||
{
|
||||
"cells": {"values": [["A", "B", "C"], [341319, 281489, 294786], [4488916, 3918072, 3892124]]},
|
||||
"domain": {"x": [0.0, 1.0], "y": [0.0, 0.60]},
|
||||
"header": {"align": "left", "font": {"size": 10}, "values": ["Date", "Number", "Output"]},
|
||||
"type": "table",
|
||||
},
|
||||
],
|
||||
"layout": {"xaxis": {"anchor": "y", "domain": [0.0, 1.0]}, "yaxis": {"anchor": "x", "domain": [0.75, 1.0]}},
|
||||
}
|
||||
pass
|
||||
@@ -23,10 +23,9 @@ for i in range(2,100):
|
||||
# connects the node to a random edge
|
||||
targetId = str(randint(1, i - 1))
|
||||
graph["edges"].append({"from": id, "to": targetId})
|
||||
json_graph = dumps(graph)
|
||||
print("i is " + str(i))
|
||||
# try setting a breakpoint right above
|
||||
# then put json_graph into the visualization console and press enter
|
||||
# then put graph into the visualization console and press enter
|
||||
# when you step through the code each time you hit the breakpoint
|
||||
# the graph should automatically refresh!
|
||||
|
||||
|
||||
38
demos/python/insertion_sort.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Python demo for sorting using VS Code Debug Visualizer."""
|
||||
|
||||
|
||||
def serialize(arr):
|
||||
"""Serialize an array into a format the visualizer can understand."""
|
||||
formatted = {
|
||||
"kind": {"grid": True},
|
||||
"rows": [
|
||||
{
|
||||
"columns": [
|
||||
{"content": str(value), "tag": str(value)} for value in arr
|
||||
],
|
||||
}
|
||||
],
|
||||
}
|
||||
return formatted
|
||||
|
||||
|
||||
arr = [6, 9, 3, 12, 1, 11, 5, 13, 8, 14, 2, 4, 10, 0, 7]
|
||||
|
||||
# Put serialized into the Debug Visualizer console
|
||||
serialized = serialize(arr)
|
||||
|
||||
# Set a breakpoint on the line below and go through the code in debug mode to
|
||||
# watch it update
|
||||
for target_idx in range(1, len(arr)):
|
||||
target_value = arr[target_idx]
|
||||
compare_idx = target_idx - 1
|
||||
|
||||
while compare_idx >= 0 and arr[compare_idx] > target_value:
|
||||
arr[compare_idx + 1] = arr[compare_idx]
|
||||
serialized = serialize(arr)
|
||||
compare_idx -= 1
|
||||
|
||||
arr[compare_idx + 1] = target_value
|
||||
serialized = serialize(arr)
|
||||
|
||||
assert arr == sorted(arr)
|
||||
7
demos/ruby/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Ruby Demos
|
||||
|
||||
To visualize Ruby objects, you need to install [debugvisualizer.gem](https://github.com/ono-max/debugvisualizer).
|
||||
|
||||
Install the gem by executing:
|
||||
|
||||
$ gem install debugvisualizer
|
||||
18
demos/ruby/src/demo_custom_visualizer.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'debugvisualizer'
|
||||
|
||||
class Foo; end
|
||||
|
||||
DebugVisualizer.register Foo do |data|
|
||||
{
|
||||
id: "my_visualizer",
|
||||
name: "My Visualizer",
|
||||
data: {
|
||||
kind: { text: true },
|
||||
text: "Foo"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
f = Foo.new
|
||||
# visualize `f` here!
|
||||
binding.break
|
||||
12
demos/ruby/src/demo_random_walks.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
data = []
|
||||
curVal = 0
|
||||
|
||||
100.times{
|
||||
100.times{
|
||||
delta = rand > 0.5 ? 1 : -1
|
||||
data << curVal
|
||||
curVal += delta
|
||||
# visualize `data` here and press F5(or Continue button) over and over!
|
||||
binding.break
|
||||
}
|
||||
}
|
||||
14
demos/rust/.vscode/launch.json
vendored
@@ -7,8 +7,18 @@
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug",
|
||||
"program": "${workspaceFolder}/target/debug/rust_demo",
|
||||
"name": "run rust demo",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=rust_demo",
|
||||
"--package=rust_demo",
|
||||
],
|
||||
"filter": {
|
||||
"name": "rust_demo",
|
||||
"kind": "bin",
|
||||
},
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
}
|
||||
|
||||
8
demos/rust/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"debugVisualizer.debugAdapterConfigurations": {
|
||||
"lldb": {
|
||||
"expressionTemplate": "${expr}",
|
||||
"context": "watch"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,77 +1,77 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct Label {
|
||||
label: Option<String>,
|
||||
}
|
||||
#[derive(Debug, Serialize)]
|
||||
struct Row {
|
||||
label: Option<String>,
|
||||
columns: Vec<Column>,
|
||||
}
|
||||
#[derive(Debug, Serialize)]
|
||||
struct Column {
|
||||
content: Option<String>,
|
||||
tag: Option<String>,
|
||||
color: Option<String>,
|
||||
}
|
||||
#[derive(Debug, Serialize)]
|
||||
struct Marker {
|
||||
id: String,
|
||||
row: u64,
|
||||
column: u64,
|
||||
rows: Option<u64>,
|
||||
columns: Option<u64>,
|
||||
label: Option<String>,
|
||||
color: Option<String>,
|
||||
}
|
||||
// expected to mirror
|
||||
// https://hediet.github.io/visualization/docs/visualization-data-schema.json
|
||||
//
|
||||
// implements the grid visualizer as an example
|
||||
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
fn is_false(b: &bool) -> bool {
|
||||
!*b
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct Kind {
|
||||
#[serde(skip_serializing_if = "is_false")]
|
||||
array: bool,
|
||||
}
|
||||
pub type Label = String;
|
||||
|
||||
/// `GridVisualizationData` in schema
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Grid {
|
||||
kind: Kind,
|
||||
#[serde(rename = "columnLabels")]
|
||||
column_labels: Option<Vec<Label>>,
|
||||
rows: Vec<Row>,
|
||||
markers: Option<Vec<Marker>>,
|
||||
|
||||
#[serde(rename = "columnLabels")]
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
column_labels: Option<Vec<Label>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Kind {
|
||||
grid: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Row {
|
||||
columns: Vec<Column>,
|
||||
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
label: Option<Label>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Column {
|
||||
/// value to display to the user
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
content: Option<String>,
|
||||
|
||||
/// unique value to identify this cell, if desired
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
tag: Option<String>,
|
||||
|
||||
// TODO: valid values / syntax?
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
color: Option<String>,
|
||||
}
|
||||
|
||||
fn show_arr(a: &[i32]) -> String {
|
||||
let n = a.len();
|
||||
let labels: Vec<Label> = (0..n)
|
||||
.map(|i| Label {
|
||||
label: Some(i.to_string()),
|
||||
})
|
||||
.collect();
|
||||
let columns: Vec<Column> = a
|
||||
.iter()
|
||||
.map(|x| Column {
|
||||
content: Some(format!("{:?}", x)),
|
||||
tag: Some(x.to_string()),
|
||||
color: None,
|
||||
tag: None,
|
||||
|
||||
// TODO: `color` value doesn't seem to change visualizer's output at all
|
||||
color: "who-knows".to_owned().into(),
|
||||
})
|
||||
.collect();
|
||||
|
||||
let row = Row {
|
||||
label: None,
|
||||
columns,
|
||||
// TODO: visualizer doesn't seem to render this
|
||||
label: "my row".to_owned().into(),
|
||||
};
|
||||
let kind = Kind { array: true };
|
||||
|
||||
let kind = Kind { grid: true };
|
||||
|
||||
let grid = Grid {
|
||||
kind,
|
||||
column_labels: Some(labels),
|
||||
rows: vec![row],
|
||||
markers: None,
|
||||
|
||||
// TODO: visualizer doesn't seem to work if this is non-`None`
|
||||
column_labels: None,
|
||||
};
|
||||
|
||||
serde_json::to_string(&grid).unwrap()
|
||||
@@ -81,9 +81,9 @@ fn main() {
|
||||
let mut arr = vec![1, 2, 3];
|
||||
let mut _s = show_arr(&arr);
|
||||
for _ in 0..5 {
|
||||
arr.swap(0, 2); // break point
|
||||
arr.swap(0, 2); // set a break-point here, to easily observe the change
|
||||
_s = show_arr(&arr);
|
||||
}
|
||||
dbg!(arr); // break point
|
||||
println!("Hello, world!");
|
||||
dbg!(arr);
|
||||
println!("break-point here, too");
|
||||
}
|
||||
295
docs/architecture.drawio.svg
Normal file
@@ -0,0 +1,295 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="241px" height="971px" viewBox="-0.5 -0.5 241 971" content="<mxfile host="localhost" modified="2020-05-18T21:20:25.100Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.45.1 Chrome/78.0.3904.130 Electron/7.2.4 Safari/537.36" etag="wIym9edGWidWU1rSQKSs" version="13.0.9"><diagram id="6hGFLwfOUW9BJ-s0fimq" name="Page-1">7Vpbd6I6FP41Pp4uCKDlcWq9HqVntBXlDUgqseGyIAr660+QoCB06prRdpw1L0o2ySbZ++PbF21IbTfphWbgjH2ISAMIMGlIjw0AZKXFPlPBNhMogpwJliGGmUg8CqZ4h7hQ4NI1higqTaS+TygOykLb9zxk05LMDEM/Lk979Un5qYG5RBXB1DZJVapjSJ1Meg9aR3kf4aWTP1lsqtkd18wn85NEjgn9uCCSOg2pHfo+za7cpI1IarvcLtm67jt3DxsLkUfPWtDMVmxMsuaH4xuj2/y0ob/2IEoXCA3pIXYwRdPAtNO7MXMvkznUJWwksstXTEjbJ37Ixp7vsUkP1T3xbW5QSFFSEPE99pDvIhpu2RR+V+Lm4nhpNvk4PlofyFzmFCwvtbjQ5B5fHlQfjcIuuF3esRG4RRsp4EwbieASNhJu0UbnwkiWL2CiKoo6CUVehH3v10yVjhDEiI6w94bgo0lNdgdth6LtvuEnPHRNPSFP+H4zAmMyFjqb2VwjtjfeTHuzteWStbFVO8ZcC2FPjUfAIUaPENhWgQ20jdF7oUZvhqFuU+iSHdS7kTkPiI1VgvoTYnlaYAF5Y0vD1QjMZMh02oBsLKwI9nYQDTxNWMyHwmAVtAautrHag+a4HWOrx547ZdcrQx21h8Ryv+MnZo0FUKPByk+YLDJ1hbBrZSyJ6gW8r5a9L4pV9x9ehqL7mxfwvlTx/jDqpCOTMgB0vCVmGP9TYCDMwEJPxMV8wmTKnH2vzG76LCNYgJfNZG44Vn/mwB6DydtsbYAUCuq/dnld13JhYLkva9gfYwaHHex1t5DBh51pZYEYP62+RQM3Seew6478Oo2xoStvJahNC1Dbaerr99S0nKAuCqcDuXwGnOT34cQo8y+OfgFHY/FDHD0PpNe5cBUUSconokipoCj1NgtLoWmntDRB0ZrQG4XTG3O/M9JZROoPnYU0KcBqwiDT7TK4bRe6Jpi6un5xZ2xtIoy8yW6AY2xLE8f2ShEpLkSkuBYi+AgRrX+NiKV8JjiqlYFYQQLy4Le0nmIjP0Be2fPsJi/dWAYtPUTUDGk+G2LT9T347GAvv5XPlXNBF5ODKsjqL/5YP6SOv/Q9k3SO0geT4CVT9UjQK7PBQ2pizAq2b1xs+ZT6bqopwXSeIvdO4aNF/gx2/ZhwUO8HWz5415GRvw5tVErv2MaXKK8+MlG6+XOc/Y9YZoJsFCLCUoRN2QV1fuV6//Mx2+VBKWiVISSfQiM7A19VrBRPFInKO+EuV5SdvKJoD7PDYc9CXquCvHaITMoq/o/xdwI6aEbOnqnEE2xeCwZSFQbymTAovtS5l34X78vSB4ou53214n2e2KT+FzpJEKIoK5qEZ/8GECFXEaF8HSIOenKWEX6WD04VXQ8RoliBBHq3dGaRlZY9m4cGm3kJhTXBwcUQ7oMIQxbemdZeVerfIN38/jjKQ0N5THWtqR9xNH1WS6JVE+Av0rOp1qSRw44C/zSb1rXClGsZtVqZ7dvfdyylobda4UuGPgSmPpNGkrZdbFVqAVaptVUt+/5Bo6dQNWmPk7pGz66QVgtP82ukzU31E9NmsZq9xMjaYBT/aa9VXRe+eaXXClRDwBTtw9GX5wA391JquNh97dTWsk+lDm3no3ZHMd9RqvmO+IUp8GmeIp/C8WcTHuV6CU9eTBbQPsPRmrHDDoV3zPoQhW2fUYR3q82ZU/CuLCDGFlCI5U12I9EIbGnmMAA2jflgDfuafEZTJnmaC9HAna2NUm+vU+jtvSjX6tvd1+QYYl2ScYkYU9P+nexBkeZuwqCaFP9lxK9kRLGmBMxf8d+BEpuXosTWaTF5QUqs9qpzStz/gsZZ8UbpEJhzTVzoSYDc7r4fzRGsH+Wz7Q9608VfSxOtX0eD47g85xqJtirXkKB0LRKsJtpXIsG/hHZCaDl5lQjtK5tainrXUsrx+P5nOa0l3IGyLlW5FK2x4fG/Xdn04x/kpM7/</diagram></mxfile>">
|
||||
<defs/>
|
||||
<g>
|
||||
<rect x="0" y="600" width="240" height="370" fill="none" stroke="#000000" pointer-events="all"/>
|
||||
<rect x="0" y="460" width="240" height="120" fill="none" stroke="#000000" pointer-events="all"/>
|
||||
<rect x="0" y="0" width="240" height="440" fill="none" stroke="#000000" pointer-events="all"/>
|
||||
<rect x="60" y="50" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 80px; margin-left: 61px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
|
||||
Extension
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="120" y="84" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
Extension
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="60" y="170" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 200px; margin-left: 61px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
|
||||
JsEvaluationEngine
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="120" y="204" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
JsEvaluationEngine
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="60" y="290" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 320px; margin-left: 61px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
|
||||
JsEvaluator
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="120" y="324" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
JsEvaluator
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="60" y="490" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 520px; margin-left: 61px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
|
||||
DataExtractionResult
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="120" y="524" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
DataExtractionResult
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<path d="M 120 125.99 L 120 167.76" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/>
|
||||
<path d="M 120 110.99 L 124.41 118.49 L 120 125.99 L 115.59 118.49 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/>
|
||||
<path d="M 113.5 155.88 L 120 168.88 L 126.5 155.88" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-end; justify-content: unsafe flex-start; width: 1px; height: 1px; padding-top: 107px; margin-left: 125px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: left; ">
|
||||
<div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">
|
||||
1
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="125" y="107" fill="#000000" font-family="Helvetica" font-size="11px">
|
||||
1
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<path d="M 120 230 L 120 287.76" fill="none" stroke="#000000" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="stroke"/>
|
||||
<path d="M 113.5 275.88 L 120 288.88 L 126.5 275.88" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 260px; margin-left: 120px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">
|
||||
Creates
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="120" y="263" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">
|
||||
Creates
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<path d="M 120 350 L 120 487.76" fill="none" stroke="#000000" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="stroke"/>
|
||||
<path d="M 113.5 475.88 L 120 488.88 L 126.5 475.88" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 420px; margin-left: 120px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">
|
||||
Evaluates Expression To
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="120" y="423" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">
|
||||
Evaluates Expression To
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="0" y="0" width="70" height="20" fill="none" stroke="none" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 10px; margin-left: 35px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: nowrap; ">
|
||||
extension
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="35" y="14" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
extension
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="0" y="460" width="50" height="20" fill="none" stroke="none" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 470px; margin-left: 25px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: nowrap; ">
|
||||
shared
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="25" y="474" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
shared
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="60" y="630" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 660px; margin-left: 61px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
|
||||
Model.state
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="120" y="664" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
Model.state
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="0" y="600" width="60" height="20" fill="none" stroke="none" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 610px; margin-left: 30px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: nowrap; ">
|
||||
webview
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="30" y="614" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
webview
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<path d="M 120 550 L 120 627.76" fill="none" stroke="#000000" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="stroke"/>
|
||||
<path d="M 113.5 615.88 L 120 628.88 L 126.5 615.88" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 590px; margin-left: 120px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">
|
||||
Sent To
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="120" y="593" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">
|
||||
Sent To
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="60" y="760" width="150" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 148px; height: 1px; padding-top: 790px; margin-left: 61px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
|
||||
Visualizer.renderContent
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="135" y="794" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
Visualizer.renderContent
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<path d="M 120 690 L 130.17 757.79" fill="none" stroke="#000000" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="stroke"/>
|
||||
<path d="M 121.98 747 L 130.33 758.89 L 134.83 745.07" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 725px; margin-left: 125px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">
|
||||
Rendered In
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="125" y="728" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">
|
||||
Rendered In
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<rect x="60" y="880" width="130" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 128px; height: 1px; padding-top: 910px; margin-left: 61px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">
|
||||
Visualization.render
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="125" y="914" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">
|
||||
Visualization.render
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
<path d="M 132.5 820 L 127.69 877.77" fill="none" stroke="#000000" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="stroke"/>
|
||||
<path d="M 122.19 865.39 L 127.59 878.89 L 135.15 866.47" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/>
|
||||
<g transform="translate(-0.5 -0.5)">
|
||||
<switch>
|
||||
<foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 850px; margin-left: 130px;">
|
||||
<div style="box-sizing: border-box; font-size: 0; text-align: center; ">
|
||||
<div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">
|
||||
Rendered In
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</foreignObject>
|
||||
<text x="130" y="853" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">
|
||||
Rendered In
|
||||
</text>
|
||||
</switch>
|
||||
</g>
|
||||
</g>
|
||||
<switch>
|
||||
<g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/>
|
||||
<a transform="translate(0,-5)" xlink:href="https://desk.draw.io/support/solutions/articles/16000042487" target="_blank">
|
||||
<text text-anchor="middle" font-size="10px" x="50%" y="100%">
|
||||
Viewer does not support full SVG 1.1
|
||||
</text>
|
||||
</a>
|
||||
</switch>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 24 KiB |
BIN
docs/ast-demo.gif
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
docs/custom-script-map.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
docs/custom-scripts.gif
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 3.5 MiB After Width: | Height: | Size: 4.2 MiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 17 KiB |
@@ -3,15 +3,13 @@
|
||||
[data-extraction]
|
||||
[webview]
|
||||
[extension]
|
||||
[visualization]
|
||||
[visualization-playground]
|
||||
[hediet/visualization]
|
||||
|
||||
[webview] ..> [extension]: "Uses RPC contracts, connects using websockets"
|
||||
[extension] ..> [webview]: "Loads into a Webview in VS Code"
|
||||
|
||||
[webview] ..> [visualization]: "Uses React Components"
|
||||
[webview] ..> [hediet/visualization]: "Uses React Components"
|
||||
|
||||
[visualization-playground] ..> [visualization]: "Uses React Components"
|
||||
|
||||
[extension] ..> [data-extraction]: "Injects Runtime into JavaScript applications"
|
||||
|
||||
|
||||
BIN
docs/table-demo.gif
Normal file
|
After Width: | Height: | Size: 2.6 MiB |
BIN
docs/visualization-plotly-random-walk.gif
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
@@ -1,2 +1 @@
|
||||
node_modules
|
||||
ui/node_modules
|
||||
./node_modules
|
||||
@@ -1,5 +1,37 @@
|
||||
# Change Log
|
||||
|
||||
## 2.6.0
|
||||
|
||||
- Improved JS data extractors
|
||||
- Uses the active stack frame (instead of the top-most) for evaluating expressions
|
||||
|
||||
## 2.4.0
|
||||
|
||||
- [Ruby support](https://github.com/hediet/vscode-debug-visualizer/pull/159)
|
||||
- New setting `debugVisualizer.customVisualizerScriptPaths` to support custom visualizations
|
||||
- Added JS data extractors
|
||||
|
||||
## 2.3.0
|
||||
|
||||
- [Improves support for python](https://github.com/hediet/vscode-debug-visualizer/pull/122)
|
||||
|
||||
## 2.2.0
|
||||
|
||||
- Adds setting `debugVisualizer.js.customScriptPaths` to inject custom scripts when debugging JavaScript. Such scripts are reloaded automatically when changed.
|
||||
|
||||
## 2.1.0
|
||||
|
||||
- Adds text diff and text decoration viewer.
|
||||
- Supports more js debug adapters
|
||||
|
||||
## 2.0.6
|
||||
|
||||
- Fixes grid extractor bug
|
||||
- Fixes Perspective.js bug
|
||||
- Fixes AST visualizer bug
|
||||
- Adds table data extractor
|
||||
- Improves typescript data extractor
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- Support for the new JS debug adapters
|
||||
|
||||
674
extension/LICENSE.md
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and`show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -3,218 +3,78 @@
|
||||
[](https://twitter.com/intent/follow?screen_name=hediet_dev)
|
||||
|
||||
A VS Code extension for visualizing data structures while debugging.
|
||||
Like the VS Code's watch view, but with custom visualizations.
|
||||
Like the VS Code's watch view, but with rich visualizations of the watched value.
|
||||
|
||||

|
||||
|
||||
## [Visualization Playground](https://hediet.github.io/visualization/)
|
||||
|
||||
Click [here](https://hediet.github.io/visualization/) to explore all available visualizations.
|
||||
|
||||
## Supported Languages
|
||||
|
||||
See [demos](../demos/) for demos. These languages and debuggers are verified to work with this extension:
|
||||
|
||||
- JavaScript/TypeScript/... using `node`/`node2`/`extensionHost` or `chrome` debug adapter: [⭐ Full Support](../demos/js)
|
||||
- Go using `go` (Delve) debug adapter: [✅ Rudimentary Support](../demos/golang)
|
||||
- Python using `python` debug adapter: [✅ Rudimentary Support](../demos/python)
|
||||
- C# using `coreclr` debug adapter: [✅ Rudimentary Support](../demos/csharp)
|
||||
- PHP using `php` debug adapter: [✅ Rudimentary Support](../demos/php)
|
||||
- Java using `java` debug adapter: [✅ Rudimentary Support](../demos/java)
|
||||
- C++ using `cppdbg` debug adapter: [✅ Rudimentary Support](../demos/cpp)
|
||||
- Swift using `lldb` debug adapter: [✅ Rudimentary Support](../demos/swift)
|
||||
- Rust using `lldb` debug adapter: [✅ Rudimentary Support](../demos/rust)
|
||||
- JavaScript/TypeScript/... using `node`/`node2`/`extensionHost`/`chrome`/`pwa-chrome`/`pwa-node` debug adapter: [⭐ Full Support](../demos/js)
|
||||
- Dart/Flutter using `dart` debug adapter: [✅ Basic Support](../demos/dart)
|
||||
- Go using `go` (Delve) debug adapter: [✅ Basic Support](../demos/golang)
|
||||
- Python using `python` debug adapter: [✅ Basic Support](../demos/python)
|
||||
- C# using `coreclr` debug adapter: [✅ Basic Support](../demos/csharp) (work in progress for Full Support)
|
||||
- PHP using `php` debug adapter: [✅ Basic Support](../demos/php)
|
||||
- Java using `java` debug adapter: [✅ Basic Support](../demos/java)
|
||||
- C++ using `cppdbg` debug adapter: [✅ Basic Support](../demos/cpp)
|
||||
- Swift using `lldb` debug adapter: [✅ Basic Support](../demos/swift)
|
||||
- Rust using `lldb` debug adapter: [✅ Basic Support](../demos/rust)
|
||||
- Ruby using `rdbg` debug adapter: [✅ Basic Support](../demos/ruby)
|
||||
|
||||
All other languages and debuggers might work too.
|
||||
For languages with _Rudimentary Support_, only JSON strings can be visualized - you must implement some logic that builds this JSON for your data structure!
|
||||
For languages with _Basic Support_, only JSON strings can be visualized - you must implement some logic that builds this JSON for your data structure!
|
||||
Fully supported languages offer _Data Extractors_ which convert some well known data structures to json.
|
||||
|
||||
## Usage
|
||||
|
||||
After installing this extension, use the command `Debug Visualizer: New View` to open a new visualizer view.
|
||||
In this view you can enter an expression that is evaluated and visualized while stepping through your application.
|
||||
This view works the same as the watch view of VS Code, except that the resulting value is presented visually rather than textually.
|
||||
This view works the same as the watch view of VS Code, except that the resulting value is presented visually rather than textually and you can only watch one expression (but you can still open multiple windows).
|
||||
|
||||
You can refresh the evaluation and open the current visualizer view into a new browser window by using the top right buttons.
|
||||
You can also unfold the details pane to select a _Data Extractor_ and a _Visualizer_.
|
||||
|
||||
Use the command `Debug Visualizer: Use Selection as Expression` (Shift + F1) to use the currently selected text as expression
|
||||
Use the command `Debug Visualizer: Use Selection as Expression` _(Shift + F1)_ to use the currently selected text as expression
|
||||
in the most recently opened debug visualizer.
|
||||
|
||||
## Supported Values
|
||||
|
||||
Visualizers consume specific JSON data. See [Integrated Visualizers](#Integrated%20Visualizers) for the schema of supported JSON data.
|
||||
Not all values can be processed.
|
||||
Visualizers consume specific JSON data. This extension uses [hediet/visualization](https://github.com/hediet/visualization), a generic visualization framework.
|
||||
You can see in its [playground](https://hediet.github.io/visualization/) which data can be visualized and how the visualization looks like.
|
||||
|
||||
The currently watched expression should evaluate to a JSON Object string,
|
||||
matching the schema of one of the supported visualizers. This JSON string may be surrounded by single or double quotation marks (or none at all) and must not be escaped.
|
||||
matching the [schema](https://hediet.github.io/visualization/docs/visualization-data-schema.json) of one of the supported visualizers. This JSON string may be surrounded by single or double quotation marks (or none at all) and must not be escaped.
|
||||
A valid example is `"{ "kind": { "text": true }, "text": "some text\nmore text" }"`.
|
||||
Use the watch window to see what an expression evaluates to. This extension simply interprets that result.
|
||||
|
||||
For some languages (TypeScript/JavaScript), runtime code is injected to support _Data Extractors_.
|
||||
A Data Extractor lifts the requirement for the visualized value to be a JSON string
|
||||
and acts as a bridge between custom data structures and the JSON data processed by the visualizers.
|
||||
When multiple Data Extractors are applicable, a preferred one can be selected in the visualization view.
|
||||
|
||||
## Integrated Visualizers
|
||||
There is a [JSON Schema for all supported visualizations](https://hediet.github.io/visualization/docs/visualization-data-schema.json) and a [typescript declaration file](https://hediet.github.io/visualization/docs/visualization-data.ts).
|
||||
|
||||
The following visualizers are built into this extension.
|
||||
## Selected Demos
|
||||
|
||||
### Graph Visualization
|
||||
### Reversing a Doubly Linked List
|
||||
|
||||
[Demo](https://hediet.github.io/vscode-debug-visualizer/?value=%7B%0A++++%22kind%22%3A+%7B+%22graph%22%3A+true+%7D%2C%0A++++%22nodes%22%3A+%5B%0A++++++++%7B+%22id%22%3A+%221%22%2C+%22label%22%3A+%221%22+%7D%2C%0A++++++++%7B+%22id%22%3A+%222%22%2C+%22label%22%3A+%222%22%2C+%22color%22%3A+%22orange%22+%7D%2C%0A++++++++%7B+%22id%22%3A+%223%22%2C+%22label%22%3A+%223%22+%7D%0A++++%5D%2C%0A++++%22edges%22%3A+%5B%0A++++++++%7B+%22from%22%3A+%221%22%2C+%22to%22%3A+%222%22%2C+%22color%22%3A+%22red%22+%7D%2C%0A++++++++%7B+%22from%22%3A+%221%22%2C+%22to%22%3A+%223%22+%7D%0A++++%5D%0A%7D).
|
||||
The Graphviz and vis.js visualizers render data that matches the `Graph` interface.
|
||||

|
||||
|
||||
```ts
|
||||
interface Graph {
|
||||
kind: { graph: true };
|
||||
nodes: NodeGraphData[];
|
||||
edges: EdgeGraphData[];
|
||||
}
|
||||
### Random Walk
|
||||
|
||||
interface NodeGraphData {
|
||||
id: string;
|
||||
label?: string;
|
||||
color?: string;
|
||||
shape?: "ellipse" | "box";
|
||||
}
|
||||

|
||||
|
||||
interface EdgeGraphData {
|
||||
from: string;
|
||||
to: string;
|
||||
label?: string;
|
||||
id?: string;
|
||||
color?: string;
|
||||
dashes?: boolean;
|
||||
}
|
||||
```
|
||||
### Ast Visualizer
|
||||
|
||||
The graphviz visualizer uses the SVG viewer to render the SVG created by `viz.js`.
|
||||

|
||||
|
||||

|
||||

|
||||
### Table Visualizer
|
||||
|
||||
### Plotly Visualization
|
||||
|
||||
[Demo](https://hediet.github.io/vscode-debug-visualizer/?value=%7B%22kind%22%3A%7B%22plotly%22%3Atrue%7D%2C%22data%22%3A%5B%7B%22y%22%3A%5B0%2C1%2C2%2C3%2C4%2C3%2C4%2C3%2C2%2C1%2C2%5D%7D%5D%7D).
|
||||
The plotly visualizer uses plotly and can visualize JSON data matching the following interface:
|
||||
|
||||
```ts
|
||||
export interface Plotly {
|
||||
kind: { plotly: true };
|
||||
data: Partial<Plotly.Data>[];
|
||||
}
|
||||
// See plotly docs for Plotly.Data.
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Tree Visualization
|
||||
|
||||
The tree visualizer renders data that matches the `Tree` interface.
|
||||
|
||||
```ts
|
||||
interface Tree<TData = unknown> {
|
||||
kind: { tree: true };
|
||||
root: TreeNode<TData>;
|
||||
}
|
||||
interface TreeNode<TExtraData> {
|
||||
id: string | undefined;
|
||||
name: string;
|
||||
value: string | undefined;
|
||||
emphasizedValue: string | undefined;
|
||||
children: TreeNode<TExtraData>[];
|
||||
data: TExtraData;
|
||||
isMarked: boolean;
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
### AST Visualization
|
||||
|
||||
[Demo](https://hediet.github.io/vscode-debug-visualizer/?value=%7B%22kind%22%3A%7B%22text%22%3Atrue%2C%22tree%22%3Atrue%2C%22ast%22%3Atrue%7D%2C%22root%22%3A%7B%22name%22%3A%22SourceFile%22%2C%22id%22%3A%22root%22%2C%22children%22%3A%5B%7B%22name%22%3A%22ClassDeclaration%22%2C%22id%22%3A%22statements%22%2C%22children%22%3A%5B%7B%22name%22%3A%22Identifier%22%2C%22id%22%3A%22name%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A6%2C%22position%22%3A6%7D%2C%22isMarked%22%3Afalse%2C%22value%22%3A%22Test1%22%7D%2C%7B%22name%22%3A%22MethodDeclaration%22%2C%22id%22%3A%22members%22%2C%22children%22%3A%5B%7B%22name%22%3A%22PublicKeyword%22%2C%22id%22%3A%22modifiers%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A8%2C%22position%22%3A14%7D%2C%22isMarked%22%3Afalse%7D%2C%7B%22name%22%3A%22Identifier%22%2C%22id%22%3A%22name%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A4%2C%22position%22%3A22%7D%2C%22isMarked%22%3Afalse%2C%22value%22%3A%22foo%22%7D%2C%7B%22name%22%3A%22Parameter%22%2C%22id%22%3A%22parameters%22%2C%22children%22%3A%5B%7B%22name%22%3A%22Identifier%22%2C%22id%22%3A%22name%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A1%2C%22position%22%3A27%7D%2C%22isMarked%22%3Afalse%2C%22value%22%3A%22a%22%7D%2C%7B%22name%22%3A%22NumberKeyword%22%2C%22id%22%3A%22type%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A7%2C%22position%22%3A29%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A9%2C%22position%22%3A27%7D%2C%22isMarked%22%3Afalse%7D%2C%7B%22name%22%3A%22Block%22%2C%22id%22%3A%22body%22%2C%22children%22%3A%5B%7B%22name%22%3A%22VariableStatement%22%2C%22id%22%3A%22statements%22%2C%22children%22%3A%5B%7B%22name%22%3A%22VariableDeclarationList%22%2C%22id%22%3A%22declarationList%22%2C%22children%22%3A%5B%7B%22name%22%3A%22VariableDeclaration%22%2C%22id%22%3A%22declarations%22%2C%22children%22%3A%5B%7B%22name%22%3A%22Identifier%22%2C%22id%22%3A%22name%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A2%2C%22position%22%3A47%7D%2C%22isMarked%22%3Afalse%2C%22value%22%3A%22x%22%7D%2C%7B%22name%22%3A%22ObjectLiteralExpression%22%2C%22id%22%3A%22initializer%22%2C%22children%22%3A%5B%7B%22name%22%3A%22PropertyAssignment%22%2C%22id%22%3A%22properties%22%2C%22children%22%3A%5B%7B%22name%22%3A%22Identifier%22%2C%22id%22%3A%22name%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A2%2C%22position%22%3A53%7D%2C%22isMarked%22%3Afalse%2C%22value%22%3A%22a%22%7D%2C%7B%22name%22%3A%22FirstLiteralToken%22%2C%22id%22%3A%22initializer%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A2%2C%22position%22%3A56%7D%2C%22isMarked%22%3Afalse%2C%22value%22%3A%225%22%7D%5D%2C%22data%22%3A%7B%22length%22%3A5%2C%22position%22%3A53%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A9%2C%22position%22%3A51%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A13%2C%22position%22%3A47%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A21%2C%22position%22%3A39%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A22%2C%22position%22%3A39%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A27%2C%22position%22%3A37%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A50%2C%22position%22%3A14%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A66%2C%22position%22%3A0%7D%2C%22isMarked%22%3Afalse%7D%2C%7B%22name%22%3A%22EndOfFileToken%22%2C%22id%22%3A%22endOfFileToken%22%2C%22children%22%3A%5B%5D%2C%22data%22%3A%7B%22length%22%3A1%2C%22position%22%3A66%7D%2C%22isMarked%22%3Afalse%7D%5D%2C%22data%22%3A%7B%22length%22%3A67%2C%22position%22%3A0%7D%2C%22isMarked%22%3Atrue%7D%2C%22text%22%3A%22%5Cnclass+Test1+%7B%5Cn%5Ctpublic+foo%28a%3A+number%29+%7B%5Cn%5Ct%5Ctconst+x+%3D+%7B+a%3A+5+%7D%3B%5Cn%5Ct%7D%5Cn%7D%5Cn%22%2C%22fileName%22%3A%22index.ts%22%7D).
|
||||
The AST (Abstract Syntax Tree) visualizer renders data that matches the `Ast` interface.
|
||||
|
||||
```ts
|
||||
interface Ast
|
||||
extends Tree<{
|
||||
position: number;
|
||||
length: number;
|
||||
}>,
|
||||
Text {
|
||||
kind: { text: true; tree: true; ast: true };
|
||||
}
|
||||
```
|
||||
|
||||
Additionally to the tree view, the source code is rendered and when selecting an AST node,
|
||||
its span in the source code is highlighted.
|
||||
|
||||

|
||||
|
||||
### Grid Visualization
|
||||
|
||||
Visualizes data matching the following interface:
|
||||
|
||||
```ts
|
||||
export interface Grid {
|
||||
kind: { array: true };
|
||||
columnLabels?: { label?: string }[];
|
||||
rows: {
|
||||
label?: string;
|
||||
columns: {
|
||||
content?: string;
|
||||
tag?: string;
|
||||
color?: string;
|
||||
}[];
|
||||
}[];
|
||||
markers?: {
|
||||
id: string;
|
||||
|
||||
row: number;
|
||||
column: number;
|
||||
rows?: number;
|
||||
columns?: number;
|
||||
|
||||
label?: string;
|
||||
color?: string;
|
||||
}[];
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Text Visualization
|
||||
|
||||
The text visualizer renders data that matches the `Text` interface.
|
||||
|
||||
```ts
|
||||
interface Text {
|
||||
kind: { text: true };
|
||||
text: string;
|
||||
mimeType?: string;
|
||||
fileName?: string;
|
||||
}
|
||||
```
|
||||
|
||||
The `mimeType` and the file extension of `fileName` are used for syntax highlighting.
|
||||
|
||||
### SVG Visualization
|
||||
|
||||
The SVG visualizer renders data that matches the `Svg` interface.
|
||||
The actual SVG data must be stored in `text`.
|
||||
|
||||
```ts
|
||||
interface Svg extends Text {
|
||||
kind: { text: true; svg: true };
|
||||
}
|
||||
```
|
||||
|
||||
### Dot Graph Visualization
|
||||
|
||||
The Graphviz Dot visualizer renders data that matches the `DotGraph` interface.
|
||||
|
||||
```ts
|
||||
interface DotGraph extends Text {
|
||||
kind: { text: true; dotGraph: true };
|
||||
}
|
||||
```
|
||||
|
||||
`Viz.js` (Graphviz) is used for rendering.
|
||||

|
||||
|
||||
## JavaScript/TypeScript Integrated Data Extractors
|
||||
|
||||
@@ -224,35 +84,22 @@ Custom data extractors can be registered too.
|
||||
See the package `@hediet/debug-visualizer-data-extraction` and its [README](../data-extraction/README.md) for the implementation and its API.
|
||||
Also, a global object of name `hedietDbgVis` with helper functions is injected.
|
||||
|
||||
### ToString
|
||||
|
||||
Just calls `.toString()` on values and treats the result as text.
|
||||
|
||||
### TypeScript AST
|
||||
|
||||
- Direct Visualization of `ts.Node`s
|
||||
- Visualization of `Record<string, ts.Node>` and `[ts.Node]`. If the record contains a key `fn`, its value is displayed for each node.
|
||||
|
||||
### As Is Data Extractor
|
||||
|
||||
Treats the data as direct input to the visualizer.
|
||||
|
||||
### Use Method 'getDebugVisualization'
|
||||
|
||||
Calls `.getDebugVisualization()` on values and treats the result as direct input to the visualizer.
|
||||
|
||||
### Plotly y-Values
|
||||
|
||||
Uses plotly to plot an array of numbers.
|
||||
|
||||
### Object Graph
|
||||
|
||||
Constructs a graph containing all objects reachable from object the expression evaluates to.
|
||||
Graph is constructed using a breadth search. Stops after 50 nodes.
|
||||
|
||||
### Array Grid
|
||||
|
||||
Creates Grid visualization data for an array.
|
||||
- **ToString**
|
||||
- Just calls `.toString()` on values and treats the result as text.
|
||||
- **TypeScript AST**
|
||||
- Direct Visualization of `ts.Node`s
|
||||
- Visualization of `Record<string, ts.Node>` and `ts.Node[]`. If the record contains a key `fn`, its value is displayed for each node.
|
||||
- **As Is Data Extractor**
|
||||
- Treats the data as direct input to the visualizer.
|
||||
- **Use Method 'getVisualizationData'**
|
||||
- Calls `.getVisualizationData()` on values and treats the result as direct input to the visualizer.
|
||||
- **Plotly y-Values**
|
||||
- Uses plotly to plot an array of numbers.
|
||||
- **Object Graph**
|
||||
- Constructs a graph containing all objects reachable from object the expression evaluates to.
|
||||
Graph is constructed using a breadth search. Stops after 50 nodes.
|
||||
- **Array Grid**
|
||||
- Creates Grid visualization data for an array.
|
||||
|
||||
## UI Features
|
||||
|
||||
@@ -266,25 +113,71 @@ Creates Grid visualization data for an array.
|
||||
|
||||
This extension provides these configuration options:
|
||||
|
||||
- `debugVisualizer.debugAdapterConfigurations`
|
||||
### **debugVisualizer.debugAdapterConfigurations**
|
||||
|
||||
Allows to set expression templates for specific debug adapter types.
|
||||
Example:
|
||||
Allows to set expression templates for specific debug adapter types.
|
||||
Example:
|
||||
|
||||
```json
|
||||
"debugVisualizer.debugAdapterConfigurations": {
|
||||
"lldb": {
|
||||
"expressionTemplate": "script to_json(\"${expr}\")",
|
||||
"context": "repl"
|
||||
}
|
||||
```json
|
||||
"debugVisualizer.debugAdapterConfigurations": {
|
||||
"lldb": {
|
||||
"expressionTemplate": "script to_json(\"${expr}\")",
|
||||
"context": "repl"
|
||||
}
|
||||
```
|
||||
}
|
||||
```
|
||||
|
||||
Configurations here overwrite the built-in support for the corresponding debug adapter type.
|
||||
Configurations here overwrite the built-in support for the corresponding debug adapter type.
|
||||
|
||||
* `debugVisualizer.useChromeKioskMode`
|
||||
### **debugVisualizer.useChromeKioskMode**
|
||||
|
||||
Specifies whether to pop out Debug Visualization Views with Chrome in Kiosk Mode. Uses the default browser otherwise or if Chrome is not found. Defaults to `true`.
|
||||
Specifies whether to pop out Debug Visualization Views with Chrome in Kiosk Mode. Uses the default browser otherwise or if Chrome is not found. Defaults to `true`.
|
||||
|
||||
### **debugVisualizer.js.customScriptPaths**
|
||||
|
||||
Specifies a list of JavaScript files that are injected into the debugee when debugging JavaScript.
|
||||
Each script must assign `module.exports` with a function of type `import("@hediet/debug-visualizer-data-extraction").LoadDataExtractorsFn`.
|
||||
Paths must be absolute and can use the variable `${workspaceFolder}`.
|
||||
Scripts are automatically reloaded when they are changed.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// @ts-check
|
||||
/**
|
||||
* @type {import("@hediet/debug-visualizer-data-extraction").LoadDataExtractorsFn}
|
||||
*/
|
||||
module.exports = (register, helpers) => {
|
||||
register({
|
||||
id: "map",
|
||||
getExtractions(data, collector, context) {
|
||||
if (!(data instanceof Map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
collector.addExtraction({
|
||||
priority: 1000,
|
||||
id: "map",
|
||||
name: "Map",
|
||||
extractData() {
|
||||
return helpers.asData({
|
||||
kind: { table: true },
|
||||
rows: [...data].map(([k, v]) => ({
|
||||
key: k,
|
||||
value: v,
|
||||
})),
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
```
|
||||
|
||||

|
||||
|
||||
Use the `helpers` object to access some magic functions.
|
||||
`helpers.find(val => ...)` can be used to find an object that is reachable by any variable in scope.
|
||||
|
||||
# See Also
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
"displayName": "Debug Visualizer",
|
||||
"description": "A visual watch window that lets you visualize your data structures while debugging.",
|
||||
"icon": "docs/logo.drawio.png",
|
||||
"version": "2.0.0",
|
||||
"version": "2.6.0",
|
||||
"license": "GPL-3.0",
|
||||
"engines": {
|
||||
"vscode": "^1.46.0"
|
||||
"vscode": "^1.84.0"
|
||||
},
|
||||
"publisher": "hediet",
|
||||
"keywords": [
|
||||
@@ -36,11 +36,14 @@
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onCommand:vscode-debug-visualizer.new-visualizer",
|
||||
"onCommand:vscode-debug-visualizer.visualizer-set-expression",
|
||||
"onDebug",
|
||||
"onWebviewPanel:debugVisualizer"
|
||||
],
|
||||
"capabilities": {
|
||||
"untrustedWorkspaces": {
|
||||
"supported": false
|
||||
}
|
||||
},
|
||||
"main": "./dist/extension.js",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
@@ -63,6 +66,22 @@
|
||||
"configuration": {
|
||||
"title": "Debug Visualizer",
|
||||
"properties": {
|
||||
"debugVisualizer.js.customScriptPaths": {
|
||||
"type": "array",
|
||||
"description": "Defines JavaScript sources that are injected into the debuggee to provide custom data extractors.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"description": "The file path to a custom js script. Must be absolute. You can use ${workspaceFolder}. Must assign `module.exports` an object of type `import('@hediet/debug-visualizer-data-extraction').LoadDataExtractorsFn`."
|
||||
}
|
||||
},
|
||||
"debugVisualizer.customVisualizerScriptPaths": {
|
||||
"type": "array",
|
||||
"description": "Defines JavaScript sources that are injected into the visualizer to provide custom visualizations.",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"description": "The file path to a custom js script. Must be absolute. You can use ${workspaceFolder}. Must assign `module.exports` an object of type `import('@hediet/visualization-core').RegisterVisualizerFn`."
|
||||
}
|
||||
},
|
||||
"debugVisualizer.useChromeKioskMode": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
@@ -92,9 +111,9 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"pub": "vsce publish --yarn --baseImagesUrl https://github.com/hediet/vscode-debug-visualizer/raw/master/extension --baseContentUrl https://github.com/hediet/vscode-debug-visualizer/raw/master/extension",
|
||||
"package": "vsce package --yarn",
|
||||
"vscode:prepublish": "yarn build",
|
||||
"pub": "vsce publish --packagePath ./dist/extension.vsix",
|
||||
"package": "vsce package --no-dependencies -o ./dist/extension.vsix --yarn --baseImagesUrl https://github.com/hediet/vscode-debug-visualizer/raw/master/extension --baseContentUrl https://github.com/hediet/vscode-debug-visualizer/raw/master/extension",
|
||||
"vscode:prepublish": "",
|
||||
"build": "webpack --mode production",
|
||||
"dev": "shx rm -rf dist && tsc -watch -p ./"
|
||||
},
|
||||
@@ -112,17 +131,18 @@
|
||||
"mobx-utils": "^5.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"copy-webpack-plugin": "^5.1.1",
|
||||
"@types/copy-webpack-plugin": "^5.0.0",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"@types/copy-webpack-plugin": "^10.1.0",
|
||||
"@types/express": "^4.17.2",
|
||||
"@types/serve-static": "^1.13.3",
|
||||
"@types/node": "^13.7.4",
|
||||
"@types/vscode": "1.46.0",
|
||||
"tslint": "^6.0.0",
|
||||
"typescript": "^3.8.2",
|
||||
"webpack": "^4.41.6",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"ts-loader": "^6.2.1",
|
||||
"shx": "^0.3.2"
|
||||
"@types/vscode": "^1.84.0",
|
||||
"tslint": "^6.1.3",
|
||||
"typescript": "^5.1.6",
|
||||
"webpack": "^5.88.1",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"ts-loader": "^9.4.4",
|
||||
"shx": "^0.3.2",
|
||||
"vsce": "2.9.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,52 @@ export class Config {
|
||||
{ serializer: serializerWithDefault<DebugAdapterConfigs>({}) }
|
||||
);
|
||||
|
||||
private readonly _customScriptPaths = new VsCodeSetting(
|
||||
"debugVisualizer.js.customScriptPaths",
|
||||
{ serializer: serializerWithDefault<string[]>([]) }
|
||||
);
|
||||
|
||||
public get customScriptPaths(): string[] {
|
||||
return this._customScriptPaths.get().map((p) => {
|
||||
const tpl = new SimpleTemplate(p);
|
||||
return tpl.render({
|
||||
workspaceFolder: () => {
|
||||
const workspaceFolder = (workspace.workspaceFolders ||
|
||||
[])[0];
|
||||
if (!workspaceFolder) {
|
||||
throw new Error(
|
||||
`Cannot get workspace folder - '${p}' cannot be evaluated!`
|
||||
);
|
||||
}
|
||||
return workspaceFolder.uri.fsPath;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private readonly _customVisualizerScriptPaths = new VsCodeSetting(
|
||||
"debugVisualizer.customVisualizerScriptPaths",
|
||||
{ serializer: serializerWithDefault<string[]>([]) }
|
||||
);
|
||||
|
||||
public get customVisualizerScriptPaths(): string[] {
|
||||
return this._customVisualizerScriptPaths.get().map((p) => {
|
||||
const tpl = new SimpleTemplate(p);
|
||||
return tpl.render({
|
||||
workspaceFolder: () => {
|
||||
const workspaceFolder = (workspace.workspaceFolders ||
|
||||
[])[0];
|
||||
if (!workspaceFolder) {
|
||||
throw new Error(
|
||||
`Cannot get workspace folder - '${p}' cannot be evaluated!`
|
||||
);
|
||||
}
|
||||
return workspaceFolder.uri.fsPath;
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@observable
|
||||
private _vsCodeTheme = window.activeColorTheme;
|
||||
|
||||
@@ -85,3 +131,13 @@ function evaluateTemplate(
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export class SimpleTemplate {
|
||||
constructor(private readonly str: string) {}
|
||||
|
||||
render(data: Record<string, () => string>): string {
|
||||
return this.str.replace(/\$\{([a-zA-Z0-9]+)\}/g, (substr, grp1) => {
|
||||
return data[grp1]();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { EvaluationEngine, Evaluator } from "./EvaluationEngine";
|
||||
import { EnhancedDebugSession } from "../../debugger/EnhancedDebugSession";
|
||||
|
||||
export class ComposedEvaluationEngine implements EvaluationEngine {
|
||||
constructor(public readonly engines: EvaluationEngine[]) {}
|
||||
|
||||
createEvaluator(session: EnhancedDebugSession): Evaluator | undefined {
|
||||
for (const f of this.engines) {
|
||||
const evaluator = f.createEvaluator(session);
|
||||
if (evaluator) {
|
||||
return evaluator;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
import { DataExtractorId } from "@hediet/debug-visualizer-data-extraction";
|
||||
import { EnhancedDebugSession } from "../../debugger/EnhancedDebugSession";
|
||||
import { EvaluationEngine, Evaluator } from "./EvaluationEngine";
|
||||
import { Config, DebugAdapterConfig } from "../../Config";
|
||||
import { GenericEvaluator } from "./GenericEvaluationEngine";
|
||||
import { registerUpdateReconciler, hotClass } from "@hediet/node-reload";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class ConfiguredEvaluationEngine implements EvaluationEngine {
|
||||
constructor(private readonly config: Config) {}
|
||||
|
||||
createEvaluator(session: EnhancedDebugSession): Evaluator | undefined {
|
||||
const config = this.config.getDebugAdapterConfig(session.session.type);
|
||||
if (!config) {
|
||||
return undefined;
|
||||
}
|
||||
return new ConfiguredEvaluator(session, config);
|
||||
}
|
||||
}
|
||||
|
||||
class ConfiguredEvaluator extends GenericEvaluator {
|
||||
constructor(
|
||||
session: EnhancedDebugSession,
|
||||
private readonly config: DebugAdapterConfig
|
||||
) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
protected getContext() {
|
||||
return this.config.context;
|
||||
}
|
||||
|
||||
protected getFinalExpression({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
}: {
|
||||
expression: string;
|
||||
preferredExtractorId: DataExtractorId | undefined;
|
||||
}) {
|
||||
return this.config.getFinalExpression({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
import {
|
||||
DataExtractionResult,
|
||||
DataExtractorId,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { EnhancedDebugSession } from "../../debugger/EnhancedDebugSession";
|
||||
import { FormattedMessage } from "../../webviewContract";
|
||||
|
||||
export interface EvaluationEngine {
|
||||
createEvaluator(session: EnhancedDebugSession): Evaluator | undefined;
|
||||
}
|
||||
|
||||
export interface Evaluator {
|
||||
evaluate(
|
||||
args: EvaluationArgs
|
||||
): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
>;
|
||||
|
||||
/**
|
||||
* The language that expressions must be written in.
|
||||
*/
|
||||
readonly languageId: string | undefined;
|
||||
}
|
||||
|
||||
export interface EvaluationArgs {
|
||||
expression: string;
|
||||
preferredExtractorId: DataExtractorId | undefined;
|
||||
frameId: number | undefined;
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
import {
|
||||
DataExtractionResult,
|
||||
DataExtractorId,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { EnhancedDebugSession } from "../../debugger/EnhancedDebugSession";
|
||||
import {
|
||||
EvaluationEngine,
|
||||
Evaluator,
|
||||
EvaluationArgs,
|
||||
} from "./EvaluationEngine";
|
||||
import { parseEvaluationResultFromGenericDebugAdapter } from "./parseEvaluationResultFromGenericDebugAdapter";
|
||||
import { FormattedMessage } from "../../webviewContract";
|
||||
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class GenericEvaluationEngine implements EvaluationEngine {
|
||||
createEvaluator(session: EnhancedDebugSession): Evaluator | undefined {
|
||||
return new GenericEvaluator(session);
|
||||
}
|
||||
}
|
||||
|
||||
export class GenericEvaluator implements Evaluator {
|
||||
public readonly languageId = "text";
|
||||
|
||||
constructor(private readonly session: EnhancedDebugSession) {}
|
||||
|
||||
public async evaluate({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
frameId,
|
||||
}: EvaluationArgs): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
const finalExpression = this.getFinalExpression({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
});
|
||||
let reply;
|
||||
try {
|
||||
reply = await this.session.evaluate({
|
||||
expression: finalExpression,
|
||||
frameId,
|
||||
context: this.getContext(),
|
||||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
kind: "error",
|
||||
message: {
|
||||
kind: "list",
|
||||
items: [
|
||||
"An error occurred while evaluating the expression:",
|
||||
error.message,
|
||||
`Used debug adapter: ${this.session.session.configuration.type}`,
|
||||
{
|
||||
kind: "inlineList",
|
||||
items: [
|
||||
"Evaluated expression is",
|
||||
{ kind: "code", content: finalExpression },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return parseEvaluationResultFromGenericDebugAdapter(reply.result, {
|
||||
debugAdapterType: this.session.session.configuration.type,
|
||||
});
|
||||
}
|
||||
|
||||
protected getFinalExpression(args: {
|
||||
expression: string;
|
||||
preferredExtractorId: DataExtractorId | undefined;
|
||||
}): string {
|
||||
return args.expression;
|
||||
}
|
||||
|
||||
protected getContext(): "watch" | "repl" {
|
||||
// we will use "repl" as default so that results are not truncated.
|
||||
return "repl";
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
import {
|
||||
getExpressionForDataExtractorApi,
|
||||
DataResult,
|
||||
ApiHasNotBeenInitializedCode,
|
||||
getExpressionToInitializeDataExtractorApi,
|
||||
DataExtractionResult,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { EnhancedDebugSession } from "../../debugger/EnhancedDebugSession";
|
||||
import {
|
||||
EvaluationEngine,
|
||||
Evaluator,
|
||||
EvaluationArgs,
|
||||
} from "./EvaluationEngine";
|
||||
import { FormattedMessage } from "../../webviewContract";
|
||||
import { registerUpdateReconciler, hotClass } from "@hediet/node-reload";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class JsEvaluationEngine implements EvaluationEngine {
|
||||
createEvaluator(session: EnhancedDebugSession): Evaluator | undefined {
|
||||
const supportedDebugAdapters = [
|
||||
"node",
|
||||
"node2",
|
||||
"extensionHost",
|
||||
"chrome",
|
||||
"pwa-chrome",
|
||||
"pwa-node",
|
||||
];
|
||||
if (supportedDebugAdapters.indexOf(session.session.type) !== -1) {
|
||||
return new JsEvaluator(session);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class JsEvaluator implements Evaluator {
|
||||
public readonly languageId = "javascript";
|
||||
|
||||
constructor(private readonly session: EnhancedDebugSession) {}
|
||||
|
||||
private getContext(): "copy" | "repl" {
|
||||
if (this.session.session.type.startsWith("pwa-")) {
|
||||
return "copy";
|
||||
}
|
||||
return "repl";
|
||||
}
|
||||
|
||||
public async evaluate({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
frameId,
|
||||
}: EvaluationArgs): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
while (true) {
|
||||
try {
|
||||
const preferredExtractorExpr = preferredExtractorId
|
||||
? `"${preferredExtractorId}"`
|
||||
: "undefined";
|
||||
|
||||
const body = `${getExpressionForDataExtractorApi()}.getData(
|
||||
e => (${expression}),
|
||||
expr => eval(expr),
|
||||
${preferredExtractorExpr}
|
||||
)`;
|
||||
|
||||
const wrappedExpr = `
|
||||
(() => {
|
||||
try {
|
||||
return ${body};
|
||||
} catch (e) {
|
||||
return JSON.stringify({
|
||||
kind: "Error",
|
||||
message: e.message,
|
||||
stack: e.stack
|
||||
});
|
||||
}
|
||||
})()
|
||||
`;
|
||||
|
||||
const reply = await this.session.evaluate({
|
||||
expression: wrappedExpr,
|
||||
frameId,
|
||||
context: this.getContext(),
|
||||
});
|
||||
const resultStr = reply.result;
|
||||
const jsonData =
|
||||
this.getContext() === "copy"
|
||||
? resultStr
|
||||
: resultStr.substr(1, resultStr.length - 2);
|
||||
const result = JSON.parse(jsonData) as DataResult;
|
||||
|
||||
if (result.kind === "NoExtractors") {
|
||||
throw new Error("No extractors");
|
||||
} else if (result.kind === "Error") {
|
||||
throw new Error(result.message);
|
||||
} else if (result.kind === "Data") {
|
||||
return {
|
||||
kind: "data",
|
||||
result: result.extractionResult,
|
||||
};
|
||||
} else {
|
||||
throw new Error("Invalid Data");
|
||||
}
|
||||
} catch (error) {
|
||||
const msg = error.message as string | undefined;
|
||||
if (msg && msg.includes(ApiHasNotBeenInitializedCode)) {
|
||||
if (await this.initializeApi(frameId)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
kind: "error",
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async initializeApi(frameId: number | undefined): Promise<boolean> {
|
||||
try {
|
||||
// prefer existing is true, so that manually registered (possibly newer) extractors are not overwritten.
|
||||
const expression = `${getExpressionToInitializeDataExtractorApi()}.registerDefaultExtractors(true);`;
|
||||
|
||||
await this.session.evaluate({
|
||||
expression,
|
||||
frameId,
|
||||
context: this.getContext(),
|
||||
});
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export * from "./EvaluationEngine";
|
||||
|
||||
export { ComposedEvaluationEngine } from "./ComposedEvaluationEngine";
|
||||
export { JsEvaluationEngine } from "./JsEvaluationEngine";
|
||||
export { GenericEvaluationEngine } from "./GenericEvaluationEngine";
|
||||
export { ConfiguredEvaluationEngine } from "./ConfiguredEvaluationEngine";
|
||||
@@ -1,146 +0,0 @@
|
||||
import {
|
||||
EvaluationWatchService,
|
||||
EvaluationWatcher,
|
||||
EvaluationWatcherOptions,
|
||||
} from "./EvaluationWatchService";
|
||||
import { observable, autorun, action } from "mobx";
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { DataExtractorId } from "@hediet/debug-visualizer-data-extraction";
|
||||
import { DataExtractionState, CompletionItem } from "../webviewContract";
|
||||
import { hotClass } from "@hediet/node-reload";
|
||||
import { VsCodeDebuggerView } from "../debugger/VsCodeDebuggerView";
|
||||
import { EvaluationEngine } from "./EvaluationEngine/EvaluationEngine";
|
||||
|
||||
@hotClass(module)
|
||||
export class EvaluationWatchServiceImpl implements EvaluationWatchService {
|
||||
public readonly dispose = Disposable.fn();
|
||||
private readonly watchers = new Set<ObservableEvaluationWatcher>();
|
||||
|
||||
constructor(
|
||||
private readonly vsCodeDebuggerView: VsCodeDebuggerView,
|
||||
private readonly evaluationEngine: EvaluationEngine
|
||||
) {
|
||||
this.dispose.track({
|
||||
dispose: autorun(() => {
|
||||
if (
|
||||
vsCodeDebuggerView.activeDebugSession &&
|
||||
vsCodeDebuggerView.activeFrameId !== undefined
|
||||
) {
|
||||
for (const w of this.watchers) {
|
||||
w.refresh();
|
||||
}
|
||||
}
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
public createEvaluationWatcher(
|
||||
expression: string,
|
||||
options: EvaluationWatcherOptions
|
||||
): EvaluationWatcher {
|
||||
const w = new ObservableEvaluationWatcher(expression, this, options);
|
||||
this.watchers.add(w);
|
||||
this.refresh(w);
|
||||
return w;
|
||||
}
|
||||
|
||||
public removeWatcher(w: ObservableEvaluationWatcher) {
|
||||
this.watchers.delete(w);
|
||||
}
|
||||
|
||||
private lastLanguageId: string | undefined = undefined;
|
||||
|
||||
get languageId(): string | undefined {
|
||||
const session = this.vsCodeDebuggerView.activeDebugSession;
|
||||
if (!session) {
|
||||
return this.lastLanguageId;
|
||||
}
|
||||
const evaluator = this.evaluationEngine.createEvaluator(session);
|
||||
if (!evaluator) {
|
||||
return this.lastLanguageId;
|
||||
}
|
||||
this.lastLanguageId = evaluator.languageId;
|
||||
return evaluator.languageId;
|
||||
}
|
||||
|
||||
public async refresh(w: ObservableEvaluationWatcher): Promise<void> {
|
||||
const session = this.vsCodeDebuggerView.activeDebugSession;
|
||||
if (!session) {
|
||||
w._state = { kind: "noDebugSession" };
|
||||
return;
|
||||
}
|
||||
|
||||
const frameId = this.vsCodeDebuggerView.activeFrameId;
|
||||
|
||||
w._state = { kind: "loading" };
|
||||
|
||||
const evaluator = this.evaluationEngine.createEvaluator(session);
|
||||
if (!evaluator) {
|
||||
w._state = {
|
||||
kind: "error",
|
||||
message: `The debug adapter "${session.session.type}" is not supported.`,
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await evaluator.evaluate({
|
||||
expression: w.expression,
|
||||
frameId,
|
||||
preferredExtractorId: w.preferredDataExtractor,
|
||||
});
|
||||
|
||||
w._state = result;
|
||||
}
|
||||
|
||||
public async getCompletions(
|
||||
text: string,
|
||||
column: number
|
||||
): Promise<CompletionItem[]> {
|
||||
const session = this.vsCodeDebuggerView.activeDebugSession;
|
||||
if (!session) {
|
||||
return [];
|
||||
}
|
||||
return await session.getCompletions({
|
||||
text,
|
||||
frameId: this.vsCodeDebuggerView.activeFrameId,
|
||||
column,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class ObservableEvaluationWatcher implements EvaluationWatcher {
|
||||
constructor(
|
||||
public readonly expression: string,
|
||||
private readonly source: EvaluationWatchServiceImpl,
|
||||
options: EvaluationWatcherOptions
|
||||
) {
|
||||
this._preferredDataExtractor = options.preferredDataExtractor;
|
||||
}
|
||||
|
||||
@observable
|
||||
private _preferredDataExtractor: DataExtractorId | undefined = undefined;
|
||||
|
||||
public get preferredDataExtractor(): DataExtractorId | undefined {
|
||||
return this._preferredDataExtractor;
|
||||
}
|
||||
|
||||
@action
|
||||
public setPreferredDataExtractor(id: DataExtractorId | undefined): void {
|
||||
this._preferredDataExtractor = id;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
public refresh(): void {
|
||||
this.source.refresh(this);
|
||||
}
|
||||
|
||||
@observable
|
||||
public _state: DataExtractionState = { kind: "loading" };
|
||||
public get state(): DataExtractionState {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this.source.removeWatcher(this);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from "./EvaluationWatchServiceImpl";
|
||||
export * from "./EvaluationWatchService";
|
||||
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
DebugSessionVisualizationSupport,
|
||||
VisualizationBackend,
|
||||
} from "./VisualizationBackend";
|
||||
import { DebugSessionProxy } from "../proxies/DebugSessionProxy";
|
||||
|
||||
export class ComposedVisualizationSupport
|
||||
implements DebugSessionVisualizationSupport {
|
||||
constructor(public readonly engines: DebugSessionVisualizationSupport[]) {}
|
||||
|
||||
createBackend(
|
||||
session: DebugSessionProxy
|
||||
): VisualizationBackend | undefined {
|
||||
for (const f of this.engines) {
|
||||
const evaluator = f.createBackend(session);
|
||||
if (evaluator) {
|
||||
return evaluator;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { DataExtractorId } from "@hediet/debug-visualizer-data-extraction";
|
||||
import { DebugSessionProxy } from "../proxies/DebugSessionProxy";
|
||||
import {
|
||||
DebugSessionVisualizationSupport,
|
||||
VisualizationBackend,
|
||||
} from "./VisualizationBackend";
|
||||
import { Config, DebugAdapterConfig } from "../Config";
|
||||
import { GenericVisualizationBackend } from "./GenericVisualizationSupport";
|
||||
import { registerUpdateReconciler, hotClass } from "@hediet/node-reload";
|
||||
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class ConfigurableVisualizationSupport
|
||||
implements DebugSessionVisualizationSupport {
|
||||
constructor(
|
||||
private readonly config: Config,
|
||||
private readonly debuggerView: DebuggerViewProxy
|
||||
) {}
|
||||
|
||||
createBackend(
|
||||
session: DebugSessionProxy
|
||||
): VisualizationBackend | undefined {
|
||||
const config = this.config.getDebugAdapterConfig(session.session.type);
|
||||
if (!config) {
|
||||
return undefined;
|
||||
}
|
||||
return new ConfiguredVisualizationBackend(
|
||||
session,
|
||||
this.debuggerView,
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ConfiguredVisualizationBackend extends GenericVisualizationBackend {
|
||||
constructor(
|
||||
debugSession: DebugSessionProxy,
|
||||
debuggerView: DebuggerViewProxy,
|
||||
private readonly config: DebugAdapterConfig
|
||||
) {
|
||||
super(debugSession, debuggerView);
|
||||
}
|
||||
|
||||
protected getContext() {
|
||||
return this.config.context;
|
||||
}
|
||||
|
||||
protected getFinalExpression({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
}: {
|
||||
expression: string;
|
||||
preferredExtractorId: DataExtractorId | undefined;
|
||||
}) {
|
||||
return this.config.getFinalExpression({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import { DataExtractionResult } from "@hediet/debug-visualizer-data-extraction";
|
||||
import { CompletionItem, FormattedMessage } from "../webviewContract";
|
||||
import {
|
||||
DebugSessionVisualizationSupport,
|
||||
GetVisualizationDataArgs,
|
||||
VisualizationBackend,
|
||||
} from "./VisualizationBackend";
|
||||
import { EventEmitter, EventSource } from "@hediet/std/events";
|
||||
import { debug } from "vscode";
|
||||
import { DebugSessionProxy } from "../proxies/DebugSessionProxy";
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
||||
import { autorun, reaction } from "mobx";
|
||||
|
||||
export class DispatchingVisualizationBackend implements VisualizationBackend {
|
||||
public readonly dispose = Disposable.fn();
|
||||
private readonly visualizationBackends = new Map<
|
||||
DebugSessionProxy,
|
||||
VisualizationBackend
|
||||
>();
|
||||
|
||||
protected readonly onChangeEmitter = new EventEmitter();
|
||||
public readonly onChange = this.onChangeEmitter;
|
||||
|
||||
constructor(
|
||||
private readonly visualizationSupport: DebugSessionVisualizationSupport,
|
||||
private readonly debuggerView: DebuggerViewProxy
|
||||
) {
|
||||
this.dispose.track(
|
||||
debug.onDidTerminateDebugSession(session => {
|
||||
const existing = [...this.visualizationBackends].find(
|
||||
v => v[0].session === session
|
||||
);
|
||||
if (existing) {
|
||||
this.visualizationBackends.delete(existing[0]);
|
||||
existing[1].dispose();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
this.dispose.track({
|
||||
dispose: () => {
|
||||
for (const backend of this.visualizationBackends.values()) {
|
||||
backend.dispose();
|
||||
}
|
||||
this.visualizationBackends.clear();
|
||||
},
|
||||
});
|
||||
|
||||
this.dispose.track({
|
||||
dispose: reaction(
|
||||
() => this.debuggerView.activeDebugSession,
|
||||
debugSession => {
|
||||
if (debugSession !== undefined) {
|
||||
this.onChangeEmitter.emit();
|
||||
}
|
||||
}
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
private getVisualizationBackend(
|
||||
debugSession: DebugSessionProxy
|
||||
): VisualizationBackend | undefined {
|
||||
const existing = this.visualizationBackends.get(debugSession);
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
const newBackend = this.visualizationSupport.createBackend(
|
||||
debugSession
|
||||
);
|
||||
|
||||
if (!newBackend) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
newBackend.onChange.sub(() => {
|
||||
this.onChangeEmitter.emit();
|
||||
});
|
||||
|
||||
this.visualizationBackends.set(debugSession, newBackend);
|
||||
|
||||
return newBackend;
|
||||
}
|
||||
|
||||
private get activeVisualizationBackend(): VisualizationBackend | undefined {
|
||||
const activeDebugSession = this.debuggerView.activeDebugSession;
|
||||
if (!activeDebugSession) {
|
||||
return undefined;
|
||||
}
|
||||
const backend = this.getVisualizationBackend(activeDebugSession);
|
||||
return backend;
|
||||
}
|
||||
|
||||
public async getVisualizationData(
|
||||
args: GetVisualizationDataArgs
|
||||
): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
const activeDebugSession = this.debuggerView.activeDebugSession;
|
||||
if (!activeDebugSession) {
|
||||
return {
|
||||
kind: "error",
|
||||
message: "No active debug session.",
|
||||
};
|
||||
}
|
||||
const backend = this.getVisualizationBackend(activeDebugSession);
|
||||
if (!backend) {
|
||||
return {
|
||||
kind: "error",
|
||||
message: `The debug adapter "${activeDebugSession.session.type}" is not supported.`,
|
||||
};
|
||||
}
|
||||
return await backend.getVisualizationData(args);
|
||||
}
|
||||
|
||||
public get expressionLanguageId(): string | undefined {
|
||||
return this.activeVisualizationBackend?.expressionLanguageId;
|
||||
}
|
||||
|
||||
public async getCompletions(
|
||||
text: string,
|
||||
column: number
|
||||
): Promise<CompletionItem[]> {
|
||||
return (
|
||||
(await this.activeVisualizationBackend?.getCompletions(
|
||||
text,
|
||||
column
|
||||
)) || []
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,235 @@
|
||||
import {
|
||||
DataExtractionResult,
|
||||
DataExtractorId,
|
||||
GraphNode,
|
||||
GraphVisualizationData,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
||||
import { DebugSessionProxy } from "../proxies/DebugSessionProxy";
|
||||
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
||||
import { FormattedMessage } from "../webviewContract";
|
||||
import {
|
||||
DebugSessionVisualizationSupport,
|
||||
GetVisualizationDataArgs,
|
||||
VisualizationBackend,
|
||||
VisualizationBackendBase,
|
||||
} from "./VisualizationBackend";
|
||||
import { parseEvaluationResultFromGenericDebugAdapter } from "./parseEvaluationResultFromGenericDebugAdapter";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class GenericVisualizationSupport
|
||||
implements DebugSessionVisualizationSupport {
|
||||
constructor(private readonly debuggerView: DebuggerViewProxy) { }
|
||||
|
||||
createBackend(
|
||||
session: DebugSessionProxy
|
||||
): VisualizationBackend | undefined {
|
||||
return new GenericVisualizationBackend(session, this.debuggerView);
|
||||
}
|
||||
}
|
||||
|
||||
export class GenericVisualizationBackend extends VisualizationBackendBase {
|
||||
public readonly expressionLanguageId = "text";
|
||||
|
||||
constructor(
|
||||
debugSession: DebugSessionProxy,
|
||||
debuggerView: DebuggerViewProxy
|
||||
) {
|
||||
super(debugSession, debuggerView);
|
||||
}
|
||||
|
||||
public async getVisualizationData({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
}: GetVisualizationDataArgs): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
const frameId = this.debuggerView.getActiveStackFrameId(
|
||||
this.debugSession
|
||||
);
|
||||
|
||||
const finalExpression = this.getFinalExpression({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
});
|
||||
let reply: { result: string; variablesReference: number };
|
||||
try {
|
||||
reply = await this.debugSession.evaluate({
|
||||
expression: finalExpression,
|
||||
frameId,
|
||||
context: this.getContext(),
|
||||
});
|
||||
|
||||
const result = parseEvaluationResultFromGenericDebugAdapter(
|
||||
reply.result,
|
||||
{
|
||||
debugAdapterType:
|
||||
this.debugSession.session.configuration.type,
|
||||
}
|
||||
);
|
||||
|
||||
if (result.kind === "data") {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Use structural information about variables
|
||||
// from the evaluation response if present.
|
||||
if (reply.variablesReference) {
|
||||
const graph = await this.constructGraphFromVariablesReference(
|
||||
reply.result,
|
||||
reply.variablesReference
|
||||
);
|
||||
|
||||
return {
|
||||
kind: "data",
|
||||
result: {
|
||||
availableExtractors: [],
|
||||
usedExtractor: {
|
||||
id: "generic" as any,
|
||||
name: "Generic",
|
||||
priority: 1,
|
||||
},
|
||||
data: graph,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
return {
|
||||
kind: "error",
|
||||
message: {
|
||||
kind: "list",
|
||||
items: [
|
||||
"An error occurred while evaluating the expression:",
|
||||
error.message,
|
||||
`Used debug adapter: ${this.debugSession.session.configuration.type}`,
|
||||
{
|
||||
kind: "inlineList",
|
||||
items: [
|
||||
"Evaluated expression is",
|
||||
{ kind: "code", content: finalExpression },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs GraphVisualizationData from a DAP variables
|
||||
* reference by successively querying the debug adapter for
|
||||
* variables. Objects are considered to be equivalent if
|
||||
* they share the same variables reference (this is important
|
||||
* for representing cyclic relationships).
|
||||
*
|
||||
* @param rootLabel - The root object's label
|
||||
* @param rootVariablesReference - The root object's DAP variables reference
|
||||
* @param maxDepth - The maximum depth to search at
|
||||
* @param maxKnownNodes - The maximum number of nodes
|
||||
*/
|
||||
private async constructGraphFromVariablesReference(
|
||||
rootLabel: string,
|
||||
rootVariablesReference: number,
|
||||
maxDepth: number = 30,
|
||||
maxKnownNodes: number = 50
|
||||
): Promise<GraphVisualizationData> {
|
||||
// Perform a breadth-first search on the object to construct the graph
|
||||
|
||||
const graph: GraphVisualizationData = {
|
||||
kind: { graph: true },
|
||||
nodes: [],
|
||||
edges: [],
|
||||
};
|
||||
const knownNodeIds: { [ref: number]: string } = {};
|
||||
const bfsQueue: {
|
||||
source: { id: string; name: string } | undefined;
|
||||
label: string;
|
||||
variablesReference: number;
|
||||
depth: number;
|
||||
}[] = [
|
||||
{
|
||||
source: undefined,
|
||||
label: rootLabel,
|
||||
variablesReference: rootVariablesReference,
|
||||
depth: 0,
|
||||
},
|
||||
];
|
||||
|
||||
let knownCount: number = 0;
|
||||
|
||||
do {
|
||||
const variable = bfsQueue.shift()!;
|
||||
const hasChilds = variable.variablesReference > 0;
|
||||
|
||||
if (variable.depth > maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
let nodeId: string;
|
||||
|
||||
if (!hasChilds || !(variable.variablesReference in knownNodeIds)) {
|
||||
// The variable is a leaf or an unvisited object: create the node.
|
||||
|
||||
const node: GraphNode = {
|
||||
id: hasChilds
|
||||
? `${variable.variablesReference}`
|
||||
: `__${variable.label}@${knownCount}__`,
|
||||
label: variable.label,
|
||||
color: variable.depth == 0 ? "lightblue" : undefined,
|
||||
shape: "box",
|
||||
};
|
||||
|
||||
graph.nodes.push(node);
|
||||
knownCount++;
|
||||
|
||||
if (hasChilds) {
|
||||
knownNodeIds[variable.variablesReference] = node.id;
|
||||
|
||||
for (const child of await this.debugSession.getVariables({
|
||||
variablesReference: variable.variablesReference,
|
||||
})) {
|
||||
bfsQueue.push({
|
||||
source: { id: node.id, name: child.name },
|
||||
label: child.value,
|
||||
variablesReference: child.variablesReference,
|
||||
depth: variable.depth + 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
nodeId = node.id;
|
||||
} else {
|
||||
// The variable is a visited object (e.g. due to a cyclic reference)
|
||||
|
||||
nodeId = knownNodeIds[variable.variablesReference];
|
||||
}
|
||||
|
||||
if (variable.source) {
|
||||
graph.edges.push({
|
||||
from: variable.source.id,
|
||||
to: nodeId,
|
||||
label: variable.source.name,
|
||||
});
|
||||
}
|
||||
} while (bfsQueue.length > 0 && knownCount <= maxKnownNodes);
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
protected getFinalExpression(args: {
|
||||
expression: string;
|
||||
preferredExtractorId: DataExtractorId | undefined;
|
||||
}): string {
|
||||
return args.expression;
|
||||
}
|
||||
|
||||
protected getContext(): "watch" | "repl" {
|
||||
// we will use "repl" as default so that results are not truncated.
|
||||
return "repl";
|
||||
}
|
||||
}
|
||||
411
extension/src/VisualizationBackend/JsVisualizationSupport.ts
Normal file
@@ -0,0 +1,411 @@
|
||||
import {
|
||||
ApiHasNotBeenInitializedCode,
|
||||
CallFrameRequest,
|
||||
CallFramesRequest,
|
||||
DataExtractionResult,
|
||||
DataExtractorId,
|
||||
DataResult,
|
||||
getExpressionForDataExtractorApi,
|
||||
getExpressionToInitializeDataExtractorApi,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { window } from "vscode";
|
||||
import { Config } from "../Config";
|
||||
import { DebugSessionProxy, StackFrame, StackTraceInfo } from "../proxies/DebugSessionProxy";
|
||||
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
||||
import { FileWatcher } from "../webview/WebviewConnection";
|
||||
import { FormattedMessage } from "../webviewContract";
|
||||
import {
|
||||
DebugSessionVisualizationSupport,
|
||||
GetVisualizationDataArgs,
|
||||
VisualizationBackend,
|
||||
VisualizationBackendBase,
|
||||
} from "./VisualizationBackend";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class JsEvaluationEngine implements DebugSessionVisualizationSupport {
|
||||
constructor(private readonly debuggerView: DebuggerViewProxy, private readonly config: Config) {}
|
||||
|
||||
createBackend(session: DebugSessionProxy): VisualizationBackend | undefined {
|
||||
const supportedDebugAdapters = [
|
||||
"node",
|
||||
"node2",
|
||||
"extensionHost",
|
||||
"chrome",
|
||||
"pwa-chrome",
|
||||
"pwa-node",
|
||||
"pwa-extensionHost",
|
||||
"node-terminal",
|
||||
"pwa-msedge",
|
||||
];
|
||||
|
||||
if (supportedDebugAdapters.indexOf(session.session.type) !== -1) {
|
||||
return new JsVisualizationBackend(session, this.debuggerView, this.config);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class CallFrameState {
|
||||
public request: CallFramesRequest | undefined = undefined;
|
||||
}
|
||||
|
||||
class JsVisualizationBackend extends VisualizationBackendBase {
|
||||
public readonly expressionLanguageId = "javascript";
|
||||
private initializePromise: Promise<void> | undefined = undefined;
|
||||
|
||||
constructor(debugSession: DebugSessionProxy, debuggerView: DebuggerViewProxy, private readonly config: Config) {
|
||||
super(debugSession, debuggerView);
|
||||
}
|
||||
|
||||
private getContext(): "copy" | "repl" {
|
||||
if (this.debugSession.session.type.startsWith("pwa-")) {
|
||||
return "copy";
|
||||
}
|
||||
return "repl";
|
||||
}
|
||||
|
||||
public async getVisualizationData(
|
||||
args: GetVisualizationDataArgs
|
||||
): Promise<{ kind: "data"; result: DataExtractionResult } | { kind: "error"; message: FormattedMessage }> {
|
||||
let result = await this.getVisualizationDataIfInitialized(args);
|
||||
|
||||
if (result.kind === "not-initialized") {
|
||||
await this.initializeApiOrWait();
|
||||
result = await this.getVisualizationDataIfInitialized(args);
|
||||
if (result.kind === "not-initialized") {
|
||||
return {
|
||||
kind: "error",
|
||||
message: "Could not initialize API",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async getVisualizationDataIfInitialized(
|
||||
args: GetVisualizationDataArgs
|
||||
): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
| { kind: "not-initialized" }
|
||||
> {
|
||||
const { expression, preferredExtractorId } = args;
|
||||
let callFrameState: CallFrameState;
|
||||
if (args.sessionStore.data instanceof CallFrameState) {
|
||||
callFrameState = args.sessionStore.data;
|
||||
} else {
|
||||
callFrameState = new CallFrameState();
|
||||
args.sessionStore.data = callFrameState;
|
||||
}
|
||||
|
||||
try {
|
||||
const frameId = this.debuggerView.getActiveStackFrameId(this.debugSession);
|
||||
|
||||
const stackTrace = await this.debuggerView.activeDebugSession!.getStackTrace({
|
||||
threadId: 0,
|
||||
levels: 20,
|
||||
});
|
||||
|
||||
const variableNames = await getVariableNames(this.debugSession, frameId);
|
||||
|
||||
let tryCount = 0;
|
||||
while (true) {
|
||||
tryCount++;
|
||||
|
||||
let callFrameDataValue = "null";
|
||||
if (callFrameState.request) {
|
||||
callFrameDataValue = await getCallFramesSnapshotValue(
|
||||
this.debugSession,
|
||||
stackTrace,
|
||||
callFrameState.request
|
||||
);
|
||||
}
|
||||
const result = await this.evaluateVisualizationDataRequest(
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
variableNames,
|
||||
callFrameDataValue,
|
||||
frameId
|
||||
);
|
||||
|
||||
if (result.kind === "NoExtractors") {
|
||||
throw new Error("No extractors");
|
||||
} else if (result.kind === "Error") {
|
||||
throw new Error(result.message + "\n" + (result as any).stack);
|
||||
} else if (result.kind === "Data") {
|
||||
return {
|
||||
kind: "data",
|
||||
result: result.extractionResult,
|
||||
};
|
||||
} else if (result.kind === "OutdatedCallFrameSnapshot") {
|
||||
if (tryCount >= 2) {
|
||||
throw new Error("OutdatedCallFrameSnapshot");
|
||||
}
|
||||
callFrameState.request = result.callFramesRequest;
|
||||
} else {
|
||||
throw new Error("Invalid Data");
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (typeof error.message === "string" && error.message.indexOf(ApiHasNotBeenInitializedCode) !== -1) {
|
||||
return { kind: "not-initialized" };
|
||||
}
|
||||
return {
|
||||
kind: "error",
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private async evaluateVisualizationDataRequest(
|
||||
expression: string,
|
||||
preferredExtractorId: DataExtractorId | undefined,
|
||||
variableNames: string[],
|
||||
callFrameDataValue: string,
|
||||
frameId: number | undefined
|
||||
): Promise<DataResult> {
|
||||
const preferredExtractorExpr = preferredExtractorId ? `"${preferredExtractorId}"` : "undefined";
|
||||
const body = `${getExpressionForDataExtractorApi()}.getData(
|
||||
() => (${expression}),
|
||||
expr => eval(expr),
|
||||
${preferredExtractorExpr},
|
||||
{${variableNames.map((n) => `${n}: () => ${n}`).join(",")}},
|
||||
${callFrameDataValue}
|
||||
)`;
|
||||
|
||||
const wrappedExpr = `(() => {
|
||||
try { return ${body}; }
|
||||
catch (e) { return JSON.stringify({ kind: "Error", message: e.message, stack: e.stack }); }
|
||||
})()
|
||||
`;
|
||||
|
||||
const reply = await this.debugSession.evaluate({
|
||||
expression: wrappedExpr,
|
||||
frameId,
|
||||
context: this.getContext(),
|
||||
});
|
||||
const resultStr = reply.result;
|
||||
const jsonData = this.getContext() === "copy" ? resultStr : resultStr.substr(1, resultStr.length - 2);
|
||||
const result = JSON.parse(jsonData) as DataResult;
|
||||
return result;
|
||||
}
|
||||
|
||||
private initializeApiOrWait(): Promise<void> {
|
||||
if (!this.initializePromise) {
|
||||
this.initializePromise = this.initializeApi().finally(() => (this.initializePromise = undefined));
|
||||
}
|
||||
return this.initializePromise;
|
||||
}
|
||||
|
||||
private async initializeApi(): Promise<void> {
|
||||
// prefer existing is true, so that manually registered (possibly newer) extractors are not overwritten.
|
||||
const expression = `${getExpressionToInitializeDataExtractorApi()}.registerDefaultExtractors(true);`;
|
||||
const frameId = this.debuggerView.getActiveStackFrameId(this.debugSession);
|
||||
const result = await this.debugSession.evaluate({
|
||||
expression,
|
||||
frameId,
|
||||
context: this.getContext(),
|
||||
});
|
||||
|
||||
await this.initializeCustomScripts();
|
||||
}
|
||||
|
||||
private customScripts: undefined | CustomScripts;
|
||||
|
||||
private async initializeCustomScripts(): Promise<void> {
|
||||
this.dispose.untrack(this.customScripts);
|
||||
this.customScripts?.dispose();
|
||||
this.customScripts = this.dispose.track(
|
||||
new CustomScripts(this.debugSession, this.debuggerView, this.config, () => this.onChangeEmitter.emit())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let globalCallFrameId = 0;
|
||||
|
||||
async function getCallFramesSnapshotValue(
|
||||
debugSession: DebugSessionProxy,
|
||||
stackTrace: StackTraceInfo,
|
||||
callFramesRequest: CallFramesRequest
|
||||
): Promise<string> {
|
||||
const globalFnDef = `
|
||||
function getGlobal() {
|
||||
if (typeof globalThis === "object") {
|
||||
return globalThis;
|
||||
} else if (typeof global === "object") {
|
||||
return global;
|
||||
} else if (typeof window === "object") {
|
||||
return window;
|
||||
}
|
||||
throw new Error("No global available");
|
||||
}`;
|
||||
|
||||
const callFrameId = globalCallFrameId++;
|
||||
let idx = 0;
|
||||
let skippedCount = 0;
|
||||
const skippedCounts: Record<number, number> = {};
|
||||
|
||||
let frames = stackTrace.stackFrames;
|
||||
const firstAsyncFrameIdx = frames.findIndex((f) => f.id === 0);
|
||||
if (firstAsyncFrameIdx !== -1) {
|
||||
frames = frames.slice(0, firstAsyncFrameIdx);
|
||||
}
|
||||
|
||||
const result = await Promise.all(
|
||||
frames.map(async (frame) => {
|
||||
function matches(frame: StackFrame, callFrameRequest: CallFrameRequest): boolean {
|
||||
if (frame.name !== callFrameRequest.methodName) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!callFramesRequest.requestedCallFrames.some((r) => matches(frame, r))) {
|
||||
if (skippedCount === 0) {
|
||||
idx++;
|
||||
}
|
||||
skippedCount++;
|
||||
skippedCounts[idx - 1] = skippedCount;
|
||||
return undefined;
|
||||
}
|
||||
skippedCount = 0;
|
||||
const curFrameIdx = idx;
|
||||
idx++;
|
||||
|
||||
const scopes = await debugSession.getScopes({ frameId: frame.id });
|
||||
const scopeVariables = await Promise.all(
|
||||
scopes
|
||||
.filter((s) => !s.expensive && s.name.indexOf(":") !== -1)
|
||||
.map((s) => debugSession.getVariables({ variablesReference: s.variablesReference }))
|
||||
);
|
||||
const variables = new Set(scopeVariables.flatMap((v) => v.map((v) => v.name)));
|
||||
|
||||
await debugSession.evaluate({
|
||||
expression: `
|
||||
(() => {
|
||||
${globalFnDef}
|
||||
const g = getGlobal();
|
||||
(g.$$hedietDbgVslzr${callFrameId} = g.$$hedietDbgVslzr${callFrameId} || [])[${curFrameIdx}] = {
|
||||
vars: { ${[...variables].map((v) => `${v}: ${v}`).join(", ")} },
|
||||
...${JSON.stringify({
|
||||
methodName: frame.name,
|
||||
source: { path: frame.source.path, name: frame.source.name },
|
||||
})}
|
||||
};
|
||||
})();
|
||||
`,
|
||||
frameId: frame.id,
|
||||
context: "repl",
|
||||
});
|
||||
|
||||
return true;
|
||||
})
|
||||
);
|
||||
|
||||
if (!result.some((r) => r)) {
|
||||
return `{ requestId: ${JSON.stringify(callFramesRequest.requestId)}, frames: [] }`;
|
||||
}
|
||||
|
||||
return `
|
||||
(() => {
|
||||
${globalFnDef}
|
||||
const g = getGlobal();
|
||||
const r = g.$$hedietDbgVslzr${callFrameId};
|
||||
delete g.$$hedietDbgVslzr${callFrameId};
|
||||
${Object.entries(skippedCounts)
|
||||
.map(([idx, val]) => `r[${idx}] = { skippedFrames: ${val} };\n`)
|
||||
.join("")}
|
||||
return { requestId: ${JSON.stringify(callFramesRequest.requestId)}, frames: r };
|
||||
})()
|
||||
`;
|
||||
}
|
||||
|
||||
async function getVariableNames(debugSession: DebugSessionProxy, frameId: number | undefined) {
|
||||
const variableNames = new Array<string>();
|
||||
if (frameId) {
|
||||
const scopes = await debugSession.getScopes({ frameId });
|
||||
const scopeVariables = await Promise.all(
|
||||
scopes
|
||||
.filter((s) => !s.expensive && s.name !== "Global")
|
||||
.map((s) =>
|
||||
debugSession.getVariables({
|
||||
variablesReference: s.variablesReference,
|
||||
})
|
||||
)
|
||||
);
|
||||
for (const variables of scopeVariables) {
|
||||
variableNames.push(...variables.filter((v) => v.value !== "undefined").map((v) => v.name));
|
||||
}
|
||||
|
||||
if (variableNames.length > 50) {
|
||||
variableNames.length = 50;
|
||||
}
|
||||
}
|
||||
return variableNames;
|
||||
}
|
||||
|
||||
class CustomScripts {
|
||||
public readonly dispose = Disposable.fn();
|
||||
|
||||
constructor(
|
||||
debugSession: DebugSessionProxy,
|
||||
debuggerView: DebuggerViewProxy,
|
||||
config: Config,
|
||||
changeHandler: () => void
|
||||
) {
|
||||
this.dispose.track(
|
||||
new FileWatcher(
|
||||
() => config.customScriptPaths,
|
||||
async (files) => {
|
||||
for (const file of files) {
|
||||
if (!file.fileExists) {
|
||||
window.showErrorMessage(`The file ${file.path} does not exist.`);
|
||||
continue;
|
||||
}
|
||||
|
||||
let expression = `
|
||||
(
|
||||
runCode => {
|
||||
let fn = undefined;
|
||||
if (runCode) {
|
||||
const module = {};
|
||||
runCode(module);
|
||||
fn = module.exports;
|
||||
}
|
||||
${getExpressionForDataExtractorApi()}.setDataExtractorFn(
|
||||
${JSON.stringify(file.path)},
|
||||
fn
|
||||
);
|
||||
}
|
||||
)
|
||||
(
|
||||
${file.content === undefined ? "undefined" : `function (module) { ${file.content} }`}
|
||||
)`;
|
||||
|
||||
try {
|
||||
await debugSession.evaluate({
|
||||
expression,
|
||||
frameId: debuggerView.getActiveStackFrameId(debugSession),
|
||||
context: "repl",
|
||||
});
|
||||
} catch (e: any) {
|
||||
window.showErrorMessage(
|
||||
'Error while running custom visualization extractor script "' +
|
||||
file.path +
|
||||
'": ' +
|
||||
e.message
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
changeHandler();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
145
extension/src/VisualizationBackend/PyVisualizationSupport.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import {
|
||||
DataExtractionResult,
|
||||
DataExtractorId,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
||||
import { Config } from "../Config";
|
||||
import { DebugSessionProxy } from "../proxies/DebugSessionProxy";
|
||||
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
||||
import { FormattedMessage } from "../webviewContract";
|
||||
import {
|
||||
DebugSessionVisualizationSupport,
|
||||
GetVisualizationDataArgs,
|
||||
VisualizationBackend,
|
||||
VisualizationBackendBase,
|
||||
} from "./VisualizationBackend";
|
||||
import { parseEvaluationResultFromGenericDebugAdapter } from "./parseEvaluationResultFromGenericDebugAdapter";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class PyEvaluationEngine implements DebugSessionVisualizationSupport {
|
||||
constructor(
|
||||
private readonly debuggerView: DebuggerViewProxy,
|
||||
private readonly config: Config
|
||||
) {}
|
||||
|
||||
createBackend(
|
||||
session: DebugSessionProxy
|
||||
): VisualizationBackend | undefined {
|
||||
const supportedDebugAdapters = ["python"];
|
||||
|
||||
if (supportedDebugAdapters.indexOf(session.session.type) !== -1) {
|
||||
return new PyVisualizationBackend(
|
||||
session,
|
||||
this.debuggerView,
|
||||
this.config
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class PyVisualizationBackend extends VisualizationBackendBase {
|
||||
public readonly expressionLanguageId = "python";
|
||||
|
||||
constructor(
|
||||
debugSession: DebugSessionProxy,
|
||||
debuggerView: DebuggerViewProxy,
|
||||
private readonly config: Config
|
||||
) {
|
||||
super(debugSession, debuggerView);
|
||||
}
|
||||
|
||||
protected getContext(): "watch" | "repl" {
|
||||
// we will use "repl" as default so that results are not truncated.
|
||||
return "repl";
|
||||
}
|
||||
|
||||
public async getVisualizationData({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
}: GetVisualizationDataArgs): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
const frameId = this.debuggerView.getActiveStackFrameId(
|
||||
this.debugSession
|
||||
);
|
||||
|
||||
const finalExpression = this.getFinalExpression({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
});
|
||||
let reply: { result: string; variablesReference: number };
|
||||
try {
|
||||
// inject vscodedebugvisualizer for python
|
||||
await this.debugSession.evaluate({
|
||||
expression:
|
||||
"from vscodedebugvisualizer import visualize\ntry:\n import debugvisualizer\nexcept ImportError:\n pass",
|
||||
frameId,
|
||||
context: this.getContext(),
|
||||
});
|
||||
|
||||
reply = await this.debugSession.evaluate({
|
||||
expression: finalExpression,
|
||||
frameId,
|
||||
context: this.getContext(),
|
||||
});
|
||||
|
||||
let result = reply.result;
|
||||
// remove the initial escape by the the debug session e.g. `''{"kind": {"text": true}, "text": "{"asdf1\'"}''`
|
||||
result = result.replace(/\\'/g, "'");
|
||||
result = result.replace(/\\\\/g, "\\");
|
||||
|
||||
return parseEvaluationResultFromGenericDebugAdapter(result, {
|
||||
debugAdapterType: this.debugSession.session.configuration.type,
|
||||
});
|
||||
} catch (error) {
|
||||
let errorTyped = error as Error;
|
||||
if (
|
||||
errorTyped.message.includes(
|
||||
"ModuleNotFoundError: No module named 'vscodedebugvisualizer'"
|
||||
)
|
||||
) {
|
||||
return {
|
||||
kind: "error",
|
||||
message: {
|
||||
kind: "list",
|
||||
items: [
|
||||
"Please make sure vscodedebugvisualizer is installed: `pip install vscodedebugvisualizer`",
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
kind: "error",
|
||||
message: {
|
||||
kind: "list",
|
||||
items: [
|
||||
"An error occurred while evaluating the expression:",
|
||||
errorTyped.message,
|
||||
`Used debug adapter: ${this.debugSession.session.configuration.type}`,
|
||||
{
|
||||
kind: "inlineList",
|
||||
items: [
|
||||
"Evaluated expression is",
|
||||
{ kind: "code", content: finalExpression },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected getFinalExpression(args: {
|
||||
expression: string;
|
||||
preferredExtractorId: DataExtractorId | undefined;
|
||||
}): string {
|
||||
// wrap expression with visualize function
|
||||
let pythonInject = "";
|
||||
pythonInject += "visualize(" + args.expression + ")";
|
||||
return pythonInject;
|
||||
}
|
||||
}
|
||||
157
extension/src/VisualizationBackend/RbVisualizationSupport.ts
Normal file
@@ -0,0 +1,157 @@
|
||||
import {
|
||||
DataExtractionResult,
|
||||
DataResult,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
||||
import { Config } from "../Config";
|
||||
import { DebugSessionProxy } from "../proxies/DebugSessionProxy";
|
||||
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
||||
import { FormattedMessage } from "../webviewContract";
|
||||
import {
|
||||
DebugSessionVisualizationSupport,
|
||||
GetVisualizationDataArgs,
|
||||
VisualizationBackend,
|
||||
VisualizationBackendBase,
|
||||
} from "./VisualizationBackend";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class RbEvaluationEngine implements DebugSessionVisualizationSupport {
|
||||
constructor(
|
||||
private readonly debuggerView: DebuggerViewProxy,
|
||||
private readonly config: Config
|
||||
) {}
|
||||
|
||||
createBackend(
|
||||
session: DebugSessionProxy
|
||||
): VisualizationBackend | undefined {
|
||||
const supportedDebugAdapters = ["rdbg"];
|
||||
|
||||
if (supportedDebugAdapters.indexOf(session.session.type) !== -1) {
|
||||
return new RbVisualizationBackend(
|
||||
session,
|
||||
this.debuggerView,
|
||||
this.config
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class RbVisualizationBackend extends VisualizationBackendBase {
|
||||
public readonly expressionLanguageId = "ruby";
|
||||
constructor(
|
||||
debugSession: DebugSessionProxy,
|
||||
debuggerView: DebuggerViewProxy,
|
||||
private readonly config: Config
|
||||
) {
|
||||
super(debugSession, debuggerView);
|
||||
}
|
||||
|
||||
private readonly defaultContext = "repl";
|
||||
|
||||
public async getVisualizationData(
|
||||
args: GetVisualizationDataArgs
|
||||
): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
const result = await this._getVisualizationData(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
private async _getVisualizationData({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
}: GetVisualizationDataArgs): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
try {
|
||||
if (expression.length === 0) throw new Error("No extractors");
|
||||
|
||||
const frameId = this.debuggerView.getActiveStackFrameId(
|
||||
this.debugSession
|
||||
);
|
||||
const initialReply = await this.debugSession.evaluate({
|
||||
expression: "require 'debugvisualizer'",
|
||||
frameId,
|
||||
context: this.defaultContext,
|
||||
});
|
||||
if (initialReply.result.includes("LoadError")) {
|
||||
return {
|
||||
kind: "error",
|
||||
message: {
|
||||
kind: "list",
|
||||
items: [
|
||||
"LoadError: Failed to load debugvisualizer.",
|
||||
{
|
||||
kind: "inlineList",
|
||||
items: [
|
||||
"Install the gem by executing:",
|
||||
{
|
||||
kind: "code",
|
||||
content: "$ bundle add debugvisualizer",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
kind: "inlineList",
|
||||
items: [
|
||||
"If bundler is not being used, install the gem by executing:",
|
||||
{
|
||||
kind: "code",
|
||||
content:
|
||||
"$ gem install debugvisualizer",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
const preferredId = preferredExtractorId || "";
|
||||
const wrappedExpr = `
|
||||
DebugVisualizer.to_debug_visualizer_protocol_json("${preferredId}", ${expression})
|
||||
`;
|
||||
const reply = await this.debugSession.evaluate({
|
||||
expression: wrappedExpr,
|
||||
frameId,
|
||||
context: this.defaultContext,
|
||||
});
|
||||
|
||||
let dataResult: DataResult;
|
||||
try {
|
||||
// Debuggee converts result to a JSON string twice.
|
||||
dataResult = JSON.parse(JSON.parse(reply.result)) as DataResult;
|
||||
} catch (error: any) {
|
||||
let message = error.message;
|
||||
// The `reply.result` is as follows when error occurs in the evaluation of an expression and parsing will fail.
|
||||
// e.g. "#<ZeroDivisionError: divided by 0>"
|
||||
// In this case, it is more beneficial to display this error message.
|
||||
if (reply.result.includes("Error")) message = reply.result;
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
switch (dataResult.kind) {
|
||||
case "NoExtractors":
|
||||
throw new Error("No extractors");
|
||||
case "Error":
|
||||
throw new Error(dataResult.message);
|
||||
case "Data":
|
||||
return {
|
||||
kind: "data",
|
||||
result: dataResult.extractionResult,
|
||||
};
|
||||
default:
|
||||
throw new Error("Invalid Data");
|
||||
}
|
||||
} catch (error: any) {
|
||||
return {
|
||||
kind: "error",
|
||||
message: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
83
extension/src/VisualizationBackend/VisualizationBackend.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import {
|
||||
DataExtractionResult,
|
||||
DataExtractorId,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { EventEmitter, EventSource } from "@hediet/std/events";
|
||||
import { reaction } from "mobx";
|
||||
import { DebugSessionProxy } from "../proxies/DebugSessionProxy";
|
||||
import { DebuggerViewProxy } from "../proxies/DebuggerViewProxy";
|
||||
import { CompletionItem, FormattedMessage } from "../webviewContract";
|
||||
|
||||
export interface DebugSessionVisualizationSupport {
|
||||
createBackend(session: DebugSessionProxy): VisualizationBackend | undefined;
|
||||
}
|
||||
|
||||
export interface VisualizationBackend extends Disposable {
|
||||
readonly onChange: EventSource;
|
||||
|
||||
getVisualizationData(
|
||||
args: GetVisualizationDataArgs
|
||||
): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
>;
|
||||
|
||||
/**
|
||||
* The language that expressions must be written in.
|
||||
*/
|
||||
readonly expressionLanguageId: string | undefined;
|
||||
|
||||
getCompletions(text: string, column: number): Promise<CompletionItem[]>;
|
||||
}
|
||||
|
||||
export interface GetVisualizationDataArgs {
|
||||
readonly expression: string;
|
||||
readonly preferredExtractorId: DataExtractorId | undefined;
|
||||
|
||||
// Can be used to attach data to the session.
|
||||
readonly sessionStore: { data: unknown };
|
||||
}
|
||||
|
||||
export abstract class VisualizationBackendBase implements VisualizationBackend {
|
||||
public readonly dispose = Disposable.fn();
|
||||
|
||||
protected readonly onChangeEmitter = new EventEmitter();
|
||||
public readonly onChange = this.onChangeEmitter;
|
||||
|
||||
constructor(
|
||||
protected readonly debugSession: DebugSessionProxy,
|
||||
protected readonly debuggerView: DebuggerViewProxy
|
||||
) {
|
||||
this.dispose.track({
|
||||
dispose: reaction(
|
||||
() => debuggerView.getActiveStackFrameId(debugSession),
|
||||
(activeStackFrameId) => {
|
||||
if (activeStackFrameId !== undefined) {
|
||||
this.onChangeEmitter.emit();
|
||||
}
|
||||
}
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
public abstract readonly expressionLanguageId: string | undefined;
|
||||
|
||||
public abstract getVisualizationData(
|
||||
args: GetVisualizationDataArgs
|
||||
): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
>;
|
||||
|
||||
public async getCompletions(
|
||||
text: string,
|
||||
column: number
|
||||
): Promise<CompletionItem[]> {
|
||||
return await this.debugSession.getCompletions({
|
||||
text,
|
||||
frameId: this.debuggerView.getActiveStackFrameId(this.debugSession),
|
||||
column,
|
||||
});
|
||||
}
|
||||
}
|
||||
8
extension/src/VisualizationBackend/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export * from "./VisualizationBackend";
|
||||
|
||||
export { ComposedVisualizationSupport } from "./ComposedVisualizationSupport";
|
||||
export { JsEvaluationEngine } from "./JsVisualizationSupport";
|
||||
export { PyEvaluationEngine } from "./PyVisualizationSupport";
|
||||
export { RbEvaluationEngine } from './RbVisualizationSupport';
|
||||
export { GenericVisualizationSupport } from "./GenericVisualizationSupport";
|
||||
export { ConfigurableVisualizationSupport } from "./ConfigurableVisualizationSupport";
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
DataExtractionResult,
|
||||
isVisualizationData,
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { FormattedMessage } from "../../webviewContract";
|
||||
import { FormattedMessage } from "../webviewContract";
|
||||
|
||||
export interface ParseEvaluationResultContext {
|
||||
debugAdapterType: string;
|
||||
@@ -65,7 +65,7 @@ export function parseEvaluationResultFromGenericDebugAdapter(
|
||||
},
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
return {
|
||||
kind: "error",
|
||||
message: e.message,
|
||||
@@ -93,7 +93,7 @@ function isEnclosedWith(str: string, char: string): boolean {
|
||||
function parseJson(str: string, context: ParseEvaluationResultContext) {
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
throw new FormattedError({
|
||||
kind: "list",
|
||||
items: [
|
||||
@@ -1,11 +1,11 @@
|
||||
import { DataExtractorId } from "@hediet/debug-visualizer-data-extraction";
|
||||
import { DataExtractionState, CompletionItem } from "../webviewContract";
|
||||
import { CompletionItem, DataExtractionState } from "../webviewContract";
|
||||
|
||||
export interface EvaluationWatchService {
|
||||
createEvaluationWatcher(
|
||||
export interface VisualizationWatchModel {
|
||||
createWatch(
|
||||
expression: string,
|
||||
options: EvaluationWatcherOptions
|
||||
): EvaluationWatcher;
|
||||
options: VisualizationWatchOptions
|
||||
): VisualizationWatch;
|
||||
|
||||
getCompletions(text: string, column: number): Promise<CompletionItem[]>;
|
||||
|
||||
@@ -17,17 +17,23 @@ export interface EvaluationWatchService {
|
||||
readonly languageId: string | undefined;
|
||||
}
|
||||
|
||||
export interface EvaluationWatcherOptions {
|
||||
export interface VisualizationWatchOptions {
|
||||
preferredDataExtractor?: DataExtractorId | undefined;
|
||||
sessionState?: unknown;
|
||||
}
|
||||
|
||||
export interface EvaluationWatcher {
|
||||
export interface VisualizationWatch {
|
||||
/** This field is constant. */
|
||||
readonly expression: string;
|
||||
|
||||
/** This field is observable */
|
||||
readonly state: DataExtractionState;
|
||||
|
||||
/** This field is observable */
|
||||
readonly preferredDataExtractor: DataExtractorId | undefined;
|
||||
|
||||
readonly sessionState: unknown;
|
||||
|
||||
setPreferredDataExtractor(id: DataExtractorId | undefined): void;
|
||||
refresh(): void;
|
||||
dispose(): void;
|
||||
@@ -0,0 +1,138 @@
|
||||
import { DataExtractorId } from "@hediet/debug-visualizer-data-extraction";
|
||||
import { hotClass } from "@hediet/node-reload";
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { EventEmitter } from "@hediet/std/events";
|
||||
import { wait } from "@hediet/std/timer";
|
||||
import { action, observable } from "mobx";
|
||||
import { CancellationToken, CancellationTokenSource } from "vscode";
|
||||
import { VisualizationBackend } from "../VisualizationBackend/VisualizationBackend";
|
||||
import { CompletionItem, DataExtractionState } from "../webviewContract";
|
||||
import { VisualizationWatch, VisualizationWatchModel, VisualizationWatchOptions } from "./VisualizationWatchModel";
|
||||
|
||||
@hotClass(module)
|
||||
export class VisualizationWatchModelImpl implements VisualizationWatchModel {
|
||||
public readonly dispose = Disposable.fn();
|
||||
private readonly watchers = new Set<ObservableVisualizationWatch>();
|
||||
|
||||
constructor(private readonly visualizationBackend: VisualizationBackend) {
|
||||
this.dispose.track(
|
||||
visualizationBackend.onChange.sub(() => {
|
||||
if (visualizationBackend.expressionLanguageId !== undefined) {
|
||||
this.lastLanguageId = visualizationBackend.expressionLanguageId;
|
||||
}
|
||||
})
|
||||
);
|
||||
this.lastLanguageId = visualizationBackend.expressionLanguageId;
|
||||
}
|
||||
|
||||
public createWatch(expression: string, options: VisualizationWatchOptions): VisualizationWatch {
|
||||
const w = new ObservableVisualizationWatch(expression, options, this.visualizationBackend);
|
||||
w.onDispose.sub(() => {
|
||||
this.watchers.delete(w);
|
||||
});
|
||||
this.watchers.add(w);
|
||||
return w;
|
||||
}
|
||||
|
||||
@observable
|
||||
private lastLanguageId: string | undefined = undefined;
|
||||
|
||||
get languageId(): string | undefined {
|
||||
return this.lastLanguageId;
|
||||
}
|
||||
|
||||
public getCompletions(text: string, column: number): Promise<CompletionItem[]> {
|
||||
return this.visualizationBackend.getCompletions(text, column);
|
||||
}
|
||||
}
|
||||
|
||||
class ObservableVisualizationWatch implements VisualizationWatch {
|
||||
public readonly dispose = Disposable.fn();
|
||||
private readonly onDisposeEmitter = new EventEmitter();
|
||||
public readonly onDispose = this.onDisposeEmitter.asEvent();
|
||||
|
||||
constructor(
|
||||
public readonly expression: string,
|
||||
options: VisualizationWatchOptions,
|
||||
private readonly visualizationBackend: VisualizationBackend
|
||||
) {
|
||||
this._preferredDataExtractor = options.preferredDataExtractor;
|
||||
|
||||
this.dispose.track(
|
||||
visualizationBackend.onChange.sub(() => {
|
||||
this.refresh();
|
||||
})
|
||||
);
|
||||
|
||||
this.dispose.track({
|
||||
dispose: () => {
|
||||
this.onDisposeEmitter.emit();
|
||||
},
|
||||
});
|
||||
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
private _preferredDataExtractor: DataExtractorId | undefined = undefined;
|
||||
|
||||
public get preferredDataExtractor(): DataExtractorId | undefined {
|
||||
return this._preferredDataExtractor;
|
||||
}
|
||||
|
||||
@action
|
||||
public setPreferredDataExtractor(id: DataExtractorId | undefined): void {
|
||||
this._preferredDataExtractor = id;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
private runningRefreshOperation: Disposable | undefined;
|
||||
|
||||
public refresh(): void {
|
||||
if (this.runningRefreshOperation) {
|
||||
this.runningRefreshOperation.dispose();
|
||||
}
|
||||
const tokenSource = new CancellationTokenSource();
|
||||
this.runningRefreshOperation = {
|
||||
dispose: () => {
|
||||
tokenSource.cancel();
|
||||
},
|
||||
};
|
||||
this._refresh(tokenSource.token);
|
||||
}
|
||||
|
||||
public sessionState: unknown = undefined;
|
||||
|
||||
private async _refresh(token: CancellationToken): Promise<void> {
|
||||
this._state = { kind: "loading" };
|
||||
const that = this;
|
||||
const result = await this.visualizationBackend.getVisualizationData({
|
||||
expression: this.expression,
|
||||
preferredExtractorId: this.preferredDataExtractor,
|
||||
sessionStore: {
|
||||
get data(): unknown {
|
||||
return that.sessionState;
|
||||
},
|
||||
set data(value: unknown) {
|
||||
that.sessionState = value;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (result.kind === "error") {
|
||||
// give cancellation requested more time in case of errors
|
||||
await wait(330);
|
||||
}
|
||||
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._state = result;
|
||||
}
|
||||
|
||||
@observable
|
||||
public _state: DataExtractionState = { kind: "loading" };
|
||||
public get state(): DataExtractionState {
|
||||
return this._state;
|
||||
}
|
||||
}
|
||||
2
extension/src/VisualizationWatchModel/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./VisualizationWatchModelImpl";
|
||||
export * from "./VisualizationWatchModel";
|
||||
@@ -1,48 +0,0 @@
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { debug, DebugSession } from "vscode";
|
||||
import { observable, action } from "mobx";
|
||||
import { VsCodeDebugger } from "./VsCodeDebugger";
|
||||
import { EnhancedDebugSession } from "./EnhancedDebugSession";
|
||||
|
||||
/**
|
||||
* Tracks the currently active debug session and its currently active stack frame.
|
||||
* This is currently all faked. A proper API would be nice.
|
||||
*/
|
||||
export class VsCodeDebuggerView {
|
||||
public readonly dispose = Disposable.fn();
|
||||
|
||||
@observable private _activeDebugSession: EnhancedDebugSession | undefined;
|
||||
|
||||
public get activeDebugSession(): EnhancedDebugSession | undefined {
|
||||
return this._activeDebugSession;
|
||||
}
|
||||
|
||||
public get activeFrameId(): number | undefined {
|
||||
if (!this._activeDebugSession) {
|
||||
return undefined;
|
||||
} else {
|
||||
return this._activeDebugSession["activeStackFrame"];
|
||||
}
|
||||
}
|
||||
|
||||
constructor(private vsCodeDebugger: VsCodeDebugger) {
|
||||
this.dispose.track(
|
||||
debug.onDidChangeActiveDebugSession(activeSession => {
|
||||
this.updateActiveDebugSession(activeSession);
|
||||
})
|
||||
);
|
||||
this.updateActiveDebugSession(debug.activeDebugSession);
|
||||
}
|
||||
|
||||
@action
|
||||
private updateActiveDebugSession(activeSession: DebugSession | undefined) {
|
||||
if (!activeSession) {
|
||||
this._activeDebugSession = undefined;
|
||||
} else {
|
||||
const s = this.vsCodeDebugger.getEnhancedDebugSession(
|
||||
activeSession
|
||||
);
|
||||
this._activeDebugSession = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,18 @@ registerUpdateReconciler(module);
|
||||
import { InternalWebviewManager } from "./webview/InternalWebviewManager";
|
||||
import { WebviewServer } from "./webview/WebviewServer";
|
||||
import { Config } from "./Config";
|
||||
import { VsCodeDebugger } from "./debugger/VsCodeDebugger";
|
||||
import { VsCodeDebuggerView } from "./debugger/VsCodeDebuggerView";
|
||||
import { EvaluationWatchServiceImpl } from "./EvaluationWatchService";
|
||||
import { DebuggerProxy } from "./proxies/DebuggerProxy";
|
||||
import { DebuggerViewProxy } from "./proxies/DebuggerViewProxy";
|
||||
import { VisualizationWatchModelImpl } from "./VisualizationWatchModel";
|
||||
import {
|
||||
ComposedEvaluationEngine,
|
||||
ComposedVisualizationSupport,
|
||||
JsEvaluationEngine,
|
||||
GenericEvaluationEngine,
|
||||
ConfiguredEvaluationEngine,
|
||||
} from "./EvaluationWatchService/EvaluationEngine";
|
||||
PyEvaluationEngine,
|
||||
RbEvaluationEngine,
|
||||
GenericVisualizationSupport,
|
||||
ConfigurableVisualizationSupport,
|
||||
} from "./VisualizationBackend";
|
||||
import { DispatchingVisualizationBackend } from "./VisualizationBackend/DispatchingVisualizationBackend";
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
context.subscriptions.push(
|
||||
@@ -31,24 +34,31 @@ export function activate(context: ExtensionContext) {
|
||||
);
|
||||
}
|
||||
|
||||
export function deactivate() {}
|
||||
export function deactivate() { }
|
||||
|
||||
export class Extension {
|
||||
public readonly dispose = Disposable.fn();
|
||||
|
||||
private readonly config = new Config();
|
||||
private readonly debugger = this.dispose.track(new VsCodeDebugger());
|
||||
private readonly debugger = this.dispose.track(new DebuggerProxy());
|
||||
private readonly debuggerView = this.dispose.track(
|
||||
new VsCodeDebuggerView(this.debugger)
|
||||
new DebuggerViewProxy(this.debugger)
|
||||
);
|
||||
|
||||
public readonly dataSource = new EvaluationWatchServiceImpl(
|
||||
this.debuggerView,
|
||||
new ComposedEvaluationEngine([
|
||||
new ConfiguredEvaluationEngine(this.config),
|
||||
new JsEvaluationEngine(),
|
||||
new GenericEvaluationEngine(),
|
||||
])
|
||||
public readonly dataSource = new VisualizationWatchModelImpl(
|
||||
new DispatchingVisualizationBackend(
|
||||
new ComposedVisualizationSupport([
|
||||
new ConfigurableVisualizationSupport(
|
||||
this.config,
|
||||
this.debuggerView
|
||||
),
|
||||
new JsEvaluationEngine(this.debuggerView, this.config),
|
||||
new PyEvaluationEngine(this.debuggerView, this.config),
|
||||
new RbEvaluationEngine(this.debuggerView, this.config),
|
||||
new GenericVisualizationSupport(this.debuggerView),
|
||||
]),
|
||||
this.debuggerView
|
||||
)
|
||||
);
|
||||
|
||||
private readonly server = new WebviewServer(this.dataSource, this.config);
|
||||
@@ -82,7 +92,26 @@ export class Extension {
|
||||
}
|
||||
|
||||
const selection = editor.selection;
|
||||
const selectedText = editor.document.getText(selection);
|
||||
|
||||
let selectedText;
|
||||
if (selection.isEmpty) {
|
||||
const lineText = editor.document.lineAt(selection.start)
|
||||
.text;
|
||||
const regexp = /`(.*)`/g;
|
||||
selectedText = "";
|
||||
let match;
|
||||
while ((match = regexp.exec(lineText))) {
|
||||
if (
|
||||
match.index <= selection.start.character &&
|
||||
selection.start.character <=
|
||||
match.index + match[0].length
|
||||
) {
|
||||
selectedText = match[1];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedText = editor.document.getText(selection);
|
||||
}
|
||||
|
||||
if (!selectedText) {
|
||||
return;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { observable } from "mobx";
|
||||
import { DebugSession } from "vscode";
|
||||
import { CompletionItem } from "../webviewContract";
|
||||
import { observable } from "mobx";
|
||||
|
||||
export class EnhancedDebugSession {
|
||||
@observable protected activeStackFrame: number | undefined;
|
||||
export class DebugSessionProxy {
|
||||
@observable private _activeStackFrameId: number | undefined;
|
||||
|
||||
constructor(public readonly session: DebugSession) {}
|
||||
|
||||
protected async getStackTrace(args: {
|
||||
public async getStackTrace(args: {
|
||||
threadId: number;
|
||||
startFrame?: number;
|
||||
levels?: number;
|
||||
}): Promise<{ totalFrames?: number; stackFrames: StackFrame[] }> {
|
||||
}): Promise<StackTraceInfo> {
|
||||
try {
|
||||
const reply = (await this.session.customRequest("stackTrace", {
|
||||
threadId: args.threadId,
|
||||
@@ -46,6 +46,36 @@ export class EnhancedDebugSession {
|
||||
}
|
||||
}
|
||||
|
||||
public async getScopes(args: { frameId: number }): Promise<Scope[]> {
|
||||
try {
|
||||
const reply = await this.session.customRequest("scopes", {
|
||||
frameId: args.frameId,
|
||||
});
|
||||
if (!reply) {
|
||||
return [];
|
||||
}
|
||||
return reply.scopes;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public async getVariables(args: { variablesReference: number }): Promise<Variable[]> {
|
||||
try {
|
||||
const reply = await this.session.customRequest("variables", {
|
||||
variablesReference: args.variablesReference,
|
||||
});
|
||||
if (!reply) {
|
||||
return [];
|
||||
}
|
||||
return reply.variables;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the given expression.
|
||||
* If context is "watch", long results are usually shortened.
|
||||
@@ -55,16 +85,38 @@ export class EnhancedDebugSession {
|
||||
expression: string;
|
||||
frameId: number | undefined;
|
||||
context: "watch" | "repl" | "copy";
|
||||
}): Promise<{ result: string }> {
|
||||
}): Promise<{ result: string; variablesReference: number }> {
|
||||
const reply = await this.session.customRequest("evaluate", {
|
||||
expression: args.expression,
|
||||
frameId: args.frameId,
|
||||
context: args.context,
|
||||
});
|
||||
return { result: reply.result };
|
||||
return {
|
||||
result: reply.result,
|
||||
variablesReference: reply.variablesReference,
|
||||
};
|
||||
}
|
||||
}
|
||||
interface StackFrame {
|
||||
|
||||
export interface StackTraceInfo {
|
||||
totalFrames?: number;
|
||||
stackFrames: StackFrame[];
|
||||
}
|
||||
|
||||
interface Scope {
|
||||
name: string;
|
||||
expensive: boolean;
|
||||
variablesReference: number;
|
||||
}
|
||||
|
||||
interface Variable {
|
||||
name: string;
|
||||
value: string;
|
||||
variablesReference: number;
|
||||
}
|
||||
|
||||
export interface StackFrame {
|
||||
id: number;
|
||||
name: string;
|
||||
source: { name: string; path: string };
|
||||
}
|
||||
@@ -1,27 +1,25 @@
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { debug, DebugSession } from "vscode";
|
||||
import { EventEmitter } from "@hediet/std/events";
|
||||
import { runInAction } from "mobx";
|
||||
import { EnhancedDebugSession } from "./EnhancedDebugSession";
|
||||
import { debug, DebugSession } from "vscode";
|
||||
import { DebugSessionProxy } from "./DebugSessionProxy";
|
||||
|
||||
/**
|
||||
* Decorates DebugSession instances and emits an event for new debug sessions.
|
||||
*/
|
||||
export class VsCodeDebugger {
|
||||
export class DebuggerProxy {
|
||||
public readonly dispose = Disposable.fn();
|
||||
private readonly sessions = new Map<DebugSession, EnhancedDebugSession>();
|
||||
private readonly sessions = new Map<DebugSession, DebugSessionProxy>();
|
||||
|
||||
private readonly _onDidStartDebugSession = new EventEmitter<{
|
||||
session: EnhancedDebugSession;
|
||||
session: DebugSessionProxy;
|
||||
}>();
|
||||
public readonly onDidStartDebugSession = this._onDidStartDebugSession.asEvent();
|
||||
public readonly onDidStartDebugSession =
|
||||
this._onDidStartDebugSession.asEvent();
|
||||
|
||||
public getEnhancedDebugSession(
|
||||
session: DebugSession
|
||||
): EnhancedDebugSession {
|
||||
public getDebugSessionProxy(session: DebugSession): DebugSessionProxy {
|
||||
let result = this.sessions.get(session);
|
||||
if (!result) {
|
||||
result = new EnhancedDebugSession(session);
|
||||
result = new DebugSessionProxy(session);
|
||||
this.sessions.set(session, result);
|
||||
}
|
||||
return result;
|
||||
@@ -29,20 +27,18 @@ export class VsCodeDebugger {
|
||||
|
||||
constructor() {
|
||||
this.dispose.track([
|
||||
debug.onDidStartDebugSession(session => {
|
||||
debug.onDidStartDebugSession((session) => {
|
||||
const e = this.sessions.get(session)!;
|
||||
this._onDidStartDebugSession.emit({ session: e });
|
||||
}),
|
||||
debug.onDidTerminateDebugSession(session => {
|
||||
debug.onDidTerminateDebugSession((session) => {
|
||||
this.sessions.delete(session);
|
||||
}),
|
||||
debug.registerDebugAdapterTrackerFactory("*", {
|
||||
createDebugAdapterTracker: session => {
|
||||
const extendedSession = this.getEnhancedDebugSession(
|
||||
session
|
||||
);
|
||||
createDebugAdapterTracker: (session) => {
|
||||
const extendedSession = this.getDebugSessionProxy(session);
|
||||
return {
|
||||
onDidSendMessage: async msg => {
|
||||
onDidSendMessage: async (msg) => {
|
||||
type Message =
|
||||
| StoppedEvent
|
||||
| ThreadsResponse
|
||||
@@ -83,14 +79,13 @@ export class VsCodeDebugger {
|
||||
if (m.type === "event") {
|
||||
if (m.event === "stopped") {
|
||||
const threadId = m.body.threadId;
|
||||
const r = await extendedSession[
|
||||
"getStackTrace"
|
||||
]({
|
||||
threadId,
|
||||
startFrame: 0,
|
||||
levels: 1,
|
||||
});
|
||||
extendedSession["activeStackFrame"] =
|
||||
const r =
|
||||
await extendedSession.getStackTrace({
|
||||
threadId,
|
||||
startFrame: 0,
|
||||
levels: 1,
|
||||
});
|
||||
extendedSession["_activeStackFrameId"] =
|
||||
r.stackFrames.length > 0
|
||||
? r.stackFrames[0].id
|
||||
: undefined;
|
||||
@@ -102,9 +97,8 @@ export class VsCodeDebugger {
|
||||
m.command === "stepIn" ||
|
||||
m.command === "stepOut"
|
||||
) {
|
||||
extendedSession[
|
||||
"activeStackFrame"
|
||||
] = undefined;
|
||||
extendedSession["_activeStackFrameId"] =
|
||||
undefined;
|
||||
}
|
||||
}
|
||||
},
|
||||
58
extension/src/proxies/DebuggerViewProxy.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { CancellationToken, debug, DebugSession, InlineValue, InlineValueContext, InlineValuesProvider, languages, ProviderResult, Range, TextDocument } from "vscode";
|
||||
import { observable, action } from "mobx";
|
||||
import { DebuggerProxy } from "./DebuggerProxy";
|
||||
import { DebugSessionProxy } from "./DebugSessionProxy";
|
||||
|
||||
/**
|
||||
* Tracks the currently active debug session and its currently active stack frame.
|
||||
* This is currently all faked. A proper API would be nice.
|
||||
*/
|
||||
export class DebuggerViewProxy {
|
||||
public readonly dispose = Disposable.fn();
|
||||
|
||||
@observable private _activeDebugSession: DebugSessionProxy | undefined;
|
||||
|
||||
public get activeDebugSession(): DebugSessionProxy | undefined {
|
||||
return this._activeDebugSession;
|
||||
}
|
||||
|
||||
public getActiveStackFrameId(
|
||||
session: DebugSessionProxy
|
||||
): number | undefined {
|
||||
return session["_activeStackFrameId"];
|
||||
}
|
||||
|
||||
constructor(private debuggerProxy: DebuggerProxy) {
|
||||
this.dispose.track(
|
||||
debug.onDidChangeActiveDebugSession(activeSession => {
|
||||
this.updateActiveDebugSession(activeSession);
|
||||
})
|
||||
);
|
||||
this.updateActiveDebugSession(debug.activeDebugSession);
|
||||
|
||||
this.dispose.track(languages.registerInlineValuesProvider('*', new FrameIdGetter(this)));
|
||||
}
|
||||
|
||||
@action
|
||||
private updateActiveDebugSession(activeSession: DebugSession | undefined) {
|
||||
this._activeDebugSession = activeSession
|
||||
? this.debuggerProxy.getDebugSessionProxy(activeSession)
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class FrameIdGetter implements InlineValuesProvider {
|
||||
constructor(
|
||||
private readonly debuggerViewProxy: DebuggerViewProxy,
|
||||
) {
|
||||
}
|
||||
|
||||
provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext, token: CancellationToken): ProviderResult<InlineValue[]> {
|
||||
const a = this.debuggerViewProxy.activeDebugSession;
|
||||
if (a) {
|
||||
a['_activeStackFrameId'] = context.frameId;
|
||||
}
|
||||
return []
|
||||
}
|
||||
}
|
||||