Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 1x 1x 1x 5x 3x 3x 3x 3x 2x 4x 2x 1x 4x | import * as vscode from "vscode";
import { SH } from "@faubulous/mentor-rdf";
import { DefinitionTreeNode } from "../../definition-tree-node";
import { RuleClassNode } from "./rule-class-node";
/**
* Node of a SHACL rule in the definition tree.
*/
export class RulesNode extends RuleClassNode {
override getContextValue() {
return 'rules';
}
override getIcon() {
return undefined;
}
override getLabel() {
return { label: "Rules" };
}
override getDescription(): string {
const graphs = this.getDocumentGraphs();
const options = this.getQueryOptions();
const rules = this.vocabulary.getRules(graphs, options);
return [...rules].length.toString();
}
override getTooltip(): vscode.MarkdownString | undefined {
return undefined;
}
override resolveNodeForUri(iri: string): DefinitionTreeNode | undefined {
const graphs = this.getOntologyGraphs();
const options = this.getQueryOptions();
if (this.vocabulary.hasType(graphs, iri, SH.Rule)) {
const rootToTarget = [...this.vocabulary.getRootShapePath(graphs, iri, options)].reverse();
rootToTarget.push(iri);
return this.walkHierarchyPath(rootToTarget);
}
for (const typeIri of this.vocabulary.getIndividualTypes(graphs, iri)) {
const rootToType = [...this.vocabulary.getRootShapePath(graphs, typeIri, options)].reverse();
rootToType.push(typeIri);
const typeNode = this.walkHierarchyPath(rootToType);
if (typeNode) {
const instances = typeNode.getChildren() as DefinitionTreeNode[];
const found = instances.find(n => n.uri === iri);
if (found) {
return found;
}
}
}
return undefined;
}
} |