Skip to content

Commit dc9b07a

Browse files
committed
v2.0.6
1 parent 2b6dbf5 commit dc9b07a

File tree

10 files changed

+93
-34
lines changed

10 files changed

+93
-34
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"runtimeExecutable": "${execPath}",
4848
"args": [
4949
"--extensionDevelopmentPath=${workspaceFolder}/extension",
50-
"${workspaceFolder}/demos/python"
50+
"${workspaceFolder}/demos/js"
5151
],
5252
"env": {
5353
"HOT_RELOAD": "",

data-extraction/src/js/api/default-extractors/GridExtractor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class GridExtractor implements DataExtractor {
2424
extractData: () =>
2525
expect<GridVisualizationData>({
2626
kind: { grid: true },
27-
rows: [{ columns: data.map(d => ({ tag: d })) }],
27+
rows: [{ columns: data.map(d => ({ tag: "" + d })) }],
2828
}),
2929
});
3030
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { isAssertionExpression } from "typescript";
2+
import { DataExtractor, ExtractionCollector, DataExtractorContext } from "..";
3+
import { TableVisualizationData } from "../../../CommonDataTypes";
4+
import { expect } from "../../../util";
5+
6+
function assert<T>(value: unknown): asserts value {}
7+
8+
export class TableDataExtractor implements DataExtractor {
9+
readonly id = "table";
10+
11+
getExtractions(
12+
data: unknown,
13+
collector: ExtractionCollector,
14+
context: DataExtractorContext
15+
): void {
16+
if (!Array.isArray(data)) {
17+
return;
18+
}
19+
if (!data.every(d => typeof d === "object" && d)) {
20+
return;
21+
}
22+
assert<object[]>(data);
23+
24+
collector.addExtraction({
25+
id: "table",
26+
name: "Table",
27+
priority: 1000,
28+
extractData() {
29+
return expect<TableVisualizationData>({
30+
kind: {
31+
table: true,
32+
},
33+
rows: data,
34+
});
35+
},
36+
});
37+
}
38+
}

