예제 #1
0
 public override TextWithChanges ToTwcSliceAsPrettyPrint(int indentLevel, int maxColumn)
 {
     if (HasUnparsedChanges())
     {
         return base.ToTwcSliceAsPrettyPrint(indentLevel, maxColumn);
     }
     TwcBuilder result = new TwcBuilder();
     result.AddText("'");
     result.AddTwc(SubTrees[0].ToTwcSliceAsPrettyPrint(indentLevel + 1, maxColumn));
     return result.ToTwc();
 }
예제 #2
0
 public override TextWithChanges ToTwcSliceAsPrettyPrint(int indentLevel, 
                                                         int maxColumn)
 {
     if (SubTrees.Count == 0 || HasUnparsedChanges())
     {
         return base.ToTwcSliceAsPrettyPrint(indentLevel, maxColumn);
     }
     else
     {
         TwcBuilder result = new TwcBuilder();
         result.AddText("(");
         foreach (ParseTree tree in SubTrees)
         {
             result.AddTwc(tree.ToTwcSliceAsPrettyPrint(indentLevel, 100000));
             if (tree != SubTrees.Last)
             {
                 result.AddText(" ");
             }
         }
         result.AddText(")");
         if (indentLevel + result.ToTwc().GetActualLength() <= maxColumn)
         {
             return result.ToTwc();
         }
         // Second attempt, this time one child per line.
         TwcBuilder result2 = new TwcBuilder();
         result2.AddText("(");
         string separator = "\n" + new String(' ', indentLevel + 1);
         foreach (ParseTree tree in SubTrees)
         {
             result2.AddTwc(tree.ToTwcSliceAsPrettyPrint(indentLevel + 1, maxColumn));
             if (tree != SubTrees.Last)
             {
                 result2.AddText(separator);
             }
         }
         result2.AddText(")");
         return result2.ToTwc();
     }
 }