This commit is contained in:
Henning Dieterichs
2020-02-10 12:13:07 +01:00
parent 51957d52eb
commit 8aae7f7b0d
45 changed files with 625 additions and 413 deletions

View File

@@ -3,22 +3,5 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Index",
"program": "${workspaceFolder}\\dist\\index.js",
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "npm: dev"
},
{
"type": "node",
"request": "launch",
"name": "Launch Double Linked List Demo",
"program": "${workspaceFolder}\\dist\\DoubleLinkedList.js",
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "npm: dev"
}
]
"configurations": []
}

4
example-project/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"debugVisualizer.useChromeKioskMode": false,
"editor.minimap.enabled": false
}

View File

@@ -1,72 +0,0 @@
import {
enableHotReload,
registerUpdateReconciler,
getReloadCount,
hotClass,
} from "@hediet/node-reload";
enableHotReload();
registerUpdateReconciler(module);
import {
registerAll,
CommonDataTypes,
getClosureObj,
} from "@hediet/debug-visualizer-data-extraction";
registerAll();
setTimeout(() => {
new Main().run();
}, 0);
@hotClass(module)
class Main {
run() {
let myValue: DoubleLinkedList | undefined = new DoubleLinkedList("1");
const first = myValue;
myValue.setNext(new DoubleLinkedList("2"));
myValue.next!.setNext(new DoubleLinkedList("3"));
myValue.next!.next!.setNext(new DoubleLinkedList("4"));
const dbgLast = myValue.next!.next!.next!;
let last: DoubleLinkedList | undefined = undefined;
while (myValue) {
myValue.prev = myValue.next;
myValue.next = last;
last = myValue;
myValue = myValue.prev;
}
myValue = first;
}
getDebugVisualization(
items: Record<string, DoubleLinkedList | undefined>
): CommonDataTypes.GraphData {
return getClosureObj(
items,
r =>
[
{ item: r.next!, edgeLabel: "next" },
{ item: r.prev!, edgeLabel: "prev" },
].filter(r => !!r.item),
item => item.name,
item => item.id
);
}
}
let id = 0;
class DoubleLinkedList {
public readonly id = (id++).toString();
constructor(public name: string) {}
next: DoubleLinkedList | undefined;
prev: DoubleLinkedList | undefined;
public setNext(val: DoubleLinkedList): void {
val.prev = this;
this.next = val;
}
}

View File

@@ -0,0 +1,59 @@
import {
registerAll,
CommonDataTypes,
createGraphFromPointers,
} from "@hediet/debug-visualizer-data-extraction";
registerAll();
setTimeout(() => {
new Main().run();
}, 0);
class Main {
run() {
const list = new DoublyLinkedList("1");
list.setNext(new DoublyLinkedList("2"));
list.next!.setNext(new DoublyLinkedList("3"));
list.next!.next!.setNext(new DoublyLinkedList("4"));
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;
}
console.log("finished");
}
}
let id = 0;
class DoublyLinkedList {
public readonly id = (id++).toString();
constructor(public name: string) {}
next: DoublyLinkedList | undefined;
prev: DoublyLinkedList | undefined;
public setNext(val: DoublyLinkedList): void {
val.prev = this;
this.next = val;
}
}

View File

@@ -1,24 +1,13 @@
import * as ts from "typescript";
import {
enableHotReload,
registerUpdateReconciler,
getReloadCount,
hotClass,
} from "@hediet/node-reload";
enableHotReload();
import {
registerAll,
CommonDataTypes,
getClosure,
} from "@hediet/debug-visualizer-data-extraction";
import { registerAll } from "@hediet/debug-visualizer-data-extraction";
import { MockLanguageServiceHost } from "./MockLanguageServiceHost";
registerAll();
registerUpdateReconciler(module);
setTimeout(() => {
new Main().run();
}, 0);
@hotClass(module)
class Main {
run() {
const mainFile = {
@@ -49,10 +38,12 @@ class Test1 {
const c = prog.getTypeChecker();
let myValue = undefined;
const sf = prog.getSourceFiles()[0];
myValue = sf.getText();
const sourceFileAst = prog.getSourceFiles()[0];
myValue = sourceFileAst.getText();
console.log("myValue is the source code of the AST");
myValue = {
sf,
sf: sourceFileAst,
fn: (n: ts.Node) => {
try {
const t = c.getTypeAtLocation(n);
@@ -62,8 +53,10 @@ class Test1 {
}
},
};
console.log("myValue is AST, annotated with type information");
myValue = {
sf,
sf: sourceFileAst,
fn: (n: ts.Node) => {
try {
const t = c.getSymbolAtLocation(n);
@@ -73,12 +66,16 @@ class Test1 {
}
},
};
console.log("myValue is AST, annotated with symbol information");
for (const ident of identifiers) {
const s = c.getSymbolAtLocation(ident);
myValue = ident;
console.log("myValue is an identifier");
}
}
}
/*
myValue = {
kind: { text: true, svg: true },
text: `
@@ -89,10 +86,4 @@ class Test1 {
/>
</svg>
`,
};
}
}
if (getReloadCount(module) === 0) {
new Main().run();
}
};*/