All files / views/trees/definition-tree/nodes/shapes shape-node.ts

100% Statements 22/22
100% Branches 4/4
100% Functions 8/8
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 65 66 67 68 69 70                    4x 4x   4x 2x 2x     4x 4x   4x       1x       1x       1x               4x 4x   4x 2x 2x     4x 4x   4x       1x           1x       2x      
import * as vscode from "vscode";
import { _SH, NamedNode, BlankNode } from "@faubulous/mentor-rdf";
import { DefinitionTreeNode } from "../../definition-tree-node";
import { ClassNodeBase } from "../classes/class-node-base";
import { PropertyNode } from "../properties/property-node";
 
export class NodeShapeNode extends ClassNodeBase {
	override getIcon() {
		let classIri: string | undefined;
 
		const id = this.uri.includes(':') ? new NamedNode(this.uri) : new BlankNode(this.uri);
		const targets = this.vocabulary.getShapeTargets(this.getDocumentGraphs(), id);
 
		for (const target of targets) {
			classIri = target;
			break;
		}
 
		const iconName = this.getIconNameFromClass(classIri);
		const iconColor = this.getIconColorFromClass(classIri);
 
		return new vscode.ThemeIcon(iconName, iconColor);
	}
 
	override getChildren(): DefinitionTreeNode[] {
		return [];
	}
 
	override getClassNode(iri: string): DefinitionTreeNode {
		return this.createChildNode(DefinitionTreeNode, iri);
	}
 
	override getIndividualNode(iri: string): DefinitionTreeNode {
		return this.createChildNode(DefinitionTreeNode, iri);
	}
}
 
export class PropertyShapeNode extends PropertyNode {
	override getIcon() {
		let rangeIri: string | undefined;
 
		const id = this.uri.includes(':') ? new NamedNode(this.uri) : new BlankNode(this.uri);
		const targets = this.vocabulary.getShapeTargets(this.getDocumentGraphs(), id);
 
		for (const target of targets) {
			rangeIri = this.getRange(target);
			break;
		}
 
		const iconName = this.getIconNameFromRange(rangeIri);
		const iconColor = this.getIconColorFromRange(rangeIri);
 
		return new vscode.ThemeIcon(iconName, iconColor);
	}
 
	override getChildren() {
		return [];
	}
}
 
export class ParameterNode extends DefinitionTreeNode {
	override getIcon() {
		return new vscode.ThemeIcon('mention', this.getIconColor());
	}
 
	override getIconColor() {
		return new vscode.ThemeColor("mentor.color.class");
	}
}