More progress.
This commit is contained in:
@@ -40,6 +40,7 @@ export module CommonDataTypes {
|
||||
export interface TreeNode<TExtraData> {
|
||||
id: string | undefined;
|
||||
name: string;
|
||||
value: string | undefined;
|
||||
children: TreeNode<TExtraData>[];
|
||||
data: TExtraData;
|
||||
isMarked: boolean;
|
||||
|
||||
@@ -3,8 +3,9 @@ import { ExtractedData } from "../DataExtractionResult";
|
||||
export interface DataExtractor<T extends ExtractedData> {
|
||||
id: string;
|
||||
getExtractions(
|
||||
data: any,
|
||||
extractionCollector: ExtractionCollector<T>
|
||||
data: unknown,
|
||||
extractionCollector: ExtractionCollector<T>,
|
||||
evalFn: <TEval>(expression: string) => TEval
|
||||
): void;
|
||||
}
|
||||
|
||||
@@ -19,3 +20,18 @@ export interface DataExtraction<TData extends ExtractedData> {
|
||||
name: string;
|
||||
extractData(): TData;
|
||||
}
|
||||
|
||||
export function getExtractions<T extends ExtractedData>(
|
||||
extractor: DataExtractor<T>,
|
||||
data: unknown,
|
||||
evalFn: <T>(expression: string) => T
|
||||
): DataExtraction<T>[] {
|
||||
const extractions = new Array<DataExtraction<T>>();
|
||||
const collector: ExtractionCollector<T> = {
|
||||
addExtraction(extraction) {
|
||||
extractions.push(extraction);
|
||||
},
|
||||
};
|
||||
extractor.getExtractions(data, collector, evalFn);
|
||||
return extractions;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface DataExtractorApi {
|
||||
): void;
|
||||
getData(
|
||||
value: unknown,
|
||||
evalFn: <T>(expression: string) => T,
|
||||
preferredDataExtractorId: string | undefined
|
||||
): JSONString<DataResult>;
|
||||
}
|
||||
@@ -54,7 +55,7 @@ export function selfContainedInitDataExtractorApi(): boolean {
|
||||
registerExtractor(extractor) {
|
||||
obj[prefix + extractor.id] = extractor;
|
||||
},
|
||||
getData(value, preferredDataExtractorId) {
|
||||
getData(value, evalFn, preferredDataExtractorId) {
|
||||
const extractions = new Array<DataExtraction<ExtractedData>>();
|
||||
const collector: ExtractionCollector<ExtractedData> = {
|
||||
addExtraction(extraction) {
|
||||
@@ -62,7 +63,7 @@ export function selfContainedInitDataExtractorApi(): boolean {
|
||||
},
|
||||
};
|
||||
for (const e of getExtractors()) {
|
||||
e.getExtractions(value, collector);
|
||||
e.getExtractions(value, collector, evalFn);
|
||||
}
|
||||
extractions.sort((a, b) => b.priority - a.priority);
|
||||
let usedExtraction = extractions[0];
|
||||
@@ -113,7 +114,7 @@ export function selfContainedInitDataExtractorApi(): boolean {
|
||||
kind: {
|
||||
text: true,
|
||||
},
|
||||
text: data.toString(),
|
||||
text: "" + data,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,13 +7,16 @@ export class TypeScriptAstDataExtractor
|
||||
readonly id = "TypeScriptAst";
|
||||
|
||||
getExtractions(
|
||||
data: any,
|
||||
collector: ExtractionCollector<CommonDataTypes.AstData>
|
||||
data: unknown,
|
||||
collector: ExtractionCollector<CommonDataTypes.AstData>,
|
||||
evalFn: <TEval>(expression: string) => TEval
|
||||
): void {
|
||||
if (typeof data !== "object" || data === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const require = evalFn<(request: string) => unknown>("require");
|
||||
|
||||
const tsApi = require("typescript") as typeof ts;
|
||||
if (!tsApi) {
|
||||
return;
|
||||
@@ -61,6 +64,12 @@ export class TypeScriptAstDataExtractor
|
||||
})
|
||||
.filter(c => c !== null);
|
||||
|
||||
let value: string | undefined = undefined;
|
||||
|
||||
if (tsApi.isIdentifier(node)) {
|
||||
value = node.text;
|
||||
}
|
||||
|
||||
return {
|
||||
name: name,
|
||||
id: memberName,
|
||||
@@ -70,6 +79,7 @@ export class TypeScriptAstDataExtractor
|
||||
position: 0,
|
||||
},
|
||||
isMarked: node === marked,
|
||||
value,
|
||||
// startPos: node.pos,
|
||||
// endPos: node.end
|
||||
};
|
||||
|
||||
@@ -33,7 +33,123 @@ class Main {
|
||||
class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = ;
|
||||
const x = e;
|
||||
}
|
||||
}
|
||||
class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}class Test {
|
||||
public test() {
|
||||
console.log("aaa");
|
||||
const x = e;
|
||||
}
|
||||
}
|
||||
`,
|
||||
@@ -42,7 +158,7 @@ class Test {
|
||||
);
|
||||
|
||||
console.log(sf);
|
||||
//new TypeScriptAstDataExtractor().getExtractions(sf, );
|
||||
debugger;
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
||||
@@ -68,7 +68,7 @@ class JsDebuggerSourceImplementation implements JsDataSource {
|
||||
w._state = { kind: "loading" };
|
||||
const expression = `(${selfContainedGetInitializedDataExtractorApi.toString()})().getData(${
|
||||
w.expression
|
||||
})`;
|
||||
}, expr => eval(expr), undefined)`;
|
||||
|
||||
const reply = await session.customRequest("evaluate", {
|
||||
expression,
|
||||
|
||||
@@ -47,7 +47,7 @@ export class WebView {
|
||||
}
|
||||
|
||||
export function getHtml(server: Server) {
|
||||
const isDev = false;
|
||||
const isDev = true;
|
||||
return `
|
||||
<html>
|
||||
<head>
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
registerUpdateReconciler,
|
||||
getReloadCount,
|
||||
} from "@hediet/node-reload";
|
||||
enableHotReload({ entryModule: module });
|
||||
enableHotReload({ entryModule: module, loggingEnabled: true });
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
|
||||
import { createJsDebuggerSource } from "./DataSource/JsDebuggerSource";
|
||||
|
||||
@@ -7,6 +7,15 @@ import { SvgLine } from "../../Components/SvgElements";
|
||||
import "./style.scss";
|
||||
|
||||
export class TreeViewModel {
|
||||
private started = true;
|
||||
start() {
|
||||
this.started = true;
|
||||
this.updateOffsets();
|
||||
}
|
||||
stop() {
|
||||
this.started = false;
|
||||
}
|
||||
|
||||
private version = 0;
|
||||
private lastUpdateVersion = -1;
|
||||
|
||||
@@ -18,6 +27,9 @@ export class TreeViewModel {
|
||||
|
||||
@action
|
||||
public updateOffsets() {
|
||||
if (!this.started) {
|
||||
return;
|
||||
}
|
||||
if (!this.root) {
|
||||
return;
|
||||
}
|
||||
@@ -76,6 +88,7 @@ export class TreeNodeViewModel {
|
||||
public readonly treeViewModel: TreeViewModel,
|
||||
public readonly id: string | undefined,
|
||||
public readonly name: string,
|
||||
public readonly value: string | undefined,
|
||||
public readonly children: TreeNodeViewModel[]
|
||||
) {}
|
||||
|
||||
@@ -178,6 +191,22 @@ export class TreeWithPathView extends React.Component<{
|
||||
|
||||
@observer
|
||||
export class TreeView extends React.Component<{ model: TreeViewModel }> {
|
||||
componentWillUpdate() {
|
||||
this.props.model.stop();
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.props.model.stop();
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.props.model.start();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.model.start();
|
||||
}
|
||||
|
||||
render() {
|
||||
const model = this.props.model;
|
||||
return (
|
||||
@@ -393,6 +422,9 @@ export class TreeNodeView extends React.Component<{
|
||||
</>
|
||||
)}
|
||||
<span className="part-name">{model.name}</span>
|
||||
{model.value && (
|
||||
<span className="part-value">{model.value}</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -9,19 +9,20 @@ export function createTreeViewModelFromTreeNodeData(
|
||||
return m;
|
||||
|
||||
function recurse(
|
||||
root: CommonDataTypes.TreeNodeData["root"],
|
||||
node: CommonDataTypes.TreeNodeData["root"],
|
||||
viewModel: TreeViewModel
|
||||
): TreeNodeViewModel {
|
||||
const children: TreeNodeViewModel[] = root.children.map(c =>
|
||||
const children: TreeNodeViewModel[] = node.children.map(c =>
|
||||
recurse(c, viewModel)
|
||||
);
|
||||
const model = new TreeNodeViewModel(
|
||||
viewModel,
|
||||
root.id,
|
||||
root.name,
|
||||
node.id,
|
||||
node.name,
|
||||
node.value,
|
||||
children
|
||||
);
|
||||
model.isMarked = root.isMarked;
|
||||
model.isMarked = node.isMarked;
|
||||
for (const c of children) {
|
||||
c.parent = model;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,13 @@
|
||||
.part-id {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.part-value {
|
||||
color: darkred;
|
||||
border: black solid 1px;
|
||||
padding: 1px 3px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
yarn.lock
10
yarn.lock
@@ -332,7 +332,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.36.0.tgz#ae60242e893d9eda9a0d96d51ef56f1a3fae14ed"
|
||||
integrity sha512-SbHR3Q5g/C3N+Ila3KrRf1rSZiyHxWdOZ7X3yFHXzw6HrvRLuVZrxnwEX0lTBMRpH9LkwZdqRTgXW+D075jxkg==
|
||||
|
||||
"@types/webpack@*", "@types/webpack@^4.32.1", "@types/webpack@^4.4.19":
|
||||
"@types/webpack@*", "@types/webpack@^4.32.1", "@types/webpack@^4.4.19", "@types/webpack@^4.4.31":
|
||||
version "4.32.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.32.1.tgz#6e95010e806f808abd6551c112097ac09035aacf"
|
||||
integrity sha512-9n38CBx9uga1FEAdTipnt0EkbKpsCJFh7xJb1LE65FFb/A6OOLFX022vYsGC1IyVCZ/GroNg9u/RMmlDxGcLIw==
|
||||
@@ -1213,6 +1213,14 @@ clean-css@4.2.x:
|
||||
dependencies:
|
||||
source-map "~0.6.0"
|
||||
|
||||
clean-webpack-plugin@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-3.0.0.tgz#a99d8ec34c1c628a4541567aa7b457446460c62b"
|
||||
integrity sha512-MciirUH5r+cYLGCOL5JX/ZLzOZbVr1ot3Fw+KcvbhUb6PM+yycqd9ZhIlcigQ5gl+XhppNmw3bEFuaaMNyLj3A==
|
||||
dependencies:
|
||||
"@types/webpack" "^4.4.31"
|
||||
del "^4.1.1"
|
||||
|
||||
cliui@^3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d"
|
||||
|
||||
Reference in New Issue
Block a user