Renames DataSource to EvaluationWatchService and DataExtractionProvider to Evaluator.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { Disposable } from "@hediet/std/disposable";
|
||||
import { debugVisualizerUIContract } from "./contract";
|
||||
import { ConsoleRpcLogger, RequestHandlingError } from "@hediet/typed-json-rpc";
|
||||
import { EvaluationWatcher, DataSource } from "./DataSource/DataSource";
|
||||
import {
|
||||
EvaluationWatcher,
|
||||
EvaluationWatchService,
|
||||
} from "./EvaluationWatchService";
|
||||
import { WebSocketStream } from "@hediet/typed-json-rpc-websocket";
|
||||
import { observable, autorun } from "mobx";
|
||||
import { Server } from "./Server";
|
||||
@@ -17,7 +20,7 @@ export class ClientConnection {
|
||||
private readonly client: typeof debugVisualizerUIContract["TClientInterface"];
|
||||
|
||||
constructor(
|
||||
dataSource: DataSource,
|
||||
dataSource: EvaluationWatchService,
|
||||
stream: WebSocketStream,
|
||||
server: Server,
|
||||
config: Config,
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import {
|
||||
DataExtractionProviderFactory,
|
||||
DataExtractionProvider,
|
||||
} from "./DataExtractionProvider";
|
||||
import { VsCodeDebugSession } from "../../VsCodeDebugger";
|
||||
|
||||
export class ComposedDataExtractionProviderFactory
|
||||
implements DataExtractionProviderFactory {
|
||||
constructor(public readonly factories: DataExtractionProviderFactory[]) {}
|
||||
|
||||
createDataExtractionProvider(
|
||||
session: VsCodeDebugSession
|
||||
): DataExtractionProvider | undefined {
|
||||
for (const f of this.factories) {
|
||||
const provider = f.createDataExtractionProvider(session);
|
||||
if (provider) {
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export * from "./DataExtractionProvider";
|
||||
|
||||
export { ComposedDataExtractionProviderFactory } from "./ComposedDataExtractionProviderFactory";
|
||||
export { JsDataExtractionProviderFactory } from "./JsDataExtractionProviderFactory";
|
||||
export { GenericDataExtractionProviderFactory } from "./GenericDataExtractionProviderFactory";
|
||||
export { ConfiguredDataExtractionProviderFactory } from "./ConfiguredDataExtractionProviderFactory";
|
||||
@@ -1 +0,0 @@
|
||||
export * from "./DataSourceImpl";
|
||||
@@ -0,0 +1,16 @@
|
||||
import { EvaluationEngine, Evaluator } from "./EvaluationEngine";
|
||||
import { VsCodeDebugSession } from "../../VsCodeDebugger";
|
||||
|
||||
export class ComposedEvaluationEngine implements EvaluationEngine {
|
||||
constructor(public readonly engines: EvaluationEngine[]) {}
|
||||
|
||||
createEvaluator(session: VsCodeDebugSession): Evaluator | undefined {
|
||||
for (const f of this.engines) {
|
||||
const evaluator = f.createEvaluator(session);
|
||||
if (evaluator) {
|
||||
return evaluator;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,26 @@
|
||||
import { DataExtractorId } from "@hediet/debug-visualizer-data-extraction";
|
||||
import { VsCodeDebugSession } from "../../VsCodeDebugger";
|
||||
import {
|
||||
DataExtractionProviderFactory,
|
||||
DataExtractionProvider,
|
||||
} from "./DataExtractionProvider";
|
||||
import { EvaluationEngine, Evaluator } from "./EvaluationEngine";
|
||||
import { Config, DebugAdapterConfig } from "../../Config";
|
||||
import { GenericDataExtractionProvider } from "./GenericDataExtractionProviderFactory";
|
||||
import { GenericEvaluator } from "./GenericEvaluationEngine";
|
||||
import { registerUpdateReconciler, hotClass } from "@hediet/node-reload";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class ConfiguredDataExtractionProviderFactory
|
||||
implements DataExtractionProviderFactory {
|
||||
export class ConfiguredEvaluationEngine implements EvaluationEngine {
|
||||
constructor(private readonly config: Config) {}
|
||||
|
||||
createDataExtractionProvider(
|
||||
session: VsCodeDebugSession
|
||||
): DataExtractionProvider | undefined {
|
||||
createEvaluator(session: VsCodeDebugSession): Evaluator | undefined {
|
||||
const config = this.config.getDebugAdapterConfig(session.session.type);
|
||||
if (!config) {
|
||||
return undefined;
|
||||
}
|
||||
return new ConfiguredDataExtractionProvider(session, config);
|
||||
return new ConfiguredEvaluator(session, config);
|
||||
}
|
||||
}
|
||||
|
||||
class ConfiguredDataExtractionProvider extends GenericDataExtractionProvider {
|
||||
class ConfiguredEvaluator extends GenericEvaluator {
|
||||
constructor(
|
||||
session: VsCodeDebugSession,
|
||||
private readonly config: DebugAdapterConfig
|
||||
@@ -5,22 +5,20 @@ import {
|
||||
import { VsCodeDebugSession } from "../../VsCodeDebugger";
|
||||
import { FormattedMessage } from "../../contract";
|
||||
|
||||
export interface DataExtractionProviderFactory {
|
||||
createDataExtractionProvider(
|
||||
session: VsCodeDebugSession
|
||||
): DataExtractionProvider | undefined;
|
||||
export interface EvaluationEngine {
|
||||
createEvaluator(session: VsCodeDebugSession): Evaluator | undefined;
|
||||
}
|
||||
|
||||
export interface DataExtractionProvider {
|
||||
export interface Evaluator {
|
||||
evaluate(
|
||||
args: DataExtractionProviderArgs
|
||||
args: EvaluationArgs
|
||||
): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
>;
|
||||
}
|
||||
|
||||
export interface DataExtractionProviderArgs {
|
||||
export interface EvaluationArgs {
|
||||
expression: string;
|
||||
preferredExtractorId: DataExtractorId | undefined;
|
||||
frameId: number | undefined;
|
||||
@@ -4,10 +4,10 @@ import {
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { VsCodeDebugSession } from "../../VsCodeDebugger";
|
||||
import {
|
||||
DataExtractionProviderFactory,
|
||||
DataExtractionProvider,
|
||||
DataExtractionProviderArgs,
|
||||
} from "./DataExtractionProvider";
|
||||
EvaluationEngine,
|
||||
Evaluator,
|
||||
EvaluationArgs,
|
||||
} from "./EvaluationEngine";
|
||||
import { parseEvaluationResultFromGenericDebugAdapter } from "./parseEvaluationResultFromGenericDebugAdapter";
|
||||
import { FormattedMessage } from "../../contract";
|
||||
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
||||
@@ -15,23 +15,20 @@ import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class GenericDataExtractionProviderFactory
|
||||
implements DataExtractionProviderFactory {
|
||||
createDataExtractionProvider(
|
||||
session: VsCodeDebugSession
|
||||
): DataExtractionProvider | undefined {
|
||||
return new GenericDataExtractionProvider(session);
|
||||
export class GenericEvaluationEngine implements EvaluationEngine {
|
||||
createEvaluator(session: VsCodeDebugSession): Evaluator | undefined {
|
||||
return new GenericEvaluator(session);
|
||||
}
|
||||
}
|
||||
|
||||
export class GenericDataExtractionProvider implements DataExtractionProvider {
|
||||
export class GenericEvaluator implements Evaluator {
|
||||
constructor(private readonly session: VsCodeDebugSession) {}
|
||||
|
||||
public async evaluate({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
frameId,
|
||||
}: DataExtractionProviderArgs): Promise<
|
||||
}: EvaluationArgs): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
@@ -7,21 +7,18 @@ import {
|
||||
} from "@hediet/debug-visualizer-data-extraction";
|
||||
import { VsCodeDebugSession } from "../../VsCodeDebugger";
|
||||
import {
|
||||
DataExtractionProviderFactory,
|
||||
DataExtractionProvider,
|
||||
DataExtractionProviderArgs,
|
||||
} from "./DataExtractionProvider";
|
||||
EvaluationEngine,
|
||||
Evaluator,
|
||||
EvaluationArgs,
|
||||
} from "./EvaluationEngine";
|
||||
import { FormattedMessage } from "../../contract";
|
||||
import { registerUpdateReconciler, hotClass } from "@hediet/node-reload";
|
||||
|
||||
registerUpdateReconciler(module);
|
||||
|
||||
@hotClass(module)
|
||||
export class JsDataExtractionProviderFactory
|
||||
implements DataExtractionProviderFactory {
|
||||
createDataExtractionProvider(
|
||||
session: VsCodeDebugSession
|
||||
): DataExtractionProvider | undefined {
|
||||
export class JsEvaluationEngine implements EvaluationEngine {
|
||||
createEvaluator(session: VsCodeDebugSession): Evaluator | undefined {
|
||||
const supportedDebugAdapters = [
|
||||
"node",
|
||||
"node2",
|
||||
@@ -29,20 +26,20 @@ export class JsDataExtractionProviderFactory
|
||||
"chrome",
|
||||
];
|
||||
if (supportedDebugAdapters.indexOf(session.session.type) !== -1) {
|
||||
return new JsDataEvaluator(session);
|
||||
return new JsEvaluator(session);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class JsDataEvaluator implements DataExtractionProvider {
|
||||
class JsEvaluator implements Evaluator {
|
||||
constructor(private readonly session: VsCodeDebugSession) {}
|
||||
|
||||
public async evaluate({
|
||||
expression,
|
||||
preferredExtractorId,
|
||||
frameId,
|
||||
}: DataExtractionProviderArgs): Promise<
|
||||
}: EvaluationArgs): Promise<
|
||||
| { kind: "data"; result: DataExtractionResult }
|
||||
| { kind: "error"; message: FormattedMessage }
|
||||
> {
|
||||
@@ -0,0 +1,6 @@
|
||||
export * from "./EvaluationEngine";
|
||||
|
||||
export { ComposedEvaluationEngine } from "./ComposedEvaluationEngine";
|
||||
export { JsEvaluationEngine } from "./JsEvaluationEngine";
|
||||
export { GenericEvaluationEngine } from "./GenericEvaluationEngine";
|
||||
export { ConfiguredEvaluationEngine } from "./ConfiguredEvaluationEngine";
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DataExtractorId } from "@hediet/debug-visualizer-data-extraction";
|
||||
import { DataExtractionState, CompletionItem } from "../contract";
|
||||
|
||||
export interface DataSource {
|
||||
export interface EvaluationWatchService {
|
||||
createEvaluationWatcher(
|
||||
expression: string,
|
||||
options: EvaluationWatcherOptions
|
||||
@@ -1,24 +1,24 @@
|
||||
import {
|
||||
DataSource,
|
||||
EvaluationWatchService,
|
||||
EvaluationWatcher,
|
||||
EvaluationWatcherOptions,
|
||||
} from "./DataSource";
|
||||
} 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 "../contract";
|
||||
import { hotClass } from "@hediet/node-reload";
|
||||
import { VsCodeDebuggerView } from "../VsCodeDebugger";
|
||||
import { DataExtractionProviderFactory } from "./DataExtractionProvider/DataExtractionProvider";
|
||||
import { EvaluationEngine } from "./EvaluationEngine/EvaluationEngine";
|
||||
|
||||
@hotClass(module)
|
||||
export class DataSourceImpl implements DataSource {
|
||||
export class EvaluationWatchServiceImpl implements EvaluationWatchService {
|
||||
public readonly dispose = Disposable.fn();
|
||||
private readonly watchers = new Set<ObservableEvaluationWatcher>();
|
||||
|
||||
constructor(
|
||||
private readonly vsCodeDebuggerView: VsCodeDebuggerView,
|
||||
private readonly dataExtractionProviderFactory: DataExtractionProviderFactory
|
||||
private readonly dataExtractionProviderFactory: EvaluationEngine
|
||||
) {
|
||||
this.dispose.track({
|
||||
dispose: autorun(() => {
|
||||
@@ -59,7 +59,7 @@ export class DataSourceImpl implements DataSource {
|
||||
|
||||
w._state = { kind: "loading" };
|
||||
|
||||
const extractionProvider = this.dataExtractionProviderFactory.createDataExtractionProvider(
|
||||
const extractionProvider = this.dataExtractionProviderFactory.createEvaluator(
|
||||
session
|
||||
);
|
||||
if (!extractionProvider) {
|
||||
@@ -98,7 +98,7 @@ export class DataSourceImpl implements DataSource {
|
||||
class ObservableEvaluationWatcher implements EvaluationWatcher {
|
||||
constructor(
|
||||
public readonly expression: string,
|
||||
private readonly source: DataSourceImpl,
|
||||
private readonly source: EvaluationWatchServiceImpl,
|
||||
options: EvaluationWatcherOptions
|
||||
) {
|
||||
this._preferredDataExtractor = options.preferredDataExtractor;
|
||||
2
extension/src/EvaluationWatchService/index.ts
Normal file
2
extension/src/EvaluationWatchService/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./EvaluationWatchServiceImpl";
|
||||
export * from "./EvaluationWatchService";
|
||||
@@ -8,7 +8,7 @@ import * as serveStatic from "serve-static";
|
||||
import { Config } from "./Config";
|
||||
import cryptoRandomString = require("crypto-random-string");
|
||||
import { distPath } from "debug-visualizer-webview";
|
||||
import { DataSource } from "./DataSource/DataSource";
|
||||
import { EvaluationWatchService } from "./EvaluationWatchService/EvaluationWatchService";
|
||||
|
||||
export class Server {
|
||||
private server: http.Server;
|
||||
@@ -16,7 +16,7 @@ export class Server {
|
||||
|
||||
public readonly connections = new Set<ClientConnection>();
|
||||
|
||||
constructor(dataSource: DataSource, config: Config) {
|
||||
constructor(dataSource: EvaluationWatchService, config: Config) {
|
||||
const app = express();
|
||||
|
||||
app.use(serveStatic(distPath));
|
||||
|
||||
@@ -16,13 +16,13 @@ import { WebViews } from "./WebViews";
|
||||
import { Server } from "./Server";
|
||||
import { Config } from "./Config";
|
||||
import { VsCodeDebugger, VsCodeDebuggerView } from "./VsCodeDebugger";
|
||||
import { DataSourceImpl } from "./DataSource";
|
||||
import { EvaluationWatchServiceImpl } from "./EvaluationWatchService";
|
||||
import {
|
||||
ComposedDataExtractionProviderFactory,
|
||||
JsDataExtractionProviderFactory,
|
||||
GenericDataExtractionProviderFactory,
|
||||
ConfiguredDataExtractionProviderFactory,
|
||||
} from "./DataSource/DataExtractionProvider";
|
||||
ComposedEvaluationEngine,
|
||||
JsEvaluationEngine,
|
||||
GenericEvaluationEngine,
|
||||
ConfiguredEvaluationEngine,
|
||||
} from "./EvaluationWatchService/EvaluationEngine";
|
||||
|
||||
export class Extension {
|
||||
public readonly dispose = Disposable.fn();
|
||||
@@ -34,12 +34,12 @@ export class Extension {
|
||||
new VsCodeDebuggerView(this.debugger)
|
||||
);
|
||||
|
||||
public readonly dataSource = new DataSourceImpl(
|
||||
public readonly dataSource = new EvaluationWatchServiceImpl(
|
||||
this.debuggerView,
|
||||
new ComposedDataExtractionProviderFactory([
|
||||
new ConfiguredDataExtractionProviderFactory(this.config),
|
||||
new JsDataExtractionProviderFactory(),
|
||||
new GenericDataExtractionProviderFactory(),
|
||||
new ComposedEvaluationEngine([
|
||||
new ConfiguredEvaluationEngine(this.config),
|
||||
new JsEvaluationEngine(),
|
||||
new GenericEvaluationEngine(),
|
||||
])
|
||||
);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"dev": "webpack-dev-server --hot",
|
||||
"dev-playground": "webpack-dev-server --hot --port 8090 --playground",
|
||||
"build": "webpack"
|
||||
},
|
||||
"main": "./index.js",
|
||||
|
||||
Reference in New Issue
Block a user