in src/vscodeIntegration/Treeview.ts [202:251]
public getChildren(elementInfo?: IElementInfo): IElementInfo[] {
// check if there is a visible text editor
if (vscode.window.visibleTextEditors.length > 0) {
if (vscode.window.activeTextEditor && this.shouldShowTreeForDocument(vscode.window.activeTextEditor.document)) {
if (!this.tree) {
this.refresh();
throw new Error("No tree");
}
let result: IElementInfo[] = [];
if (!elementInfo) {
if (this.tree.value instanceof Json.ObjectValue) {
// tslint:disable-next-line:one-variable-per-declaration
for (let i = 0, il = this.tree.value.properties.length; i < il; i++) {
let item = this.getElementInfo(this.tree.value.properties[i]);
result.push(item);
}
}
} else {
let valueNode = elementInfo.current.value.start !== undefined ? this.tree.getValueAtCharacterIndex(elementInfo.current.value.start, ContainsBehavior.strict) : undefined;
// Value is an object and is collapsible
if (valueNode instanceof Json.ObjectValue && elementInfo.current.collapsible) {
// tslint:disable-next-line:one-variable-per-declaration
for (let i = 0, il = valueNode.properties.length; i < il; i++) {
let item = this.getElementInfo(valueNode.properties[i], elementInfo);
result.push(item);
}
} else if (valueNode instanceof Json.ArrayValue && elementInfo.current.collapsible) {
// Array with objects
// tslint:disable-next-line:one-variable-per-declaration
for (let i = 0, il = valueNode.length; i < il; i++) {
let valueElement = valueNode.elements[i];
if (valueElement instanceof Json.ObjectValue) {
let item = this.getElementInfo(valueElement, elementInfo);
result.push(item);
}
}
}
}
return result;
}
}
return [];
}