data-extraction/src/js/api/default-extractors/TypeScriptDataExtractors.ts

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export class TypeScriptAstDataExtractor implements DataExtractor {
107107
root: helper.toTreeNode(
108108
rootNode || finalRootSourceFile,
109109
"root",
110+
"",
110111
marked,
111112
fn
112113
),
@@ -121,19 +122,24 @@ export class TypeScriptAstDataExtractor implements DataExtractor {
121122
class Helper {
122123
constructor(private readonly tsApi: typeof ts) {}
123124

124-
findKey(value: any, object: any): string | null {
125-
for (var key in object) {
126-
if (key.startsWith("_")) continue;
125+
getPropertyNameInParent(value: any, parent: any): string | undefined {
126+
for (const propertyName in parent) {
127+
if (propertyName.startsWith("_")) continue;
127128

128-
var member = object[key];
129-
if (member === value) return key;
129+
const member = parent[propertyName];
130+
if (member === value) {
131+
return propertyName;
132+
}
130133

131-
if (Array.isArray(member) && member.indexOf(value) !== -1) {
132-
return key;
134+
if (Array.isArray(member)) {
135+
const index = member.indexOf(value);
136+
if (index !== -1) {
137+
return `${propertyName}[${index}]`;
138+
}
133139
}
134140
}
135141

136-
return null;
142+
return undefined;
137143
}
138144

139145
getChildren(node: ts.Node): ts.Node[] {
@@ -147,30 +153,38 @@ class Helper {
147153
toTreeNode(
148154
node: ts.Node,
149155
memberName: string,
156+
segmentName: string,
150157
marked: Set<ts.Node>,
151158
emphasizedValueFn: (node: ts.Node) => string | undefined
152159
): AstTreeNode {
153160
const name = this.tsApi.SyntaxKind[node.kind];
154161
const children = this.getChildren(node)
155162
.map((childNode, idx) => {
156-
let parentPropertyName = this.findKey(childNode, node) || "";
163+
let parentPropertyName =
164+
this.getPropertyNameInParent(childNode, node) || "";
165+
157166
if (childNode.kind == this.tsApi.SyntaxKind.SyntaxList) {
158167
const children = this.getChildren(childNode);
159-
children.some(c => {
160-
parentPropertyName = this.findKey(c, node) || "";
161-
return !!parentPropertyName;
162-
});
163-
164-
if (children.length === 0) return null!;
168+
for (const c of children) {
169+
const name =
170+
this.getPropertyNameInParent(c, node) || "";
171+
if (name) {
172+
parentPropertyName = name;
173+
break;
174+
}
175+
}
165176
}
166177

178+
let segmentName = "." + parentPropertyName;
167179
if (node.kind == this.tsApi.SyntaxKind.SyntaxList) {
168180
parentPropertyName = "" + idx;
181+
segmentName = `[${idx}]`;
169182
}
170183

171184
return this.toTreeNode(
172185
childNode,
173186
parentPropertyName,
187+
segmentName,
174188
marked,
175189
emphasizedValueFn
176190
);
@@ -201,6 +215,7 @@ class Helper {
201215
return {
202216
items,
203217
children: children,
218+
segment: segmentName,
204219
span: {
205220
length: node.end - node.pos,
206221
start: node.pos,

data-extraction/src/js/api/default-extractors/registerDefaultDataExtractors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { PlotlyDataExtractor } from "./PlotlyDataExtractor";
77
import { ObjectGraphExtractor } from "./ObjectGraphExtractor";
88
import { getDataExtractorApi } from "../injection";
99
import { GridExtractor } from "./GridExtractor";
10+
import { TableDataExtractor } from "./TableExtractor";
1011

1112
/**
1213
* The default data extractors should be registered by VS Code automatically.
@@ -23,6 +24,7 @@ export function registerDefaultExtractors(
2324
new PlotlyDataExtractor(),
2425
new ObjectGraphExtractor(),
2526
new GridExtractor(),
27+
new TableDataExtractor(),
2628
]) {
2729
api.registerExtractor(item);
2830
}

demos/js/src/demo_typescript-asts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Main {
1818
class Test1 {
1919
public foo(a: number) {
2020
const x = { a: 5 };
21+
const y = { a: 5 };
2122
}
2223
}
2324
`,

extension/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## 2.0.6
4+
5+
- Fixes grid extractor bug
6+
- Fixes Perspective.js bug
7+
- Fixes AST visualizer bug
8+
- Adds table data extractor
9+
- Improves typescript data extractor
10+
311
## 2.0.0
412

513
- Support for the new JS debug adapters

extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"displayName": "Debug Visualizer",
55
"description": "A visual watch window that lets you visualize your data structures while debugging.",
66
"icon": "docs/logo.drawio.png",
7-
"version": "2.0.4",
7+
"version": "2.0.6",
88
"license": "GPL-3.0",
99
"engines": {
1010
"vscode": "^1.46.0"

webview/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"react-dom": "^16.12.0",
2121
"react-measure": "^2.3.0",
2222
"@hediet/debug-visualizer-data-extraction": "*",
23-
"@hediet/visualization-bundle": "^0.1.4",
24-
"@hediet/visualization-core": "^0.1.0",
23+
"@hediet/visualization-bundle": "^0.1.6",
24+
"@hediet/visualization-core": "^0.1.1",
2525
"@knuddels/mobx-logger": "^1.1.1",
2626
"less-loader": "^6.2.0"
2727
},

yarn.lock

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,6 @@
507507
stack-trace "^0.0.10"
508508
ws "^7.0.0"
509509

510-
"@hediet/semantic-json@^0.3.11":
511-
version "0.3.11"
512-
resolved "https://registry.yarnpkg.com/@hediet/semantic-json/-/semantic-json-0.3.11.tgz#9420a89d30645ba333dfd4f3f2c120f973297ee2"
513-
integrity sha512-KKw6ZcYHiyfhanNmln/WlG4KvZnMi/Ojy8O6HB6sqfDC5XCcNYjccUMMtaX23F/Hox0dWJPFqXYs54KJAA5itg==
514-
515510
"@hediet/semantic-json@^0.3.14":
516511
version "0.3.14"
517512
resolved "https://registry.yarnpkg.com/@hediet/semantic-json/-/semantic-json-0.3.14.tgz#876bd5c4b646c134641ad17e9ef352595fb163e7"
@@ -555,10 +550,10 @@
555550
"@hediet/std" "^0.6.0"
556551
io-ts "^1.8.6"
557552

558-
"@hediet/visualization-bundle@^0.1.4":
559-
version "0.1.4"
560-
resolved "https://registry.yarnpkg.com/@hediet/visualization-bundle/-/visualization-bundle-0.1.4.tgz#ddaba4818501b8ca6a0cdd355afeb02bfb4dc731"
561-
integrity sha512-FPR9zhyEDlYMk9vscWgEe9B2NQzvFxjc85tjDUR9GZbr42RtLTMd0Xyf0AlSl+plV98mD1XERWowagHqleU7Xg==
553+
"@hediet/visualization-bundle@^0.1.6":
554+
version "0.1.6"
555+
resolved "https://registry.yarnpkg.com/@hediet/visualization-bundle/-/visualization-bundle-0.1.6.tgz#a8ab11be910a30d0d26a88044caf11cab4a60f98"
556+
integrity sha512-IQZDORYlRTojBwJUIADpg4NRxCqK6Q+bl1H2IP7Bq28wdwsRtuERB2UcGPufn00NGhJbOw6FAH2e1zwsQAkboQ==
562557
dependencies:
563558
"@finos/perspective-viewer" "^0.5.2"
564559
"@finos/perspective-viewer-d3fc" "^0.5.2"
@@ -581,12 +576,12 @@
581576
vis-network "^8.0.0"
582577
viz.js "^2.1.2"
583578

584-
"@hediet/visualization-core@^0.1.0":
585-
version "0.1.0"
586-
resolved "https://registry.yarnpkg.com/@hediet/visualization-core/-/visualization-core-0.1.0.tgz#f23706cbc6a9ffd411c300767077ca4c0c494c15"
587-
integrity sha512-v7aZnyJ0ax09x6mBqhVaJQVwos1X7nyEfymr85/wbvLuleDjisKUuLHBxGpmWYSBRFMZUKIHllaY48DEHjP8Ug==
579+
"@hediet/visualization-core@^0.1.1":
580+
version "0.1.1"
581+
resolved "https://registry.yarnpkg.com/@hediet/visualization-core/-/visualization-core-0.1.1.tgz#240b96ac48e24b7ae81f2b0360cebd57091eb600"
582+
integrity sha512-2WNP75TZg87bejt5XB+11jzbAoJ5EGbVrW+srSHRjUSdezZQ53x16E4XVV/q9W6HD6okTuz7wGjDrapNzK1EMw==
588583
dependencies:
589-
"@hediet/semantic-json" "^0.3.11"
584+
"@hediet/semantic-json" "^0.3.14"
590585
"@hediet/std" "^0.6.0"
591586
react "^16.12.0"
592587
react-dom "^16.12.0"

0 commit comments

Comments
 (0)