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 | 10x 3x 7x 7x 3x 7x 1x 1x | import * as vscode from 'vscode';
import { any } from '@src/utilities';
import { TreeNode, sortByLabel } from "@src/views/trees/tree-node";
import { ClassNodeBase } from "../classes/class-node-base";
import { PropertyNode } from "./property-node";
/**
* Node of a property in the definition tree.
*/
export class PropertyClassNode extends ClassNodeBase {
override getResourceUri(): vscode.Uri | undefined {
return vscode.Uri.parse('mentor:properties:' + this.uri);
}
/**
* Get the IRIs of the root properties of the property type that are listed below this node.
* @returns An iterator of property IRIs.
*/
private _getRootPropertyIris(): IterableIterator<string> {
return this.vocabulary.getRootPropertiesOfType(this.getDocumentGraphs(), this.uri!, this.getQueryOptions());
}
/**
* Indicates whether the property type has root properties, stopping at the first one. This
* replaces the sub-class and instance check of {@link ClassNodeBase.hasChildren} with the
* query of {@link getChildren}, so that the node is expandable exactly if it lists properties.
* @returns `true` if the node has children, `false` otherwise.
*/
override hasChildren(): boolean {
return any(this._getRootPropertyIris());
}
override getChildren(): TreeNode[] {
const result = [];
for (const p of this._getRootPropertyIris()) {
result.push(this.createChildNode(PropertyNode, p));
}
return sortByLabel(result);
}
override getClassNode(iri: string) {
return this.createChildNode(PropertyClassNode, iri);
}
override getIndividualNode(iri: string) {
return this.createChildNode(PropertyNode, iri);
}
} |