/// <summary> /// Get a group key from the specified node. /// </summary> /// <param name="node"></param> /// <returns></returns> public string GetGroupPathFromNode(CstNode node) { IEnumerable <string> distinctivePath; if (_extractor.IsInner) { //node = node.AncestorsOfOnlyChildAndSelf().Last(); // TODO // TODO: descendants may be empty list distinctivePath = node.DescendantsOfFirstChild() .Take(GroupKeyLength) .Select(e => e.HasToken ? e.RuleId + "-" + _extractor.GetToken(e) : e.RuleId); } else { //node = node.DescendantsOfOnlyChildAndSelf().Last(); // TODO distinctivePath = node.AncestorsAndSelf() .Take(GroupKeyLength) .Select(e => e.HasToken ? e.RuleId + "-" + _extractor.GetToken(e) : e.RuleId); } return(">" + node.Name + ">" + string.Join(">", distinctivePath) + ">"); }
/// <summary> /// Get a group key from the specified node. /// </summary> /// <param name="node"></param> /// <returns></returns> public string GetGroupPathFromNode(CstNode node) { IEnumerable<string> distinctivePath; if (_extractor.IsInner) { //node = node.AncestorsOfOnlyChildAndSelf().Last(); // TODO // TODO: descendants may be empty list distinctivePath = node.DescendantsOfFirstChild() .Take(GroupKeyLength) .Select(e => e.HasToken ? e.RuleId + "-" + _extractor.GetToken(e) : e.RuleId); } else { //node = node.DescendantsOfOnlyChildAndSelf().Last(); // TODO distinctivePath = node.AncestorsAndSelf() .Take(GroupKeyLength) .Select(e => e.HasToken ? e.RuleId + "-" + _extractor.GetToken(e) : e.RuleId); } return ">" + node.Name + ">" + string.Join(">", distinctivePath) + ">"; }