protected createChildNodeList()

in src/views/projectNode.ts [79:119]


    protected createChildNodeList(): ExplorerNode[] {

        const result: ExplorerNode[] = [];
        const packageData: any[] = [];
        if (this.nodeData.children && this.nodeData.children.length) {
            this.nodeData.children.forEach((data) => {
                if (data.kind === NodeKind.Container) {
                    result.push(new ContainerNode(data, this, this));
                } else if (data.kind === NodeKind.PackageRoot) {
                    result.push(NodeFactory.createPackageRootNode(data, this, this));
                } else if (data.kind === NodeKind.Package) {
                    // Invisible project may have an empty named package root, in that case,
                    // we will skip it.
                    packageData.push(data);
                } else if (data.kind === NodeKind.PrimaryType) {
                    // For invisible project with empty named package root with a default package,
                    // types will be the project node's children
                    if (data.metaData && data.metaData[PrimaryTypeNode.K_TYPE_KIND]) {
                        result.push(new PrimaryTypeNode(data, this, undefined));
                    }
                }
            });
        }

        if (packageData.length > 0) {
            if (Settings.isHierarchicalView()) {
                const data: HierarchicalPackageNodeData = HierarchicalPackageNodeData.createHierarchicalNodeDataByPackageList(packageData);
                const hierarchicalPackageNodes: HierarchicalPackageNode[] = data === undefined ? [] : data.children.map((hierarchicalChildrenNode) =>
                        new HierarchicalPackageNode(hierarchicalChildrenNode, this, this, this));
                result.push(...hierarchicalPackageNodes);
            } else {
                result.push(...packageData.map((data) => new PackageNode(data, this, this, this)));
            }
        }

        result.sort((a: DataNode, b: DataNode) => {
            return b.nodeData.kind - a.nodeData.kind;
        });

        return result;
    }