import * as vscode from 'vscode';
import { FileChangeNode } from './fileChangeNode';
import { TreeNode, TreeNodeParent } from './treeNode';

export class DiffGroupNode extends TreeNode implements vscode.TreeItem {
	public collapsibleState: vscode.TreeItemCollapsibleState;
	public children: (FileChangeNode | DiffGroupNode)[] = [];

	constructor(public parent: TreeNodeParent, public label: string) {
		super();
		this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
	}

	public addFiles(files: FileChangeNode[]) {
		this.children = [...files];
		this.children.forEach(child => {
			child.parent = this;
		});
	}

	async getChildren(): Promise<TreeNode[]> {
		return Promise.resolve(this.children);
	}

	getTreeItem(): vscode.TreeItem {
		return this;
	}
}
