All files / views/trees/definition-tree/nodes concept-scheme-node.ts

100% Statements 22/22
100% Branches 10/10
100% Functions 5/5
100% Lines 22/22

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                      1x       2x       3x   3x 1x     2x   2x 1x     1x       6x   6x   6x 3x     6x   6x 1x     6x       3x 2x   2x 1x       2x    
import * as vscode from "vscode";
import { DefinitionTreeNode } from "../definition-tree-node";
import { ConceptsNode } from "./concepts/concepts-node";
import { CollectionsNode } from "./collections/collections-node";
 
/**
 * Node of a SKOS concept scheme in the definition tree.
 */
export class ConceptSchemeNode extends DefinitionTreeNode {
	override getIcon() {
		// return undefined;
		return new vscode.ThemeIcon('rdf-concept-scheme', this.getIconColor());
	}
 
	override getIconColor() {
		return new vscode.ThemeColor("mentor.color.class");
	}
 
	override hasChildren(): boolean {
		const concepts = this.createChildNode(ConceptsNode, 'mentor:concepts', { definedBy: this.uri });
 
		if (concepts.hasChildren()) {
			return true;
		}
 
		const collections = this.createChildNode(CollectionsNode, 'mentor:collections', { definedBy: this.uri });
 
		if (collections.hasChildren()) {
			return true;
		}
 
		return false;
	}
 
	override getChildren(): DefinitionTreeNode[] {
		const result = [];
 
		const concepts = this.createChildNode(ConceptsNode, 'mentor:concepts', { definedBy: this.uri });
 
		if (concepts.hasChildren()) {
			result.push(concepts);
		}
 
		const collections = this.createChildNode(CollectionsNode, 'mentor:collections', { definedBy: this.uri });
 
		if (collections.hasChildren()) {
			result.push(collections);
		}
 
		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;
	}
}