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 | 1x 1x 1x 1x 1x 1x 1x 12x 2x 10x 20x 20x 20x 17x 17x 6x 3x 3x 2x 20x 1x 6x 6x 4x 3x 3x 2x 2x 2x 1x 3x 2x | import * as vscode from "vscode";
import { TreeNode, sortByLabel } from "@src/views/trees/tree-node";
import { DefinitionTreeNode } from "../../definition-tree-node";
import { IndividualNode } from "./individual-node";
import { IndividualClassNode } from "./individual-class-node";
/**
* Node of a class instance in the definition tree.
*/
export class IndividualsNode extends IndividualClassNode {
override getContextValue(): string {
return 'individuals';
}
override getIcon() {
return undefined;
}
override getLabel(): vscode.TreeItemLabel {
return { label: 'Individuals' };
}
override getDescription(): string {
const graphs = this.getDocumentGraphs();
const options = this.getQueryOptions();
const individuals = this.vocabulary.getIndividuals(graphs, undefined, options);
return [...individuals].length.toString();
}
override hasChildren(): boolean {
for (const _ of this.getChildren()) {
return true;
}
return false;
}
override getChildren(): TreeNode[] {
const result = [];
const showIndividualTypes = this.settings.get('view.showIndividualTypes', true);
if (showIndividualTypes) {
const types = this.vocabulary.getIndividualTypes(this.getOntologyGraphs(), undefined, this.getQueryOptions());
for (let t of types) {
result.push(this.createChildNode(IndividualClassNode, t));
}
} else {
const individuals = this.vocabulary.getIndividuals(this.getDocumentGraphs(), undefined, this.getQueryOptions());
for (let i of individuals) {
result.push(this.createChildNode(IndividualNode, i));
}
}
return sortByLabel(result);
}
override getTooltip(): vscode.MarkdownString | undefined {
return undefined;
}
override resolveNodeForUri(iri: string): DefinitionTreeNode | undefined {
const children = this.getChildren() as DefinitionTreeNode[];
if (this.settings.get('view.showIndividualTypes', true)) {
// Individuals are grouped by type — find the matching type node, then the individual within it.
for (const typeIri of this.vocabulary.getIndividualTypes(this.getDocumentGraphs(), iri)) {
const typeNode = children.find(n => n.uri === typeIri);
if (typeNode) {
const instances = typeNode.getChildren() as DefinitionTreeNode[];
const found = instances.find(n => n.uri === iri);
if (found) {
return found;
}
}
}
return undefined;
}
// Flat list — direct lookup.
return children.find(n => n.uri === iri);
}
} |