public static GraphvizTable MakeTable(TextDocument document, int offset) { DocumentLine line = GetTableHeaderLine(document, offset); if (line == null) { return(null); } GraphvizTable table = new GraphvizTable(); while (line != null) { string rowText = document.GetText(line).Trim(); var row = ToRow(rowText); if (row?.CellCount > 0) { table.Add(row); line = line.NextLine; } else { break; } } if (table.RowCount > 1) { return(table); } else { return(null); } }
private string MakeGraphvizDot(GraphvizTable table) { string contents = MakeGraphvizDotContent(table); if (string.IsNullOrEmpty(contents)) { return(null); } StringBuilder sb = new StringBuilder(); sb.Append("digraph") .Append('{') .Append(GetGraphDef()) .Append(contents) .Append('}'); return(sb.ToString()); }
private string MakeGraphvizDotContent(GraphvizTable table) { if ((table == null) || (table.RowCount < 2)) { return(null); } GraphvizTableRow header = table[0]; ShapeIndex = header.Index("Shape"); LabelIndex = header.Index("Label"); ConnIndex = header.Index("Connections"); ColorIndex = header.Index("Color"); for (int i = 1; i < table.RowCount; i++) { GraphvizTableRow row = table[i]; bool? isNode = row[0].IsDotNode(); if (!isNode.HasValue) { return(null); } if (isNode.Value) { if (row[0].Value.Contains(":")) { DotModel.Add(new GraphvizRankNode(row[0].Value)); } else { ProcessNode(row); } } else { ProcessEdge(row); } } return(DotModel.GetDotString()); }