/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/SpecialNodesInserter.cs

http://github.com/icsharpcode/ILSpy · C# · 142 lines · 6 code · 2 blank · 134 comment · 0 complexity · 86202113e7dbe253aa05b89b2a4124a6 MD5 · raw file

  1. // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
  2. // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
  3. using System;
  4. using System.Collections.Generic;
  5. using ICSharpCode.NRefactory.VB.Ast;
  6. namespace ICSharpCode.NRefactory.VB.PrettyPrinter
  7. {
  8. // public class SpecialOutputVisitor : ISpecialVisitor
  9. // {
  10. // readonly IOutputFormatter formatter;
  11. //
  12. // public SpecialOutputVisitor(IOutputFormatter formatter)
  13. // {
  14. // this.formatter = formatter;
  15. // }
  16. //
  17. // public bool ForceWriteInPreviousLine;
  18. //
  19. // public object Visit(ISpecial special, object data)
  20. // {
  21. // Console.WriteLine("Warning: SpecialOutputVisitor.Visit(ISpecial) called with " + special);
  22. // return data;
  23. // }
  24. //
  25. // public object Visit(BlankLine special, object data)
  26. // {
  27. // formatter.PrintBlankLine(ForceWriteInPreviousLine);
  28. // return data;
  29. // }
  30. //
  31. // public object Visit(Comment special, object data)
  32. // {
  33. // formatter.PrintComment(special, ForceWriteInPreviousLine);
  34. // return data;
  35. // }
  36. //
  37. // public object Visit(PreprocessingDirective special, object data)
  38. // {
  39. // formatter.PrintPreprocessingDirective(special, ForceWriteInPreviousLine);
  40. // return data;
  41. // }
  42. // }
  43. //
  44. // /// <summary>
  45. // /// This class inserts specials between INodes.
  46. // /// </summary>
  47. // public sealed class SpecialNodesInserter : IDisposable
  48. // {
  49. // IEnumerator<ISpecial> enumerator;
  50. // SpecialOutputVisitor visitor;
  51. // bool available; // true when more specials are available
  52. //
  53. // public SpecialNodesInserter(IEnumerable<ISpecial> specials, SpecialOutputVisitor visitor)
  54. // {
  55. // if (specials == null) throw new ArgumentNullException("specials");
  56. // if (visitor == null) throw new ArgumentNullException("visitor");
  57. // enumerator = specials.GetEnumerator();
  58. // this.visitor = visitor;
  59. // available = enumerator.MoveNext();
  60. // }
  61. //
  62. // void WriteCurrent()
  63. // {
  64. // enumerator.Current.AcceptVisitor(visitor, null);
  65. // available = enumerator.MoveNext();
  66. // }
  67. //
  68. // AttributedNode currentAttributedNode;
  69. //
  70. // /// <summary>
  71. // /// Writes all specials up to the start position of the node.
  72. // /// </summary>
  73. // public void AcceptNodeStart(INode node)
  74. // {
  75. // if (node is AttributedNode) {
  76. // currentAttributedNode = node as AttributedNode;
  77. // if (currentAttributedNode.Attributes.Count == 0) {
  78. // AcceptPoint(node.StartLocation);
  79. // currentAttributedNode = null;
  80. // }
  81. // } else {
  82. // AcceptPoint(node.StartLocation);
  83. // }
  84. // }
  85. //
  86. // /// <summary>
  87. // /// Writes all specials up to the end position of the node.
  88. // /// </summary>
  89. // public void AcceptNodeEnd(INode node)
  90. // {
  91. // visitor.ForceWriteInPreviousLine = true;
  92. // AcceptPoint(node.EndLocation);
  93. // visitor.ForceWriteInPreviousLine = false;
  94. // if (currentAttributedNode != null) {
  95. // if (node == currentAttributedNode.Attributes[currentAttributedNode.Attributes.Count - 1]) {
  96. // AcceptPoint(currentAttributedNode.StartLocation);
  97. // currentAttributedNode = null;
  98. // }
  99. // }
  100. // }
  101. //
  102. // /// <summary>
  103. // /// Writes all specials up to the specified location.
  104. // /// </summary>
  105. // public void AcceptPoint(Location loc)
  106. // {
  107. // while (available && enumerator.Current.StartPosition <= loc) {
  108. // WriteCurrent();
  109. // }
  110. // }
  111. //
  112. // /// <summary>
  113. // /// Outputs all missing specials to the writer.
  114. // /// </summary>
  115. // public void Finish()
  116. // {
  117. // while (available) {
  118. // WriteCurrent();
  119. // }
  120. // }
  121. //
  122. // void IDisposable.Dispose()
  123. // {
  124. // Finish();
  125. // }
  126. //
  127. // /// <summary>
  128. // /// Registers a new SpecialNodesInserter with the output visitor.
  129. // /// Make sure to call Finish() (or Dispose()) on the returned SpecialNodesInserter
  130. // /// when the output is finished.
  131. // /// </summary>
  132. // public static SpecialNodesInserter Install(IEnumerable<ISpecial> specials, IOutputDomVisitor outputVisitor)
  133. // {
  134. // SpecialNodesInserter sni = new SpecialNodesInserter(specials, new SpecialOutputVisitor(outputVisitor.OutputFormatter));
  135. // outputVisitor.BeforeNodeVisit += sni.AcceptNodeStart;
  136. // outputVisitor.AfterNodeVisit += sni.AcceptNodeEnd;
  137. // return sni;
  138. // }
  139. // }
  140. }