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