private void RenderNode(Ust ust) { int index = currentIndex; string typeName = graphTooltipPrinter.Print(ust.GetType().Name); string labelName, tooltip; if (ust is ArgsUst || ust is BlockStatement || ust is ExpressionStatement || ust is ConditionalExpression) { labelName = typeName; tooltip = graphTooltipPrinter.Print(ust.ToString()); } else { labelName = graphNodePrinter.Print(ust.ToString()); tooltip = typeName; } vertexesString.Append($@"{index} [label=""{labelName}"""); vertexesString.Append($@", tooltip=""{tooltip}"""); /*if (ust is Token) * { * vertexesString.Append(", fillcolor=khaki, style=filled"); * } * else if (ust is Expression) * { * vertexesString.Append(", fillcolor=rosybrown1, style=filled"); * } * else if (ust is Statement) * { * vertexesString.Append(", fillcolor=skyblue1, style=filled"); * } * else if (ust is ArgsUst) * { * vertexesString.Append(", fillcolor=palegreen, style=filled"); * }*/ vertexesString.AppendLine("];"); foreach (Ust child in ust.Children) { if (child != null) { currentIndex++; edgesString.AppendEdge(index, currentIndex); RenderNode(child); } } }
public bool TryGetOrFold(Ust ust, out FoldResult result) { if (ust == null || !foldingTypes.Contains(ust.GetType())) { result = null; return(false); } lock (ust) { if (foldedResults.TryGetValue(ust.TextSpan, out result)) { return(result != null); } result = TryGetOrFold(ust); NormalizeAndAdd(ust, ref result); } return(result != null); }