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 | 1x 1x 1x 1x 1x 1x 1x 14x 14x 14x 14x 12x 12x 2x 2x 2x 1x 11x 7x 7x 7x 7x 7x 5x 5x 3x 2x 2x 1x 7x 1x 6x 6x 1x 5x 5x 3x 5x 5x 5x 4x 2x 2x 1x 3x 1x | import * as vscode from "vscode";
import { RDF } from "@faubulous/mentor-rdf";
import { TreeNode, sortByLabel } from "@src/views/trees/tree-node";
import { DefinitionTreeNode } from "../../definition-tree-node";
import { PropertyNode } from "./property-node";
import { PropertyClassNode } from "../properties/property-class-node";
/**
* Node of a property in the definition tree.
*/
export class PropertiesNode extends PropertyClassNode {
override getContextValue(): string {
return 'properties';
}
override getIcon(): vscode.ThemeIcon | undefined {
return undefined;
}
override getLabel(): vscode.TreeItemLabel {
return { label: 'Properties' };
}
override getDescription(): string {
const graphs = this.getOntologyGraphs();
const options = this.getQueryOptions();
const properties = [...this.vocabulary.getProperties(graphs, options)];
return properties.length.toString();
}
override hasChildren(): boolean {
const graphs = this.getOntologyGraphs();
const options = this.getQueryOptions();
const showPropertyTypes = this.settings.get('view.showPropertyTypes', true);
if (showPropertyTypes) {
const types = this.vocabulary.getPropertyTypes(graphs, options);
for (const _ of types) {
return true;
}
} else {
const properties = this.vocabulary.getSubProperties(graphs, undefined, options);
for (const _ of properties) {
return true;
}
}
return false;
}
override getChildren(): TreeNode[] {
const result = [];
const graphs = this.getOntologyGraphs();
const options = this.getQueryOptions();
const showPropertyTypes = this.settings.get('view.showPropertyTypes', true);
if (showPropertyTypes) {
const types = this.vocabulary.getPropertyTypes(graphs, options);
for (let type of types) {
result.push(this.createChildNode(PropertyClassNode, type));
}
} else {
const properties = this.vocabulary.getSubProperties(graphs, undefined, options);
for (let p of properties) {
result.push(this.createChildNode(PropertyNode, p));
}
}
return sortByLabel(result);
}
override getTooltip(): vscode.MarkdownString | undefined {
return undefined;
}
override resolveNodeForUri(iri: string): DefinitionTreeNode | undefined {
const graphs = this.getOntologyGraphs();
if (!this.vocabulary.hasType(graphs, iri, RDF.Property)) {
return undefined;
}
const options = this.getQueryOptions();
if (options.includeReferenced) {
// If referenced classes are included, we want to include classes
// that are defined in other ontologies.
options.definedBy = null;
}
const rootToNode = [...this.vocabulary.getRootPropertiesPath(graphs, iri, options)].reverse();
rootToNode.push(iri);
if (this.settings.get('view.showPropertyTypes', true)) {
// Properties are grouped by type — try each type branch.
for (const typeNode of this.getChildren() as DefinitionTreeNode[]) {
const found = typeNode.walkHierarchyPath(rootToNode);
if (found) {
return found;
}
}
return undefined;
}
return this.walkHierarchyPath(rootToNode);
}
} |