Skip to content

Commit

Permalink
Merge pull request #35 from kieler/34-referencing-of-subcomponents-in…
Browse files Browse the repository at this point in the history
…-control-structure-not-possible

referencing of subcomponents possible
  • Loading branch information
Drakae authored Jun 3, 2024
2 parents f1cec56 + f479e7e commit 389d4da
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions extension/src-language-server/stpa/stpa-scopeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
Node,
Rule,
SystemConstraint,
SystemResponsibilities,
UCA,
Variable,
VerticalEdge,
Expand Down Expand Up @@ -106,7 +107,14 @@ export class StpaScopeProvider extends DefaultScopeProvider {
return this.getCAs(node, precomputed);
} else if ((isContext(node) || isDCAContext(node)) && referenceType === this.VAR_TYPE) {
return this.getVars(node, precomputed);
} else if (isVerticalEdge(node) && referenceType === this.NODE_TYPE) {
} else if (
(isVerticalEdge(node) ||
isSystemResponsibilities(node) ||
isActionUCAs(node) ||
isRule(node) ||
isDCARule(node)) &&
referenceType === this.NODE_TYPE
) {
return this.getNodes(node, precomputed);
} else {
return this.getStandardScope(node, referenceType, precomputed);
Expand Down Expand Up @@ -178,16 +186,30 @@ export class StpaScopeProvider extends DefaultScopeProvider {
* @param precomputed Precomputed Scope of the document.
* @returns scope containing all nodes of the control structure.
*/
protected getNodes(node: VerticalEdge, precomputed: PrecomputedScopes): Scope {
let graph: Node | Graph = node.$container;
while (graph && !isGraph(graph)) {
graph = graph.$container;
protected getNodes(
node: VerticalEdge | SystemResponsibilities | ActionUCAs | Rule | DCARule,
precomputed: PrecomputedScopes
): Scope {
const graph = this.getGraph(node);
if (!graph) {
return EMPTY_SCOPE;
}

const allDescriptions = this.getChildrenNodes(graph.nodes, precomputed);
return this.descriptionsToScope(allDescriptions);
}

protected getGraph(node: VerticalEdge | SystemResponsibilities | ActionUCAs | Rule | DCARule): Graph | undefined {
if (isVerticalEdge(node)) {
let graph: Node | Graph = node.$container;
while (graph && !isGraph(graph)) {
graph = graph.$container;
}
return graph as Graph;
} else if (isSystemResponsibilities(node) || isActionUCAs(node) || isRule(node) || isDCARule(node)) {
return node.$container.controlStructure;
}
}

/**
* Collects the descriptions of all {@code nodes} and their children.
* @param nodes The nodes for which the descriptions should be collected.
Expand Down

0 comments on commit 389d4da

Please sign in to comment.