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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 2x 26x 6x 1x 5x 1x 2x 3x 3x 2x 2x 1x 3x 2x 1x 1x 10x 10x 10x 3x 10x 10x 1x 10x 10x 1x 10x 10x 4x 10x 10x 4x 10x 10x 4x 10x 3x 5x 5x 1x 2x | import * as vscode from "vscode";
import { container } from 'tsyringe';
import { VocabularyRepository } from "@faubulous/mentor-rdf";
import { ServiceToken } from '@src/services/tokens';
import { DefinitionTreeNode } from "../definition-tree-node";
import { ClassesNode } from "./classes/classes-node";
import { PropertiesNode } from "./properties/properties-node";
import { IndividualsNode } from "./individuals/individuals-node";
import { ShapesNode } from "./shapes/shapes-node";
import { RulesNode } from "./rules/rules-node";
import { ValidatorsNode } from "./validators/validators-node";
/**
* Node of a ontology header in the definition tree.
*/
export class OntologyNode extends DefinitionTreeNode {
private get vocabulary() {
return container.resolve<VocabularyRepository>(ServiceToken.VocabularyRepository);
}
isReferenced = false;
override getLabel(): vscode.TreeItemLabel {
if (this.uri === 'mentor:unknown') {
return { label: 'Unknown' };
} else {
return super.getLabel();
}
}
override getIcon() {
// return undefined;
return new vscode.ThemeIcon('rdf-ontology', this.getIconColor());
}
override getIconColor() {
return new vscode.ThemeColor("mentor.color.class");
}
override getDescription(): string {
let result = super.getDescription();
if (this.uri) {
const version = this.vocabulary.getOntologyVersionInfo(this.getDocumentGraphs(), this.uri);
if (version) {
result += " " + version;
}
}
return result;
}
override getTooltip(): vscode.MarkdownString | undefined {
if (this.uri === 'mentor:unknown') {
return new vscode.MarkdownString('Definitions that are not associated with an ontology in this document, either via `rdfs:isDefinedBy` or via a shared namespace IRI.');
} else {
return super.getTooltip();
}
}
override getChildren(): DefinitionTreeNode[] {
const result = [];
const classes = this.createChildNode(ClassesNode, 'mentor:classes');
if (classes.hasChildren()) {
result.push(classes);
}
const properties = this.createChildNode(PropertiesNode, 'mentor:properties');
if (properties.hasChildren()) {
result.push(properties);
}
const individuals = this.createChildNode(IndividualsNode, 'mentor:individuals');
if (individuals.hasChildren()) {
result.push(individuals);
}
const shapes = this.createChildNode(ShapesNode, 'mentor:shapes', this.getQueryOptions({ includeBlankNodes: true }));
if (shapes.hasChildren()) {
result.push(shapes);
}
const rules = this.createChildNode(RulesNode, 'mentor:rules', this.getQueryOptions({ includeBlankNodes: true }));
if (rules.hasChildren()) {
result.push(rules);
}
const validators = this.createChildNode(ValidatorsNode, 'mentor:validators', this.getQueryOptions({ includeBlankNodes: true }));
if (validators.hasChildren()) {
result.push(validators);
}
return result;
}
override resolveNodeForUri(iri: string): DefinitionTreeNode | undefined {
for (const child of this.getChildren()) {
const found = child.resolveNodeForUri(iri);
if (found) {
return found;
}
}
return undefined;
}
} |