private getParentNodeInExplorer()

in src/syncHandler.ts [84:113]


    private getParentNodeInExplorer(uri: Uri): ExplorerNode | undefined {
        let node: DataNode | undefined = explorerNodeCache.findBestMatchNodeByUri(uri);

        if (!node) {
            return undefined;
        }

        if (Settings.isHierarchicalView()) {
            // TODO: has to get the hierarchical package root node due to the java side implementation
            // because currently it will only get the types for a package node but no child packages.
            while (node && node.nodeData.kind !== NodeKind.PackageRoot) {
                node = <DataNode>node.getParent();
            }
            return node;
        } else {
            // in flat view
            if (path.extname(uri.fsPath) === ".java" && node.uri &&
                    Uri.parse(node.uri).fsPath === path.dirname(uri.fsPath)) {
                // if the returned node is direct parent of the input uri, refresh it.
                return node;
            } else {
                // the direct parent is not rendered in the explorer, the returned node
                // is other package fragment, we need to refresh the package fragment root.
                while (node && node.nodeData.kind > NodeKind.PackageRoot) {
                    node = <DataNode>node.getParent();
                }
                return node;
            }
        }
    }