/NRefactory/ICSharpCode.NRefactory.VB/Lexer/Special/PreProcessingDirective.cs

http://github.com/icsharpcode/ILSpy · C# · 156 lines · 5 code · 2 blank · 149 comment · 0 complexity · 4942415df46f61def5dff648abd8ed00 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. namespace ICSharpCode.NRefactory.VB
  6. {
  7. // public class PreprocessingDirective : AbstractSpecial
  8. // {
  9. // #region Conversion C# <-> VB
  10. // public static void VBToCSharp(IList<ISpecial> list)
  11. // {
  12. // for (int i = 0; i < list.Count; ++i) {
  13. // if (list[i] is PreprocessingDirective)
  14. // list[i] = VBToCSharp((PreprocessingDirective)list[i]);
  15. // }
  16. // }
  17. //
  18. // public static PreprocessingDirective VBToCSharp(PreprocessingDirective dir)
  19. // {
  20. // string cmd = dir.Cmd;
  21. // string arg = dir.Arg;
  22. // if (cmd.Equals("#End", StringComparison.InvariantCultureIgnoreCase)) {
  23. // if (arg.ToLowerInvariant().StartsWith("region")) {
  24. // cmd = "#endregion";
  25. // arg = "";
  26. // } else if ("if".Equals(arg, StringComparison.InvariantCultureIgnoreCase)) {
  27. // cmd = "#endif";
  28. // arg = "";
  29. // }
  30. // } else if (cmd.Equals("#Region", StringComparison.InvariantCultureIgnoreCase)) {
  31. // cmd = "#region";
  32. // } else if (cmd.Equals("#If", StringComparison.InvariantCultureIgnoreCase)) {
  33. // cmd = "#if";
  34. // if (arg.ToLowerInvariant().EndsWith(" then"))
  35. // arg = arg.Substring(0, arg.Length - 5);
  36. // } else if (cmd.Equals("#Else", StringComparison.InvariantCultureIgnoreCase)) {
  37. // if (dir.Expression != null)
  38. // cmd = "#elif";
  39. // else
  40. // cmd = "#else";
  41. // } else if (cmd.Equals("#ElseIf", StringComparison.InvariantCultureIgnoreCase)) {
  42. // cmd = "#elif";
  43. // }
  44. // return new PreprocessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition) {
  45. // Expression = dir.Expression
  46. // };
  47. // }
  48. //
  49. // public static void CSharpToVB(List<ISpecial> list)
  50. // {
  51. // for (int i = 0; i < list.Count; ++i) {
  52. // if (list[i] is PreprocessingDirective)
  53. // list[i] = CSharpToVB((PreprocessingDirective)list[i]);
  54. // }
  55. // }
  56. //
  57. // public static PreprocessingDirective CSharpToVB(PreprocessingDirective dir)
  58. // {
  59. // string cmd = dir.Cmd;
  60. // string arg = dir.Arg;
  61. // switch (cmd) {
  62. // case "#region":
  63. // cmd = "#Region";
  64. // if (!arg.StartsWith("\"")) {
  65. // arg = "\"" + arg.Trim() + "\"";
  66. // }
  67. // break;
  68. // case "#endregion":
  69. // cmd = "#End";
  70. // arg = "Region";
  71. // break;
  72. // case "#endif":
  73. // cmd = "#End";
  74. // arg = "If";
  75. // break;
  76. // case "#if":
  77. // arg += " Then";
  78. // break;
  79. // }
  80. // if (cmd.Length > 1) {
  81. // cmd = cmd.Substring(0, 2).ToUpperInvariant() + cmd.Substring(2);
  82. // }
  83. // return new PreprocessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition) {
  84. // Expression = dir.Expression
  85. // };
  86. // }
  87. // #endregion
  88. //
  89. // string cmd;
  90. // string arg;
  91. // Ast.Expression expression = Ast.Expression.Null;
  92. //
  93. // /// <summary>
  94. // /// Gets the directive name, including '#'.
  95. // /// </summary>
  96. // public string Cmd {
  97. // get {
  98. // return cmd;
  99. // }
  100. // set {
  101. // cmd = value ?? string.Empty;
  102. // }
  103. // }
  104. //
  105. // /// <summary>
  106. // /// Gets the directive argument.
  107. // /// </summary>
  108. // public string Arg {
  109. // get {
  110. // return arg;
  111. // }
  112. // set {
  113. // arg = value ?? string.Empty;
  114. // }
  115. // }
  116. //
  117. // /// <summary>
  118. // /// Gets/sets the expression (for directives that take an expression, e.g. #if and #elif).
  119. // /// </summary>
  120. // public Ast.Expression Expression {
  121. // get { return expression; }
  122. // set { expression = value ?? Ast.Expression.Null; }
  123. // }
  124. //
  125. // /// <value>
  126. // /// The end position of the pre processor directive line.
  127. // /// May be != EndPosition.
  128. // /// </value>
  129. // public Location LastLineEnd {
  130. // get;
  131. // set;
  132. // }
  133. //
  134. //
  135. // public override string ToString()
  136. // {
  137. // return String.Format("[PreProcessingDirective: Cmd = {0}, Arg = {1}]",
  138. // Cmd,
  139. // Arg);
  140. // }
  141. //
  142. // public PreprocessingDirective(string cmd, string arg, Location start, Location end)
  143. // : base(start, end)
  144. // {
  145. // this.Cmd = cmd;
  146. // this.Arg = arg;
  147. // }
  148. //
  149. // public override object AcceptVisitor(ISpecialVisitor visitor, object data)
  150. // {
  151. // return visitor.Visit(this, data);
  152. // }
  153. // }
  154. }