diff --git a/packages/editor/src/performance/perf-diagram-loader.ts b/packages/editor/src/performance/perf-diagram-loader.ts index 4154b045..87566693 100644 --- a/packages/editor/src/performance/perf-diagram-loader.ts +++ b/packages/editor/src/performance/perf-diagram-loader.ts @@ -1,4 +1,4 @@ -import { DiagramLoader, DiagramLoadingOptions, IDiagramStartup, ResolvedDiagramLoadingOptions } from '@eclipse-glsp/client'; +import { DiagramLoader, DiagramLoadingOptions, IDiagramStartup, ResolvedDiagramLoadingOptions, StatusAction } from '@eclipse-glsp/client'; import { injectable } from 'inversify'; @injectable() @@ -10,9 +10,34 @@ export class PerfDiagramLoader extends DiagramLoader { } protected override async initialize(options: ResolvedDiagramLoadingOptions): Promise { - console.time('DiagramLoader.initialize'); - await super.initialize(options); - console.timeEnd('DiagramLoader.initialize'); + console.time('DiagramLoader.initialize (DI)'); + if (options.enableNotifications) { + console.time('dispatchStatus - (DI)'); + await this.actionDispatcher.dispatch(StatusAction.create('Initializing...', { severity: 'INFO' })); + console.timeEnd('dispatchStatus - (DI)'); + } + + console.time('getClient - (DI)'); + const glspClient = await this.options.glspClientProvider(); + console.timeEnd('getClient - (DI)'); + console.time('startClient - (DI)'); + await glspClient.start(); + console.timeEnd('startClient - (DI)'); + if (!glspClient.initializeResult) { + console.time('initializeServer - (DI)'); + await glspClient.initializeServer(options.initializeParameters); + console.timeEnd('initializeServer - (DI)'); + } + console.time('configureModelSource - (DI)'); + this.modelSource.configure(glspClient); + console.timeEnd('configureModelSource - (DI)'); + + if (options.enableNotifications) { + console.time('clearStatus - (DI)'); + this.actionDispatcher.dispatch(StatusAction.create('', { severity: 'NONE' })); + console.timeEnd('clearStatus - (DI)'); + } + console.timeEnd('DiagramLoader.initialize (DI)'); } protected override async requestModel(options: ResolvedDiagramLoadingOptions): Promise { diff --git a/packages/editor/src/performance/perf-model-source.ts b/packages/editor/src/performance/perf-model-source.ts new file mode 100644 index 00000000..4c55c9fc --- /dev/null +++ b/packages/editor/src/performance/perf-model-source.ts @@ -0,0 +1,32 @@ +import { Disposable, GLSPClient, GLSPModelSource } from '@eclipse-glsp/client'; +import { injectable } from 'inversify'; + +@injectable() +export class PerfGLSPModelSource extends GLSPModelSource { + async configure(glspClient: GLSPClient): Promise { + console.time('GLSPModelSource.configure (MS)'); + this.glspClient = glspClient; + if (!glspClient.initializeResult) { + throw new Error('Could not configure model source. The GLSP client is not initialized yet!'); + } + + console.time('createInitializeClientSessionParameters (MS)'); + const initializeParams = this.createInitializeClientSessionParameters(glspClient.initializeResult); + console.timeEnd('createInitializeClientSessionParameters (MS)'); + + console.time('configureServerActions (MS)'); + this.configureServeActions(glspClient.initializeResult); + console.timeEnd('configureServerActions (MS)'); + + this.toDispose.push( + glspClient.onActionMessage(message => this.messageReceived(message), this.clientId), + Disposable.create(() => glspClient.disposeClientSession(this.createDisposeClientSessionParameters())) + ); + + console.time('initializeClientSession (MS)'); + const result = await glspClient!.initializeClientSession(initializeParams); + console.timeEnd('initializeClientSession (MS)'); + console.timeEnd('GLSPModelSource.configure (MS)'); + return result; + } +} diff --git a/packages/editor/src/performance/performance-module.ts b/packages/editor/src/performance/performance-module.ts index eafceb3a..745bc57c 100644 --- a/packages/editor/src/performance/performance-module.ts +++ b/packages/editor/src/performance/performance-module.ts @@ -1,8 +1,9 @@ -import { DiagramLoader, FeatureModule, GLSPActionDispatcher, ModelViewer, TYPES } from '@eclipse-glsp/client'; +import { DiagramLoader, FeatureModule, GLSPActionDispatcher, GLSPModelSource, ModelViewer, TYPES } from '@eclipse-glsp/client'; import { PerfActionDispatcher } from './perf-action-dispatcher'; import { PerfCommandStack } from './perf-command-stack'; import { PerfDiagramLoader } from './perf-diagram-loader'; import { PerfModelViewer } from './perf-viewer'; +import { PerfGLSPModelSource } from './perf-model-source'; export function createPerformanceModule(enabled?: boolean): FeatureModule { return new FeatureModule( @@ -14,6 +15,7 @@ export function createPerformanceModule(enabled?: boolean): FeatureModule { rebind(GLSPActionDispatcher).to(PerfActionDispatcher).inSingletonScope(); rebind(ModelViewer).to(PerfModelViewer).inSingletonScope(); rebind(TYPES.ICommandStack).to(PerfCommandStack).inSingletonScope(); + rebind(GLSPModelSource).to(PerfGLSPModelSource).inSingletonScope(); }, { featureId: Symbol('performance') } );