From a1b2800ef5fb5ddfbfbff2378ae6dd8cc9d3539c Mon Sep 17 00:00:00 2001 From: Jette Petzold Date: Thu, 21 Dec 2023 15:55:03 +0100 Subject: [PATCH] added comments --- .../fta/analysis/fta-cutSet-calculator.ts | 1 + .../fta/diagram/fta-diagram-generator.ts | 3 + .../fta/diagram/fta-interfaces.ts | 6 + .../fta/diagram/fta-synthesis-options.ts | 12 ++ .../src-language-server/fta/diagram/utils.ts | 2 +- .../fta/fta-message-handler.ts | 5 +- extension/src-language-server/fta/utils.ts | 1 + .../stpa/ftaGeneration/fta-generation.ts | 17 +- extension/src-language-server/utils.ts | 9 + extension/src-webview/actions.ts | 4 +- .../context-menu/context-menu-provider.ts | 2 +- .../context-menu/context-menu-services.ts | 2 +- extension/src-webview/di.config.ts | 8 +- extension/src-webview/fta/fta-model.ts | 6 + extension/src-webview/fta/fta-views.tsx | 11 +- extension/src-webview/views-rendering.tsx | 14 ++ extension/src/actions.ts | 3 +- extension/src/extension.ts | 187 +++++++++++------- extension/src/wview.ts | 16 ++ 19 files changed, 216 insertions(+), 93 deletions(-) diff --git a/extension/src-language-server/fta/analysis/fta-cutSet-calculator.ts b/extension/src-language-server/fta/analysis/fta-cutSet-calculator.ts index 6ffdc5d9..abe13f54 100644 --- a/extension/src-language-server/fta/analysis/fta-cutSet-calculator.ts +++ b/extension/src-language-server/fta/analysis/fta-cutSet-calculator.ts @@ -29,6 +29,7 @@ import { } from "../../generated/ast"; import { namedFtaElement } from "../utils"; +/* element for which the cut sets were determined */ export let topOfAnalysis: string | undefined; /** diff --git a/extension/src-language-server/fta/diagram/fta-diagram-generator.ts b/extension/src-language-server/fta/diagram/fta-diagram-generator.ts index db38e38c..19dcf434 100644 --- a/extension/src-language-server/fta/diagram/fta-diagram-generator.ts +++ b/extension/src-language-server/fta/diagram/fta-diagram-generator.ts @@ -43,8 +43,11 @@ export class FtaDiagramGenerator extends LangiumDiagramGenerator { /** Saves the Ids of the generated SNodes */ protected idToSNode: Map = new Map(); + /** Saves the parent node of a gate */ protected parentOfGate: Map = new Map(); + /** Saves the description node of a gate */ protected descriptionOfGate: Map = new Map(); + /** Saves the port of a node */ protected nodeToPort: Map = new Map(); constructor(services: FtaServices) { diff --git a/extension/src-language-server/fta/diagram/fta-interfaces.ts b/extension/src-language-server/fta/diagram/fta-interfaces.ts index 3c799b3f..eb2c9b99 100644 --- a/extension/src-language-server/fta/diagram/fta-interfaces.ts +++ b/extension/src-language-server/fta/diagram/fta-interfaces.ts @@ -32,10 +32,16 @@ export interface FTANode extends SNode { n?: number; } +/** + * FTA Graph. + */ export interface FTAGraph extends SGraph { modelOrder?: boolean; } +/** + * Description node of a fault tree. + */ export interface DescriptionNode extends SNode { name: string; inCurrentSelectedCutSet?: boolean; diff --git a/extension/src-language-server/fta/diagram/fta-synthesis-options.ts b/extension/src-language-server/fta/diagram/fta-synthesis-options.ts index d2204693..8ffc6dc6 100644 --- a/extension/src-language-server/fta/diagram/fta-synthesis-options.ts +++ b/extension/src-language-server/fta/diagram/fta-synthesis-options.ts @@ -48,6 +48,9 @@ const analysisCategoryOption: ValuedSynthesisOption = { currentValue: 0, }; +/** + * Boolean option to toggle the visualization gate descriptions. + */ const showGateDescriptionsOptions: ValuedSynthesisOption = { synthesisOption: { id: showGateDescriptionsID, @@ -61,6 +64,9 @@ const showGateDescriptionsOptions: ValuedSynthesisOption = { currentValue: true, }; +/** + * Boolean option to toggle the visualization node descriptions. + */ const showComponentDescriptionsOptions: ValuedSynthesisOption = { synthesisOption: { id: showComponentDescriptionsID, @@ -74,6 +80,9 @@ const showComponentDescriptionsOptions: ValuedSynthesisOption = { currentValue: false, }; +/** + * Option to highlight the components of a cut set. + */ const cutSets: ValuedSynthesisOption = { synthesisOption: { id: cutSetsID, @@ -123,6 +132,9 @@ export class FtaSynthesisOptions extends SynthesisOptions { } } + /** + * Resets the cutSets option to no cut set. + */ resetCutSets(): void { const option = this.getOption(cutSetsID); if (option) { diff --git a/extension/src-language-server/fta/diagram/utils.ts b/extension/src-language-server/fta/diagram/utils.ts index 71d008a0..55ffd5a7 100644 --- a/extension/src-language-server/fta/diagram/utils.ts +++ b/extension/src-language-server/fta/diagram/utils.ts @@ -59,7 +59,7 @@ export function getFTNodeType(node: AstNode): FTNodeType { */ export function getTargets(node: AstNode): AstNode[] { const targets: AstNode[] = []; - // only the top event and gates have children + // only the top event and gates have children/targets if (isTopEvent(node) && node.child.ref) { targets.push(node.child.ref); } diff --git a/extension/src-language-server/fta/fta-message-handler.ts b/extension/src-language-server/fta/fta-message-handler.ts index 44f72045..e8eff62d 100644 --- a/extension/src-language-server/fta/fta-message-handler.ts +++ b/extension/src-language-server/fta/fta-message-handler.ts @@ -15,7 +15,6 @@ * SPDX-License-Identifier: EPL-2.0 */ -import { AstNode } from "langium"; import { LangiumSprottySharedServices } from "langium-sprotty"; import { Connection } from "vscode-languageserver"; import { ModelFTA } from "../generated/ast"; @@ -49,10 +48,10 @@ function addCutSetsHandler( ftaServices: FtaServices, sharedServices: LangiumSprottySharedServices ): void { - connection.onRequest("cutSets/generate", async (content: {uri: string, startId?: string}) => { + connection.onRequest("cutSets/generate", async (content: { uri: string; startId?: string }) => { return cutSetsRequested(content.uri, ftaServices, sharedServices, false, content.startId); }); - connection.onRequest("cutSets/generateMinimal", async (content: {uri: string, startId?: string}) => { + connection.onRequest("cutSets/generateMinimal", async (content: { uri: string; startId?: string }) => { return cutSetsRequested(content.uri, ftaServices, sharedServices, true, content.startId); }); connection.onRequest("cutSets/reset", () => { diff --git a/extension/src-language-server/fta/utils.ts b/extension/src-language-server/fta/utils.ts index 7e6081b2..2dc8fb84 100644 --- a/extension/src-language-server/fta/utils.ts +++ b/extension/src-language-server/fta/utils.ts @@ -18,6 +18,7 @@ import { Range } from "vscode-languageserver"; import { Component, Condition, Gate, ModelFTA, TopEvent, isAND, isInhibitGate, isKNGate, isOR } from "../generated/ast"; +/** FTA elements that have a name. */ export type namedFtaElement = Component | Condition | Gate | TopEvent; /** diff --git a/extension/src-language-server/stpa/ftaGeneration/fta-generation.ts b/extension/src-language-server/stpa/ftaGeneration/fta-generation.ts index 5983f0dc..229dc65d 100644 --- a/extension/src-language-server/stpa/ftaGeneration/fta-generation.ts +++ b/extension/src-language-server/stpa/ftaGeneration/fta-generation.ts @@ -17,7 +17,7 @@ import type { Reference } from "langium"; import { LangiumSprottySharedServices } from "langium-sprotty"; -import { Children, Component, Hazard, LossScenario, Model, ModelFTA, OR, TopEvent, UCA, isOR } from "../../generated/ast"; +import { Children, Component, Hazard, LossScenario, Model, ModelFTA, OR, TopEvent } from "../../generated/ast"; import { getModel } from "../../utils"; /** @@ -34,7 +34,7 @@ export async function createFaultTrees(uri: string, shared: LangiumSprottyShared const scenarios: Map = sortScenarios(model); // create fault tree for each hazard for (const hazard of model.hazards) { - faultTrees.push(createFaulTreeForHazard(model, scenarios, hazard)); + faultTrees.push(createFaulTreeForHazard(scenarios, hazard)); } return faultTrees; } @@ -58,11 +58,10 @@ function sortScenarios(model: Model): Map { /** * Creates a fault tree with {@code hazard} as top event. - * @param stpaModel The stpa model that contains the {@code hazard}. * @param hazard The hazard for which the fault tree should be created. * @returns the AST of the created fault tree with {@code hazard} as top event. */ -function createFaulTreeForHazard(stpaModel: Model, scenarios: Map, hazard: Hazard): ModelFTA { +function createFaulTreeForHazard(scenarios: Map, hazard: Hazard): ModelFTA { const ftaModel = {} as ModelFTA; ftaModel.components = []; ftaModel.gates = []; @@ -108,7 +107,9 @@ function createFaulTreeForHazard(stpaModel: Model, scenarios: Map { return { ref: gate, $refText: gate.name } as Reference; }); + const gateChildren = ftaModel.gates.map((gate) => { + return { ref: gate, $refText: gate.name } as Reference; + }); const gate = { name: `G0`, children: gateChildren, @@ -129,6 +130,12 @@ function createFaulTreeForHazard(stpaModel: Model, scenarios: Map, key: string, value: any): void { if (map.has(key)) { const currentValues = map.get(key); diff --git a/extension/src-language-server/utils.ts b/extension/src-language-server/utils.ts index 78028a2a..b2f6f805 100644 --- a/extension/src-language-server/utils.ts +++ b/extension/src-language-server/utils.ts @@ -36,6 +36,15 @@ export async function getModel( return currentDoc.parseResult.value; } +/** + * Creates a list of labels containing the given {@code description} respecting the {@code labelManagement} and {@code labelWidth}. + * @param description The text for the label to create. + * @param labelManagement The label management option. + * @param labelWidth The desired width of the label. + * @param nodeId The id of the node for which the label is created. + * @param idCache The id cache. + * @returns a list of labels containing the given {@code description} respecting the {@code labelManagement} and {@code labelWidth}. + */ export function getDescription( description: string, labelManagement: labelManagementValue, diff --git a/extension/src-webview/actions.ts b/extension/src-webview/actions.ts index 9c6ba6f1..7979ecd8 100644 --- a/extension/src-webview/actions.ts +++ b/extension/src-webview/actions.ts @@ -17,7 +17,7 @@ import { inject } from "inversify"; import { CommandExecutionContext, CommandResult, HiddenCommand, TYPES, isExportable, isHoverable, isSelectable, isViewport } from "sprotty"; -import { RequestAction, ResponseAction, generateRequestId, Action } from "sprotty-protocol"; +import { Action, RequestAction, ResponseAction, generateRequestId } from "sprotty-protocol"; /** Requests the current SVG from the client. */ @@ -93,6 +93,7 @@ export class SvgCommand extends HiddenCommand { } } +/** Send from client to server to start a cut set analysis with the start node given by the startId */ export interface CutSetAnalysisAction extends Action { kind: typeof CutSetAnalysisAction.KIND; startId: string @@ -108,6 +109,7 @@ export namespace CutSetAnalysisAction { } } +/** Send from client to server to start a minimal cut set analysis with the start node given by the startId */ export interface MinimalCutSetAnalysisAction extends Action { kind: typeof MinimalCutSetAnalysisAction.KIND; startId: string diff --git a/extension/src-webview/context-menu/context-menu-provider.ts b/extension/src-webview/context-menu/context-menu-provider.ts index 62cc62df..1659aa24 100644 --- a/extension/src-webview/context-menu/context-menu-provider.ts +++ b/extension/src-webview/context-menu/context-menu-provider.ts @@ -27,7 +27,6 @@ export class ContextMenuProvider implements IContextMenuItemProvider { if (root.type === FTA_GRAPH_TYPE) { // find node that was clicked on let clickedNode: FTANode | undefined; - root.children.forEach((child) => { if (child.type === FTA_NODE_TYPE) { if ((child as FTANode).selected) { @@ -41,6 +40,7 @@ export class ContextMenuProvider implements IContextMenuItemProvider { } } }); + // create context menu items return Promise.resolve([ { label: "Cut Set Analysis", diff --git a/extension/src-webview/context-menu/context-menu-services.ts b/extension/src-webview/context-menu/context-menu-services.ts index ebf7a5f7..7722b5eb 100644 --- a/extension/src-webview/context-menu/context-menu-services.ts +++ b/extension/src-webview/context-menu/context-menu-services.ts @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 */ -import { injectable, inject } from "inversify"; +import { inject, injectable } from "inversify"; import { Anchor, IContextMenuService, MenuItem } from "sprotty"; import { ActionNotification } from "sprotty-vscode-protocol"; import { VsCodeMessenger } from "sprotty-vscode-webview/lib/services"; diff --git a/extension/src-webview/di.config.ts b/extension/src-webview/di.config.ts index 1471e0ea..eff02c2d 100644 --- a/extension/src-webview/di.config.ts +++ b/extension/src-webview/di.config.ts @@ -34,13 +34,14 @@ import { TYPES, configureCommand, configureModelElement, + contextMenuModule, loadDefaultModules, - overrideViewerOptions, - contextMenuModule + overrideViewerOptions } from "sprotty"; import { SvgCommand } from "./actions"; -import { ContextMenuService } from "./context-menu/context-menu-services"; import { ContextMenuProvider } from "./context-menu/context-menu-provider"; +import { ContextMenuService } from "./context-menu/context-menu-services"; +import pastaContextMenuModule from "./context-menu/di.config"; import { SvgPostprocessor } from "./exportPostProcessor"; import { CustomSvgExporter } from "./exporter"; import { DescriptionNode, FTAEdge, FTAGraph, FTANode, FTAPort, FTA_DESCRIPTION_NODE_TYPE, FTA_EDGE_TYPE, FTA_GRAPH_TYPE, FTA_INVISIBLE_EDGE_TYPE, FTA_NODE_TYPE, FTA_PORT_TYPE } from "./fta/fta-model"; @@ -72,7 +73,6 @@ import { STPAGraphView, STPANodeView, } from "./stpa/stpa-views"; -import pastaContextMenuModule from "./context-menu/di.config"; const pastaDiagramModule = new ContainerModule((bind, unbind, isBound, rebind) => { rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope(); diff --git a/extension/src-webview/fta/fta-model.ts b/extension/src-webview/fta/fta-model.ts index bdb7c4b4..9df301b7 100644 --- a/extension/src-webview/fta/fta-model.ts +++ b/extension/src-webview/fta/fta-model.ts @@ -60,10 +60,16 @@ export class FTANode extends SNode { n?: number; } +/** + * FTA Graph. + */ export class FTAGraph extends SGraph { modelOrder?: boolean; } +/** + * Description node of a fault tree. + */ export class DescriptionNode extends SNode { static readonly DEFAULT_FEATURES = [ connectableFeature, diff --git a/extension/src-webview/fta/fta-views.tsx b/extension/src-webview/fta/fta-views.tsx index 9fb3fb27..eb10db6d 100644 --- a/extension/src-webview/fta/fta-views.tsx +++ b/extension/src-webview/fta/fta-views.tsx @@ -18,8 +18,8 @@ /** @jsx svg */ import { injectable } from 'inversify'; import { VNode } from "snabbdom"; -import { Hoverable, IViewArgs, Point, PolylineEdgeView, RectangularNodeView, RenderingContext, SEdge, SGraph, SGraphView, SShapeElement, Selectable, svg } from 'sprotty'; -import { renderAndGate, renderEllipse, renderHorizontalLine, renderInhibitGate, renderKnGate, renderOrGate, renderOval, renderRectangle, renderRoundedRectangle, renderVerticalLine } from "../views-rendering"; +import { IViewArgs, Point, PolylineEdgeView, RectangularNodeView, RenderingContext, SEdge, SGraph, SGraphView, svg } from 'sprotty'; +import { renderAndGate, renderEllipse, renderHorizontalLine, renderInhibitGate, renderKnGate, renderOrGate, renderRectangle, renderRoundedRectangle, renderVerticalLine } from "../views-rendering"; import { DescriptionNode, FTAEdge, FTAGraph, FTANode, FTAPort, FTA_DESCRIPTION_NODE_TYPE, FTA_EDGE_TYPE, FTA_NODE_TYPE, FTA_PORT_TYPE, FTNodeType } from './fta-model'; @injectable() @@ -56,6 +56,7 @@ export class FTAInvisibleEdgeView extends PolylineArrowEdgeViewFTA { @injectable() export class DescriptionNodeView extends RectangularNodeView { render(node: DescriptionNode, context: RenderingContext): VNode | undefined { + // render the description node similar to an on edge label const element = renderRectangle(node); const border1 = renderHorizontalLine(node); const border2 = renderHorizontalLine(node); @@ -172,7 +173,11 @@ export class FTAGraphView extends SGraphView { return super.render(model, context); } - + /** + * Highlights the nodes and edges connected to the selected cut set. + * @param model The FTAGraph. + * @param currentNode The current node, which should be handled including its targets. + */ protected highlightConnectedToCutSet(model: SGraph, currentNode: FTANode): void { for (const port of currentNode.children.filter(child => child.type === FTA_PORT_TYPE)) { const edge = model.children.find(child => child.type === FTA_EDGE_TYPE && (child as FTAEdge).sourceId === port.id) as FTAEdge; diff --git a/extension/src-webview/views-rendering.tsx b/extension/src-webview/views-rendering.tsx index 2849fe9e..12003c89 100644 --- a/extension/src-webview/views-rendering.tsx +++ b/extension/src-webview/views-rendering.tsx @@ -32,6 +32,15 @@ export function renderOval(node: SNode): VNode { ry={Math.max(node.size.height, 0) / 2.0} />; } +/** + * Creates an ellipse for {@code node}. + * @param x The x-coordinate of the ellipse. + * @param y The y-coordinate of the ellipse. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + * @param lineWidth The line width of the ellipse. + * @returns an ellipse for {@code node}. + */ export function renderEllipse(x: number | undefined, y: number | undefined, width: number, height: number, lineWidth: number): VNode { return { } } -function registerSTPACommands(manager: StpaLspVscodeExtension, context: vscode.ExtensionContext, options: { extensionPrefix: string; }): void { +/** + * Register all commands that are specific to STPA. + * @param manager The manager that handles the webview panels. + * @param context The context of the extension. + * @param options The options for the commands. + */ +function registerSTPACommands( + manager: StpaLspVscodeExtension, + context: vscode.ExtensionContext, + options: { extensionPrefix: string } +): void { context.subscriptions.push( vscode.commands.registerCommand( options.extensionPrefix + ".contextTable.open", @@ -209,65 +222,93 @@ function registerSTPACommands(manager: StpaLspVscodeExtension, context: vscode.E ); } -function registerFTACommands(manager: StpaLspVscodeExtension, context: vscode.ExtensionContext, options: { extensionPrefix: string; }): void { +/** + * Register all commands that are specific to FTA. + * @param manager The manager that handles the webview panels. + * @param context The context of the extension. + * @param options The options for the commands. + */ +function registerFTACommands( + manager: StpaLspVscodeExtension, + context: vscode.ExtensionContext, + options: { extensionPrefix: string } +): void { // commands for computing and displaying the (minimal) cut sets of the fault tree. context.subscriptions.push( - vscode.commands.registerCommand(options.extensionPrefix + ".fta.cutSets", async (uri: vscode.Uri, startId?: string) => { - const cutSets: string[] = await languageClient.sendRequest("cutSets/generate", {uri: uri.path, startId}); - await manager.openDiagram(uri); - handleCutSets(manager, cutSets, false); - }) + vscode.commands.registerCommand( + options.extensionPrefix + ".fta.cutSets", + async (uri: vscode.Uri, startId?: string) => { + const cutSets: string[] = await languageClient.sendRequest("cutSets/generate", { + uri: uri.path, + startId, + }); + await manager.openDiagram(uri); + handleCutSets(cutSets, false); + } + ) ); context.subscriptions.push( - vscode.commands.registerCommand(options.extensionPrefix + ".fta.minimalCutSets", async (uri: vscode.Uri, startId?: string) => { - const minimalCutSets: string[] = await languageClient.sendRequest("cutSets/generateMinimal", {uri: uri.path, startId}); - await manager.openDiagram(uri); - handleCutSets(manager, minimalCutSets, true); - }) + vscode.commands.registerCommand( + options.extensionPrefix + ".fta.minimalCutSets", + async (uri: vscode.Uri, startId?: string) => { + const minimalCutSets: string[] = await languageClient.sendRequest("cutSets/generateMinimal", { + uri: uri.path, + startId, + }); + await manager.openDiagram(uri); + handleCutSets(minimalCutSets, true); + } + ) ); } -function handleCutSets(manager: StpaLspVscodeExtension, cutSets: string[], minimal?: boolean): void { +/** + * Handles the result of the cut set analysis. + * @param manager The manager that handles the webview panels. + * @param cutSets The cut sets that should be handled. + * @param minimal Determines whether the cut sets are minimal or not. + */ +function handleCutSets(cutSets: string[], minimal?: boolean): void { // print cut sets to output channel createOutputChannel(cutSets, "FTA Cut Sets", minimal); } function createLanguageClient(context: vscode.ExtensionContext): LanguageClient { - const serverModule = context.asAbsolutePath(path.join('pack', 'language-server')); + const serverModule = context.asAbsolutePath(path.join("pack", "language-server")); // The debug options for the server // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging. // By setting `process.env.DEBUG_BREAK` to a truthy value, the language server will wait until a debugger is attached. - const debugOptions = { execArgv: ['--nolazy', `--inspect${process.env.DEBUG_BREAK ? '-brk' : ''}=${process.env.DEBUG_SOCKET || '6009'}`] }; + const debugOptions = { + execArgv: [ + "--nolazy", + `--inspect${process.env.DEBUG_BREAK ? "-brk" : ""}=${process.env.DEBUG_SOCKET || "6009"}`, + ], + }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used const serverOptions: ServerOptions = { run: { module: serverModule, transport: TransportKind.ipc }, - debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions } + debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }, }; - const fileSystemWatcher = vscode.workspace.createFileSystemWatcher('**/*.{stpa,fta}'); + const fileSystemWatcher = vscode.workspace.createFileSystemWatcher("**/*.{stpa,fta}"); context.subscriptions.push(fileSystemWatcher); // Options to control the language client const clientOptions: LanguageClientOptions = { documentSelector: supportedFileEndings.map((ending) => ({ - scheme: 'file', + scheme: "file", language: ending, })), synchronize: { // Notify the server about file changes to files contained in the workspace - fileEvents: fileSystemWatcher - } + fileEvents: fileSystemWatcher, + }, }; // Create the language client and start the client. - const languageClient = new LanguageClient( - 'stpa', - 'stpa', - serverOptions, - clientOptions - ); + const languageClient = new LanguageClient("stpa", "stpa", serverOptions, clientOptions); // Start the client. This will also launch the server languageClient.start(); @@ -276,21 +317,21 @@ function createLanguageClient(context: vscode.ExtensionContext): LanguageClient function registerTextEditorSync(manager: StpaLspVscodeExtension, context: vscode.ExtensionContext): void { context.subscriptions.push( - vscode.workspace.onDidSaveTextDocument(async document => { + vscode.workspace.onDidSaveTextDocument(async (document) => { if (document) { manager.openDiagram(document.uri); } }) ); context.subscriptions.push( - vscode.workspace.onDidSaveTextDocument(async document => { + vscode.workspace.onDidSaveTextDocument(async (document) => { if (document) { - await languageClient.sendRequest('cutSets/reset'); + await languageClient.sendRequest("cutSets/reset"); manager.openDiagram(document.uri); if (manager.contextTable) { - languageClient.sendNotification('contextTable/getData', document.uri.toString()); + languageClient.sendNotification("contextTable/getData", document.uri.toString()); } } }) ); -} \ No newline at end of file +} diff --git a/extension/src/wview.ts b/extension/src/wview.ts index 31780146..9a54064a 100644 --- a/extension/src/wview.ts +++ b/extension/src/wview.ts @@ -71,11 +71,19 @@ export class StpaLspWebview extends LspWebviewEndpoint { this.sendAction({ kind: SendConfigAction.KIND, options: renderOptions } as SendConfigAction); } + /** + * Updates the configuration of the PASTA extension. + * @param action The action containing the configuration options. + */ protected updateConfigValues(action: SendConfigAction): void { const configOptions = vscode.workspace.getConfiguration("pasta"); action.options.forEach((element) => configOptions.update(element.id, element.value)); } + /** + * Executes the cut set analysis for the given start ID. + * @param action The action containing the start ID. + */ protected handleCutSetAnalysisAction(action: CutSetAnalysisAction): void { const uriString = this.deserializeUriOfDiagramIdentifier(); if (uriString !== "") { @@ -84,6 +92,10 @@ export class StpaLspWebview extends LspWebviewEndpoint { } } + /** + * Executes the minimal cut set analysis for the given start ID. + * @param action The action containing the start ID. + */ protected handleMinimalCutSetAnalysisAction(action: MinimalCutSetAnalysisAction): void { const uriString = this.deserializeUriOfDiagramIdentifier(); if (uriString !== "") { @@ -92,6 +104,10 @@ export class StpaLspWebview extends LspWebviewEndpoint { } } + /** + * Deserializes the URI of the diagram identifier. + * @returns the deserialized URI of the diagram identifier. + */ protected deserializeUriOfDiagramIdentifier(): string { if (this.diagramIdentifier) { let uriString = this.diagramIdentifier.uri.toString();