From 7391c6b0f2b6b7b23920448efe109f3e3f7fda95 Mon Sep 17 00:00:00 2001 From: Jette Petzold Date: Mon, 18 Sep 2023 17:33:12 +0200 Subject: [PATCH] mka feedback --- extension/src-language-server/handler.ts | 32 ++++++++++--- extension/src-language-server/stpa.langium | 18 +++---- .../src-language-server/stpa/ID-enforcer.ts | 8 ++-- .../stpa/diagram/diagram-generator.ts | 14 +++--- .../stpa/diagram/filtering.ts | 8 ++-- .../src-language-server/stpa/diagram/utils.ts | 6 +-- .../stpa/result-report/result-generator.ts | 10 ++-- .../stpa/result-report/svg-generator.ts | 47 ++++--------------- .../stpa/stpa-scopeProvider.ts | 10 ++-- .../stpa/stpa-validator.ts | 16 +++---- extension/src-language-server/stpa/utils.ts | 16 +++---- extension/src-webview/actions.ts | 1 + extension/src-webview/exportPostProcessor.ts | 1 + extension/src/report/md-export.ts | 8 ++-- extension/src/report/utils.ts | 2 +- 15 files changed, 94 insertions(+), 103 deletions(-) diff --git a/extension/src-language-server/handler.ts b/extension/src-language-server/handler.ts index bd373363..014e3f39 100644 --- a/extension/src-language-server/handler.ts +++ b/extension/src-language-server/handler.ts @@ -28,7 +28,7 @@ import { elementWithName } from "./stpa/utils"; */ export function addNotificationHandler(connection: Connection, shared: LangiumSprottySharedServices): void { // diagram - connection.onNotification('diagram/selected', async (msg: {label: string, uri: string}) => { + connection.onNotification("diagram/selected", async (msg: { label: string; uri: string }) => { // get the current model const model = await getModel(msg.uri, shared); @@ -36,14 +36,19 @@ export function addNotificationHandler(connection: Connection, shared: LangiumSp const range = getRangeOfNode(model, msg.label); if (range) { // notify extension to highlight the range in the editor - connection.sendNotification('editor/highlight', ({ startLine: range.start.line, startChar: range.start.character, endLine: range.end.line, endChar: range.end.character, uri: msg.uri })); + connection.sendNotification("editor/highlight", { + startLine: range.start.line, + startChar: range.start.character, + endLine: range.end.line, + endChar: range.end.character, + uri: msg.uri, + }); } else { console.log("The selected UCA could not be found in the editor."); } }); } - /** * Determines the range of the component identified by {@code label} in the editor, * @param model The current STPA model. @@ -52,16 +57,29 @@ export function addNotificationHandler(connection: Connection, shared: LangiumSp */ function getRangeOfNode(model: Model, label: string): Range | undefined { let range: Range | undefined = undefined; - const elements: elementWithName[] = [...model.losses, ...model.hazards, ...model.hazards.flatMap(hazard => hazard.subComps), ...model.systemLevelConstraints, ...model.systemLevelConstraints.flatMap(constraint => constraint.subComps), ...model.responsibilities.flatMap(resp => resp.responsiblitiesForOneSystem), - ...model.allUCAs.flatMap(ucas => ucas.providingUcas.concat(ucas.notProvidingUcas, ucas.wrongTimingUcas, ucas.continousUcas)), ...model.rules.flatMap(rule => rule.contexts), ...model.controllerConstraints, ...model.scenarios, ...model.safetyCons]; + const elements: elementWithName[] = [ + ...model.losses, + ...model.hazards, + ...model.hazards.flatMap((hazard) => hazard.subComponents), + ...model.systemLevelConstraints, + ...model.systemLevelConstraints.flatMap((constraint) => constraint.subComponents), + ...model.responsibilities.flatMap((resp) => resp.responsiblitiesForOneSystem), + ...model.allUCAs.flatMap((ucas) => + ucas.providingUcas.concat(ucas.notProvidingUcas, ucas.wrongTimingUcas, ucas.continousUcas) + ), + ...model.rules.flatMap((rule) => rule.contexts), + ...model.controllerConstraints, + ...model.scenarios, + ...model.safetyCons, + ]; if (model.controlStructure) { elements.push(...model.controlStructure.nodes); } - elements.forEach(component => { + elements.forEach((component) => { if (component.name === label) { range = component.$cstNode?.range; return; } }); return range; -} \ No newline at end of file +} diff --git a/extension/src-language-server/stpa.langium b/extension/src-language-server/stpa.langium index f309f699..63a8c5c5 100644 --- a/extension/src-language-server/stpa.langium +++ b/extension/src-language-server/stpa.langium @@ -22,10 +22,10 @@ entry Model: ('Hazards' hazards+=Hazard*)? ('SystemConstraints' systemLevelConstraints+=SystemConstraint*)? ('ControlStructure' controlStructure=Graph)? - ('Responsibilities' responsibilities+=Resps*)? + ('Responsibilities' responsibilities+=SystemResponsibilities*)? (('UCAs' allUCAs+=ActionUCAs*) | ('Context-Table' rules+=Rule*))? ('DCAs' allDCAs+=DCARule*)? - ('ControllerConstraints' controllerConstraints+=ContConstraint*)? + ('ControllerConstraints' controllerConstraints+=ControllerConstraint*)? ('LossScenarios' scenarios+=LossScenario*)? ('SafetyRequirements' safetyCons+=SafetyConstraint*)?; @@ -48,14 +48,14 @@ Loss: Hazard: name=SubID description=STRING ('['refs+=[Loss] (',' refs+=[Loss])*']')? - ('{' (header=STRING? subComps+=Hazard+)*'}')?; + ('{' (header=STRING? subComponents+=Hazard+)*'}')?; SystemConstraint: name=SubID description=STRING '[' refs+=[Hazard:SubID] (',' refs+=[Hazard:SubID])* ']' - ('{' (header=STRING? subComps+=SystemConstraint+)*'}')?; + ('{' (header=STRING? subComponents+=SystemConstraint+)*'}')?; Graph: name=ID '{'(nodes+=Node /* | edges+=Edge */)*'}'; @@ -67,8 +67,8 @@ Node: ('processModel' '{'variables+=Variable*'}')? ('input' '[' inputs+=Command (',' inputs+=Command)* ']')? ('output' '[' outputs+=Command (',' outputs+=Command)* ']')? - ('controlActions' '{'actions+=VE*'}')? - ('feedback' '{'feedbacks+=VE*'}')? + ('controlActions' '{'actions+=VerticalEdge*'}')? + ('feedback' '{'feedbacks+=VerticalEdge*'}')? '}'; /* Edge: @@ -85,13 +85,13 @@ VariableValue: firstValue=(QualifiedName | INT | 'MIN' | 'true' | 'false') (',' secondValue=(QualifiedName | INT | 'MAX'))? secondParenthesis=(']'|')'))?; -VE: +VerticalEdge: '[' comms+=Command (',' comms+=Command)* ']' '->' target=[Node]; Command: name=ID label=STRING; -Resps: +SystemResponsibilities: system=[Node] '{'responsiblitiesForOneSystem+=Responsibility*'}'; Responsibility: @@ -123,7 +123,7 @@ DCARule: DCAContext: name=ID '['vars+=[Variable] '=' values+=QualifiedName (',' vars+=[Variable] '=' values+=QualifiedName)*']'; -ContConstraint: +ControllerConstraint: name=ID description=STRING '['refs+=[UCA] (',' refs+=[UCA])*']'; LossScenario: diff --git a/extension/src-language-server/stpa/ID-enforcer.ts b/extension/src-language-server/stpa/ID-enforcer.ts index 920581d4..ed379138 100644 --- a/extension/src-language-server/stpa/ID-enforcer.ts +++ b/extension/src-language-server/stpa/ID-enforcer.ts @@ -277,9 +277,9 @@ export class IDEnforcer { edits = edits.concat(edit.changes[this.currentUri]); } // rename children - if ((isHazard(element) || isSystemConstraint(element)) && element.subComps.length !== 0) { + if ((isHazard(element) || isSystemConstraint(element)) && element.subComponents.length !== 0) { let index = 1; - for (const child of element.subComps) { + for (const child of element.subComponents) { edits = edits.concat(await this.renameID(child, prefix + counter + ".", index)); index++; } @@ -380,8 +380,8 @@ export class IDEnforcer { // check whether the children are affected // if the children are affected, it must be checked whether they have again affected children // otherwise the current elements are the affected ones - if (element.subComps.length !== 0 && element.subComps[0].$cstNode && element.subComps[0].$cstNode.offset <= offset) { - const modified = this.findAffectedSubComponents(element.subComps, element.name + ".", offset); + if (element.subComponents.length !== 0 && element.subComponents[0].$cstNode && element.subComponents[0].$cstNode.offset <= offset) { + const modified = this.findAffectedSubComponents(element.subComponents, element.name + ".", offset); elements = modified.elements; prefix = modified.prefix; } diff --git a/extension/src-language-server/stpa/diagram/diagram-generator.ts b/extension/src-language-server/stpa/diagram/diagram-generator.ts index 2c99cb54..eb3aadaa 100644 --- a/extension/src-language-server/stpa/diagram/diagram-generator.ts +++ b/extension/src-language-server/stpa/diagram/diagram-generator.ts @@ -25,7 +25,7 @@ import { Model, Node, SystemConstraint, - VE, + VerticalEdge, isContext, isHazard, isSystemConstraint, @@ -128,7 +128,7 @@ export class StpaDiagramGenerator extends LangiumDiagramGenerator { ) .flat(1), ...filteredModel.systemLevelConstraints - ?.map((sc) => sc.subComps?.map((ssc) => this.generateEdgesForSTPANode(ssc, args))) + ?.map((sc) => sc.subComponents?.map((ssc) => this.generateEdgesForSTPANode(ssc, args))) .flat(2), ]); } @@ -296,7 +296,7 @@ export class StpaDiagramGenerator extends LangiumDiagramGenerator { * @param args GeneratorContext of the STPA model. * @returns A list of edges representing the commands. */ - protected translateCommandsToEdges(commands: VE[], edgetype: EdgeType, args: GeneratorContext): CSEdge[] { + protected translateCommandsToEdges(commands: VerticalEdge[], edgetype: EdgeType, args: GeneratorContext): CSEdge[] { const idCache = args.idCache; const edges: CSEdge[] = []; for (const edge of commands) { @@ -495,16 +495,16 @@ export class StpaDiagramGenerator extends LangiumDiagramGenerator { isContext(node) ? createUCAContextDescription(node) : node.description ); // if the hierarchy option is true, the subcomponents are added as children to the parent - if (this.options.getHierarchy() && isHazard(node) && node.subComps.length !== 0) { + if (this.options.getHierarchy() && isHazard(node) && node.subComponents.length !== 0) { // adds subhazards children = children.concat( - node.subComps?.map((sc: Hazard) => this.generateSTPANode(sc, showDescription, args)) + node.subComponents?.map((sc: Hazard) => this.generateSTPANode(sc, showDescription, args)) ); } - if (this.options.getHierarchy() && isSystemConstraint(node) && node.subComps.length !== 0) { + if (this.options.getHierarchy() && isSystemConstraint(node) && node.subComponents.length !== 0) { // adds subconstraints children = children.concat( - node.subComps?.map((sc: SystemConstraint) => this.generateSTPANode(sc, showDescription, args)) + node.subComponents?.map((sc: SystemConstraint) => this.generateSTPANode(sc, showDescription, args)) ); } diff --git a/extension/src-language-server/stpa/diagram/filtering.ts b/extension/src-language-server/stpa/diagram/filtering.ts index 95da2b27..8bbad680 100644 --- a/extension/src-language-server/stpa/diagram/filtering.ts +++ b/extension/src-language-server/stpa/diagram/filtering.ts @@ -17,13 +17,13 @@ import { ActionUCAs, - ContConstraint, + ControllerConstraint, Graph, Hazard, Loss, LossScenario, Model, - Resps, + SystemResponsibilities, Rule, SafetyConstraint, SystemConstraint, @@ -37,9 +37,9 @@ export class CustomModel { losses: Loss[] = []; hazards: Hazard[] = []; systemLevelConstraints: SystemConstraint[] = []; - responsibilities: Resps[] = []; + responsibilities: SystemResponsibilities[] = []; allUCAs: ActionUCAs[] = []; - controllerConstraints: ContConstraint[] = []; + controllerConstraints: ControllerConstraint[] = []; scenarios: LossScenario[] = []; safetyCons: SafetyConstraint[] = []; controlStructure?: Graph; diff --git a/extension/src-language-server/stpa/diagram/utils.ts b/extension/src-language-server/stpa/diagram/utils.ts index d9c7a292..ae4fa590 100644 --- a/extension/src-language-server/stpa/diagram/utils.ts +++ b/extension/src-language-server/stpa/diagram/utils.ts @@ -19,7 +19,7 @@ import { AstNode } from "langium"; import { Context, Node, - isContConstraint, + isControllerConstraint, isContext, isHazard, isLoss, @@ -42,7 +42,7 @@ import { groupValue } from "./synthesis-options"; export function getTargets(node: AstNode, hierarchy: boolean): AstNode[] { if (node) { const targets: AstNode[] = []; - if (isHazard(node) || isResponsibility(node) || isSystemConstraint(node) || isContConstraint(node) || isSafetyConstraint(node)) { + if (isHazard(node) || isResponsibility(node) || isSystemConstraint(node) || isControllerConstraint(node) || isSafetyConstraint(node)) { for (const ref of node.refs) { if (ref?.ref) { targets.push(ref.ref); } } @@ -239,7 +239,7 @@ export function getAspect(node: AstNode): STPAAspect { return STPAAspect.UCA; } else if (isResponsibility(node)) { return STPAAspect.RESPONSIBILITY; - } else if (isContConstraint(node)) { + } else if (isControllerConstraint(node)) { return STPAAspect.CONTROLLERCONSTRAINT; } else if (isLossScenario(node)) { return STPAAspect.SCENARIO; diff --git a/extension/src-language-server/stpa/result-report/result-generator.ts b/extension/src-language-server/stpa/result-report/result-generator.ts index 5d1f6fc1..e25d2258 100644 --- a/extension/src-language-server/stpa/result-report/result-generator.ts +++ b/extension/src-language-server/stpa/result-report/result-generator.ts @@ -19,7 +19,7 @@ import { AstNode, Reference } from "langium"; import { LangiumSprottySharedServices } from "langium-sprotty"; import { ActionUCAs, - ContConstraint, + ControllerConstraint, Hazard, LossScenario, Responsibility, @@ -66,7 +66,7 @@ export async function createResultData(uri: string, shared: LangiumSprottyShared }); // safety constraints - result.safetyCons = createResultComponents(model.safetyCons); + result.safetyConstraints = createResultComponents(model.safetyCons); // responsibilities model.responsibilities.forEach((component) => { @@ -128,7 +128,7 @@ function createSingleListComponent(component: LossScenario | UCA): StpaComponent * @returns the result components for the given {@code components}. */ function createResultComponents( - components: Hazard[] | SystemConstraint[] | ContConstraint[] | SafetyConstraint[] | Responsibility[] + components: Hazard[] | SystemConstraint[] | ControllerConstraint[] | SafetyConstraint[] | Responsibility[] ): StpaComponent[] { const resultList: StpaComponent[] = []; components.forEach((component) => { @@ -146,7 +146,7 @@ function createHazardOrSystemConstraintComponents(components: Hazard[] | SystemC const resultList: StpaComponent[] = []; components.forEach((component) => { const resultComponent = createSingleComponent(component); - resultComponent.subComponents = createHazardOrSystemConstraintComponents(component.subComps); + resultComponent.subComponents = createHazardOrSystemConstraintComponents(component.subComponents); resultList.push(resultComponent); }); return resultList; @@ -158,7 +158,7 @@ function createHazardOrSystemConstraintComponents(components: Hazard[] | SystemC * @returns the result component for the given {@code component}. */ function createSingleComponent( - component: Hazard | SystemConstraint | ContConstraint | SafetyConstraint | Responsibility + component: Hazard | SystemConstraint | ControllerConstraint | SafetyConstraint | Responsibility ): StpaComponent { return { id: component.name, diff --git a/extension/src-language-server/stpa/result-report/svg-generator.ts b/extension/src-language-server/stpa/result-report/svg-generator.ts index 5fabe1cc..803b8496 100644 --- a/extension/src-language-server/stpa/result-report/svg-generator.ts +++ b/extension/src-language-server/stpa/result-report/svg-generator.ts @@ -146,34 +146,11 @@ export function setFilteredUcaGraphOptions(options: StpaSynthesisOptions, value: options.setHideSafetyConstraints(true); } -export function setUcaGraphOptions(options: StpaSynthesisOptions): void { - options.setShowRelationshipGraph(true); - options.setShowControlStructure(false); - options.setFilteringUCAs("all UCAs"); - options.setHideSysCons(true); - options.setHideResps(false); - options.setHideUCAs(false); - options.setHideContCons(true); - options.setHideScenarios(true); - options.setHideSafetyConstraints(true); -} - /** - * Sets the values of {@code options} such that the relationship graph is reduced to the controller constraints without system-level constraints. + * Sets the values of {@code options} such that the relationship graph is reduced to the controller constraints without + * system-level constraints. The relationship graph is filtered based on {@code value} for the UCA filter. * @param options The synthesis options. */ -export function setControllerConstraintGraphOptions(options: StpaSynthesisOptions): void { - options.setShowRelationshipGraph(true); - options.setShowControlStructure(false); - options.setFilteringUCAs("all UCAs"); - options.setHideSysCons(true); - options.setHideResps(false); - options.setHideUCAs(false); - options.setHideContCons(false); - options.setHideScenarios(true); - options.setHideSafetyConstraints(true); -} - export function setControllerConstraintWithFilteredUcaGraphOptions(options: StpaSynthesisOptions, value: string): void { options.setShowRelationshipGraph(true); options.setShowControlStructure(false); @@ -187,21 +164,10 @@ export function setControllerConstraintWithFilteredUcaGraphOptions(options: Stpa } /** - * Sets the values of {@code options} such that the relationship graph is reduced to the loss scenarios without system-level constraints. + * Sets the values of {@code options} such that the relationship graph is reduced to the loss scenarios without + * system-level constraints. The relationship graph is filtered based on {@code value} for the UCA filter. * @param options The synthesis options. */ -function setScenarioGraphOptions(options: StpaSynthesisOptions): void { - options.setShowRelationshipGraph(true); - options.setShowControlStructure(false); - options.setFilteringUCAs("all UCAs"); - options.setHideSysCons(true); - options.setHideResps(false); - options.setHideUCAs(false); - options.setHideContCons(false); - options.setHideScenarios(false); - options.setHideSafetyConstraints(true); -} - export function setScenarioWithFilteredUCAGraphOptions(options: StpaSynthesisOptions, value: string): void { options.setShowRelationshipGraph(true); options.setShowControlStructure(false); @@ -215,6 +181,11 @@ export function setScenarioWithFilteredUCAGraphOptions(options: StpaSynthesisOpt options.setHideSafetyConstraints(true); } +/** + * Sets the values of {@code options} such that the relationship graph is reduced to the loss scenarios that are not + * connected to a UCA without system-level constraints. + * @param options The synthesis options. + */ export function setScenarioWithNoUCAGraphOptions(options: StpaSynthesisOptions): void { options.setShowRelationshipGraph(true); options.setShowControlStructure(false); diff --git a/extension/src-language-server/stpa/stpa-scopeProvider.ts b/extension/src-language-server/stpa/stpa-scopeProvider.ts index 5a41cbfe..8779c687 100644 --- a/extension/src-language-server/stpa/stpa-scopeProvider.ts +++ b/extension/src-language-server/stpa/stpa-scopeProvider.ts @@ -27,7 +27,7 @@ import { getDocument, stream } from "langium"; -import { ActionUCAs, Command, Context, DCAContext, DCARule, Hazard, LossScenario, Model, Node, Rule, SystemConstraint, UCA, Variable, isActionUCAs, isContConstraint, isContext, isDCAContext, isDCARule, isHazardList, isLossScenario, isModel, isResponsibility, isResps, isRule, isSafetyConstraint, isSystemConstraint } from "../generated/ast"; +import { ActionUCAs, Command, Context, DCAContext, DCARule, Hazard, LossScenario, Model, Node, Rule, SystemConstraint, UCA, Variable, isActionUCAs, isControllerConstraint, isContext, isDCAContext, isDCARule, isHazardList, isLossScenario, isModel, isResponsibility, isSystemResponsibilities, isRule, isSafetyConstraint, isSystemConstraint } from "../generated/ast"; import { StpaServices } from "./stpa-module"; @@ -56,7 +56,7 @@ export class StpaScopeProvider extends DefaultScopeProvider { } if (precomputed && model) { // determine the scope for the different aspects & reference types - if ((isContConstraint(node) || isLossScenario(node) || isSafetyConstraint(node)) && (referenceType === this.UCA_TYPE || referenceType === this.CONTEXT_TYPE)) { + if ((isControllerConstraint(node) || isLossScenario(node) || isSafetyConstraint(node)) && (referenceType === this.UCA_TYPE || referenceType === this.CONTEXT_TYPE)) { return this.getUCAs(model, precomputed); } else if (isHazardList(node) && isLossScenario(node.$container) && node.$container.uca && referenceType === this.HAZARD_TYPE) { return this.getUCAHazards(node.$container, model, precomputed); @@ -86,7 +86,7 @@ export class StpaScopeProvider extends DefaultScopeProvider { private getStandardScope(node: AstNode, referenceType: string, precomputed: PrecomputedScopes): Scope { let currentNode: AstNode | undefined = node; // responsibilities, UCAs, and DCAs should have references to the nodes in the control structure - if ((isResps(node) || isActionUCAs(node) || isRule(node) || isDCARule(node)) && referenceType === Node) { + if ((isSystemResponsibilities(node) || isActionUCAs(node) || isRule(node) || isDCARule(node)) && referenceType === Node) { const model = node.$container as Model; currentNode = model.controlStructure; } @@ -183,8 +183,8 @@ export class StpaScopeProvider extends DefaultScopeProvider { let res: AstNodeDescription[] = []; for (const node of nodes) { const currentNode: AstNode | undefined = node; - if (node.subComps.length !== 0) { - res = this.getHazardSysCompsDescriptions(node.subComps, precomputed, type); + if (node.subComponents.length !== 0) { + res = this.getHazardSysCompsDescriptions(node.subComponents, precomputed, type); } res = res.concat(this.getDescriptions(currentNode, type, precomputed)); } diff --git a/extension/src-language-server/stpa/stpa-validator.ts b/extension/src-language-server/stpa/stpa-validator.ts index 76083822..a9b499ae 100644 --- a/extension/src-language-server/stpa/stpa-validator.ts +++ b/extension/src-language-server/stpa/stpa-validator.ts @@ -17,7 +17,7 @@ import { Reference, ValidationAcceptor, ValidationChecks, ValidationRegistry } from 'langium'; import { Position } from 'vscode-languageserver-types'; -import { ContConstraint, Context, Hazard, HazardList, Loss, Model, Node, Responsibility, StpaAstType, SystemConstraint, isModel } from '../generated/ast'; +import { ControllerConstraint, Context, Hazard, HazardList, Loss, Model, Node, Responsibility, StpaAstType, SystemConstraint, isModel } from '../generated/ast'; import { StpaServices } from './stpa-module'; import { collectElementsWithSubComps, elementWithName, elementWithRefs } from './utils'; @@ -33,7 +33,7 @@ export class StpaValidationRegistry extends ValidationRegistry { Hazard: validator.checkHazard, SystemConstraint: validator.checkSystemConstraint, Responsibility: validator.checkResponsibility, - ContConstraint: validator.checkControllerConstraints, + ControllerConstraint: validator.checkControllerConstraints, HazardList: validator.checkHazardList, Node: validator.checkNode, Context: validator.checkContext @@ -176,9 +176,9 @@ export class StpaValidator { * @param accept */ checkHazard(hazard: Hazard, accept: ValidationAcceptor): void { - if (hazard.subComps) { - this.checkPrefixOfSubElements(hazard.name, hazard.subComps, accept); - this.checkReferencedLossesOfSubHazard(hazard.refs, hazard.subComps, accept); + if (hazard.subComponents) { + this.checkPrefixOfSubElements(hazard.name, hazard.subComponents, accept); + this.checkReferencedLossesOfSubHazard(hazard.refs, hazard.subComponents, accept); } this.checkReferenceListForDuplicates(hazard, hazard.refs, accept); // a top-level hazard should reference loss(es) @@ -197,8 +197,8 @@ export class StpaValidator { * @param accept */ checkSystemConstraint(sysCons: SystemConstraint, accept: ValidationAcceptor): void { - if (sysCons.subComps) { - this.checkPrefixOfSubElements(sysCons.name, sysCons.subComps, accept); + if (sysCons.subComponents) { + this.checkPrefixOfSubElements(sysCons.name, sysCons.subComponents, accept); } this.checkReferenceListForDuplicates(sysCons, sysCons.refs, accept); } @@ -228,7 +228,7 @@ export class StpaValidator { * @param contCons The ContConstraint to check. * @param accept */ - checkControllerConstraints(contCons: ContConstraint, accept: ValidationAcceptor): void { + checkControllerConstraints(contCons: ControllerConstraint, accept: ValidationAcceptor): void { this.checkReferenceListForDuplicates(contCons, contCons.refs, accept); } diff --git a/extension/src-language-server/stpa/utils.ts b/extension/src-language-server/stpa/utils.ts index a18a3b18..bb1287d2 100644 --- a/extension/src-language-server/stpa/utils.ts +++ b/extension/src-language-server/stpa/utils.ts @@ -19,7 +19,7 @@ import { LangiumSharedServices } from "langium"; import { LangiumSprottySharedServices } from "langium-sprotty"; import { Command, - ContConstraint, + ControllerConstraint, Context, Graph, Hazard, @@ -42,7 +42,7 @@ export type leafElement = | SystemConstraint | Responsibility | UCA - | ContConstraint + | ControllerConstraint | LossScenario | SafetyConstraint | Context; @@ -52,7 +52,7 @@ export type elementWithName = | SystemConstraint | Responsibility | UCA - | ContConstraint + | ControllerConstraint | LossScenario | SafetyConstraint | Node @@ -66,7 +66,7 @@ export type elementWithRefs = | SystemConstraint | Responsibility | HazardList - | ContConstraint + | ControllerConstraint | SafetyConstraint; /** @@ -108,9 +108,9 @@ export function collectElementsWithSubComps(topElements: (Hazard | SystemConstra let todo = topElements; for (let i = 0; i < todo.length; i++) { const current = todo[i]; - if (current.subComps) { - result = result.concat(current.subComps); - todo = todo.concat(current.subComps); + if (current.subComponents) { + result = result.concat(current.subComponents); + todo = todo.concat(current.subComponents); } } return result; @@ -130,7 +130,7 @@ export class StpaResult { // sorted by control action and by ucas ucaScenarios: Record> = {}; scenarios: StpaComponent[] = []; - safetyCons: StpaComponent[] = []; + safetyConstraints: StpaComponent[] = []; } export class StpaComponent { diff --git a/extension/src-webview/actions.ts b/extension/src-webview/actions.ts index cd086b57..747d5306 100644 --- a/extension/src-webview/actions.ts +++ b/extension/src-webview/actions.ts @@ -64,6 +64,7 @@ export class SvgCommand extends HiddenCommand { super(); } + /** Same functionality as for the default SVGCommand provided by Sprotty. */ execute(context: CommandExecutionContext): CommandResult { if (isExportable(context.root)) { const root = context.modelFactory.createRoot(context.root); diff --git a/extension/src-webview/exportPostProcessor.ts b/extension/src-webview/exportPostProcessor.ts index 76efeb97..7db3ae38 100644 --- a/extension/src-webview/exportPostProcessor.ts +++ b/extension/src-webview/exportPostProcessor.ts @@ -22,6 +22,7 @@ import { Action } from "sprotty-protocol"; import { RequestSvgAction } from "./actions"; import { CustomSvgExporter } from "./exporter"; +/** Replaces the default SvgPostprocessor to use the custom svg exporter. */ @injectable() export class SvgPostprocessor implements IVNodePostprocessor { diff --git a/extension/src/report/md-export.ts b/extension/src/report/md-export.ts index ec277bc2..90fa1473 100644 --- a/extension/src/report/md-export.ts +++ b/extension/src/report/md-export.ts @@ -111,7 +111,7 @@ function createSTPAResultMarkdownText(data: StpaResult, diagramSizes: Record stpaComponentToMarkdown(scenario)).join(" \n") + `\n`; + markdown += scenarios.map((scenario) => stpaComponentToMarkdown(scenario)).join(" \n") + `\n\n`; markdown += `\n\n`; @@ -312,7 +312,7 @@ function ucasToMarkdown( markdown += "\n\n\n\n
\n\n"; // add the filtered diagram for the control action const path = FILTERED_UCA_PATH(actionUCA); - markdown += `\n\n

\n\n`; + markdown += `\n\n
\n\n`; } // add a diagram for all UCAs markdown += `### _All UCAs_\n\n`; @@ -365,7 +365,7 @@ function addSummary(data: StpaResult, diagramSizes: Record): str } } // add safety constraints - for (const component of data.safetyCons) { + for (const component of data.safetyConstraints) { markdown += stpaComponentToMarkdown(component); markdown += ` \n`; } diff --git a/extension/src/report/utils.ts b/extension/src/report/utils.ts index 223f92bd..0747c6a5 100644 --- a/extension/src/report/utils.ts +++ b/extension/src/report/utils.ts @@ -70,7 +70,7 @@ export class StpaResult { // sorted by control action and by ucas ucaScenarios: Record> = {}; scenarios: StpaComponent[] = []; - safetyCons: StpaComponent[] = []; + safetyConstraints: StpaComponent[] = []; } export class StpaComponent {