~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
4
using System;
 
5
using System.Linq;
 
6
using System.Collections;
 
7
using System.Collections.Generic;
 
8
using System.Diagnostics;
 
9
using System.Globalization;
 
10
using System.Text;
 
11
 
 
12
using ICSharpCode.NRefactory.VB.Ast;
 
13
using ICSharpCode.NRefactory.VB.Parser;
 
14
using ICSharpCode.NRefactory.VB.Visitors;
 
15
 
 
16
namespace ICSharpCode.NRefactory.VB.PrettyPrinter
 
17
{
 
18
//      public sealed class VBNetOutputVisitor : NodeTrackingAstVisitor, IOutputDomVisitor
 
19
//      {
 
20
//              Errors                  errors             = new Errors();
 
21
//              VBNetOutputFormatter    outputFormatter;
 
22
//              VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions();
 
23
//              TypeDeclaration         currentType;
 
24
//              
 
25
//              Stack<int> exitTokenStack = new Stack<int>();
 
26
//              
 
27
//              public string Text {
 
28
//                      get {
 
29
//                              return outputFormatter.Text;
 
30
//                      }
 
31
//              }
 
32
//              
 
33
//              public Errors Errors {
 
34
//                      get {
 
35
//                              return errors;
 
36
//                      }
 
37
//              }
 
38
//              
 
39
//              AbstractPrettyPrintOptions IOutputDomVisitor.Options {
 
40
//                      get { return prettyPrintOptions; }
 
41
//              }
 
42
//              
 
43
//              public VBNetPrettyPrintOptions Options {
 
44
//                      get { return prettyPrintOptions; }
 
45
//              }
 
46
//              
 
47
//              public IOutputFormatter OutputFormatter {
 
48
//                      get {
 
49
//                              return outputFormatter;
 
50
//                      }
 
51
//              }
 
52
//              
 
53
//              public VBNetOutputVisitor()
 
54
//              {
 
55
//                      outputFormatter = new VBNetOutputFormatter(prettyPrintOptions);
 
56
//              }
 
57
//              
 
58
//              public event Action<INode> BeforeNodeVisit;
 
59
//              public event Action<INode> AfterNodeVisit;
 
60
//              
 
61
//              protected override void BeginVisit(INode node)
 
62
//              {
 
63
//                      if (BeforeNodeVisit != null) {
 
64
//                              BeforeNodeVisit(node);
 
65
//                      }
 
66
//                      base.BeginVisit(node);
 
67
//              }
 
68
//              
 
69
//              protected override void EndVisit(INode node)
 
70
//              {
 
71
//                      base.EndVisit(node);
 
72
//                      if (AfterNodeVisit != null) {
 
73
//                              AfterNodeVisit(node);
 
74
//                      }
 
75
//              }
 
76
//              
 
77
//              object TrackedVisit(INode node, object data)
 
78
//              {
 
79
//                      return node.AcceptVisitor(this, data);
 
80
//              }
 
81
//              
 
82
//              void Error(string text, Location position)
 
83
//              {
 
84
//                      errors.Error(position.Line, position.Column, text);
 
85
//              }
 
86
//              
 
87
//              void UnsupportedNode(INode node)
 
88
//              {
 
89
//                      Error(node.GetType().Name + " is unsupported", node.StartLocation);
 
90
//              }
 
91
//              
 
92
//              #region ICSharpCode.NRefactory.Parser.IAstVisitor interface implementation
 
93
//              public override object TrackedVisitCompilationUnit(CompilationUnit compilationUnit, object data)
 
94
//              {
 
95
//                      compilationUnit.AcceptChildren(this, data);
 
96
//                      outputFormatter.EndFile();
 
97
//                      return null;
 
98
//              }
 
99
//              
 
100
//              /// <summary>
 
101
//              /// Converts type name to primitive type name. Returns typeString if typeString is not
 
102
//              /// a primitive type.
 
103
//              /// </summary>
 
104
//              static string ConvertTypeString(string typeString)
 
105
//              {
 
106
//                      string primitiveType;
 
107
//                      if (TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType))
 
108
//                              return primitiveType;
 
109
//                      else
 
110
//                              return typeString;
 
111
//              }
 
112
//
 
113
//              public override object TrackedVisitTypeReference(TypeReference typeReference, object data)
 
114
//              {
 
115
//                      if (typeReference == TypeReference.ClassConstraint) {
 
116
//                              outputFormatter.PrintToken(Tokens.Class);
 
117
//                      } else if (typeReference == TypeReference.StructConstraint) {
 
118
//                              outputFormatter.PrintToken(Tokens.Structure);
 
119
//                      } else if (typeReference == TypeReference.NewConstraint) {
 
120
//                              outputFormatter.PrintToken(Tokens.New);
 
121
//                      } else {
 
122
//                              PrintTypeReferenceWithoutArray(typeReference);
 
123
//                              if (typeReference.IsArrayType) {
 
124
//                                      PrintArrayRank(typeReference.RankSpecifier, 0);
 
125
//                              }
 
126
//                      }
 
127
//                      return null;
 
128
//              }
 
129
//              
 
130
//              void PrintTypeReferenceWithoutArray(TypeReference typeReference)
 
131
//              {
 
132
//                      if (typeReference.IsGlobal) {
 
133
//                              outputFormatter.PrintToken(Tokens.Global);
 
134
//                              outputFormatter.PrintToken(Tokens.Dot);
 
135
//                      }
 
136
//                      bool printGenerics = true;
 
137
//                      if (typeReference.IsKeyword) {
 
138
//                              outputFormatter.PrintText(ConvertTypeString(typeReference.Type));
 
139
//                      } else {
 
140
//                              outputFormatter.PrintIdentifier(typeReference.Type);
 
141
//                      }
 
142
//                      if (printGenerics && typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) {
 
143
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
144
//                              outputFormatter.PrintToken(Tokens.Of);
 
145
//                              outputFormatter.Space();
 
146
//                              AppendCommaSeparatedList(typeReference.GenericTypes);
 
147
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
148
//                      }
 
149
//                      for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
 
150
//                              outputFormatter.PrintToken(Tokens.Times);
 
151
//                      }
 
152
//              }
 
153
//              
 
154
//              void PrintArrayRank(int[] rankSpecifier, int startRank)
 
155
//              {
 
156
//                      for (int i = startRank; i < rankSpecifier.Length; ++i) {
 
157
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
158
//                              for (int j = 0; j < rankSpecifier[i]; ++j) {
 
159
//                                      outputFormatter.PrintToken(Tokens.Comma);
 
160
//                              }
 
161
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
162
//                      }
 
163
//              }
 
164
//              
 
165
//              public override object TrackedVisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data)
 
166
//              {
 
167
//                      TrackedVisit(innerClassTypeReference.BaseType, data);
 
168
//                      outputFormatter.PrintToken(Tokens.Dot);
 
169
//                      return VisitTypeReference((TypeReference)innerClassTypeReference, data);
 
170
//              }
 
171
//              
 
172
//              #region Global scope
 
173
//              bool printAttributeSectionInline; // is set to true when printing parameter's attributes
 
174
//              
 
175
//              public override object TrackedVisitAttributeSection(AttributeSection attributeSection, object data)
 
176
//              {
 
177
//                      if (!printAttributeSectionInline)
 
178
//                              outputFormatter.Indent();
 
179
//                      outputFormatter.PrintText("<");
 
180
//                      if (!string.IsNullOrEmpty(attributeSection.AttributeTarget) && !string.Equals(attributeSection.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) {
 
181
//                              outputFormatter.PrintText(char.ToUpperInvariant(attributeSection.AttributeTarget[0]) + attributeSection.AttributeTarget.Substring(1));
 
182
//                              outputFormatter.PrintToken(Tokens.Colon);
 
183
//                              outputFormatter.Space();
 
184
//                      }
 
185
//                      Debug.Assert(attributeSection.Attributes != null);
 
186
//                      AppendCommaSeparatedList(attributeSection.Attributes);
 
187
//                      
 
188
//                      outputFormatter.PrintText(">");
 
189
//                      
 
190
//                      if ("assembly".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)
 
191
//                          || "module".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)) {
 
192
//                              outputFormatter.NewLine();
 
193
//                      } else {
 
194
//                              if (printAttributeSectionInline)
 
195
//                                      outputFormatter.Space();
 
196
//                              else
 
197
//                                      outputFormatter.PrintLineContinuation();
 
198
//                      }
 
199
//                      
 
200
//                      return null;
 
201
//              }
 
202
//              
 
203
//              public override object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data)
 
204
//              {
 
205
//                      outputFormatter.PrintIdentifier(attribute.Type);
 
206
//                      if (attribute.PositionalArguments.Count > 0 || attribute.NamedArguments.Count > 0) {
 
207
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
208
//                              AppendCommaSeparatedList(attribute.PositionalArguments);
 
209
//                              
 
210
//                              if (attribute.NamedArguments.Count > 0) {
 
211
//                                      if (attribute.PositionalArguments.Count > 0) {
 
212
//                                              outputFormatter.PrintToken(Tokens.Comma);
 
213
//                                              outputFormatter.Space();
 
214
//                                      }
 
215
//                                      AppendCommaSeparatedList(attribute.NamedArguments);
 
216
//                              }
 
217
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
218
//                      }
 
219
//                      return null;
 
220
//              }
 
221
//              
 
222
//              public override object TrackedVisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data)
 
223
//              {
 
224
//                      outputFormatter.PrintIdentifier(namedArgumentExpression.Name);
 
225
//                      outputFormatter.Space();
 
226
//                      outputFormatter.PrintToken(Tokens.Colon);
 
227
//                      outputFormatter.PrintToken(Tokens.Assign);
 
228
//                      outputFormatter.Space();
 
229
//                      TrackedVisit(namedArgumentExpression.Expression, data);
 
230
//                      return null;
 
231
//              }
 
232
//              
 
233
//              public override object TrackedVisitUsing(ImportsClause @using, object data)
 
234
//              {
 
235
//                      Debug.Fail("Should never be called. The usings should be handled in Visit(UsingDeclaration)");
 
236
//                      return null;
 
237
//              }
 
238
//              
 
239
//              public override object TrackedVisitUsingDeclaration(ImportsStatement usingDeclaration, object data)
 
240
//              {
 
241
//                      outputFormatter.Indent();
 
242
//                      outputFormatter.PrintToken(Tokens.Imports);
 
243
//                      outputFormatter.Space();
 
244
//                      for (int i = 0; i < usingDeclaration.ImportsClauses.Count; ++i) {
 
245
//                              outputFormatter.PrintIdentifier(((ImportsClause)usingDeclaration.ImportsClauses[i]).Name);
 
246
//                              if (((ImportsClause)usingDeclaration.ImportsClauses[i]).IsAlias) {
 
247
//                                      outputFormatter.Space();
 
248
//                                      outputFormatter.PrintToken(Tokens.Assign);
 
249
//                                      outputFormatter.Space();
 
250
//                                      TrackedVisit(((ImportsClause)usingDeclaration.ImportsClauses[i]).Alias, data);
 
251
//                              }
 
252
//                              if (i + 1 < usingDeclaration.ImportsClauses.Count) {
 
253
//                                      outputFormatter.PrintToken(Tokens.Comma);
 
254
//                                      outputFormatter.Space();
 
255
//                              }
 
256
//                      }
 
257
//                      outputFormatter.NewLine();
 
258
//                      return null;
 
259
//              }
 
260
//              
 
261
//              public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
 
262
//              {
 
263
//                      outputFormatter.Indent();
 
264
//                      outputFormatter.PrintToken(Tokens.Namespace);
 
265
//                      outputFormatter.Space();
 
266
//                      outputFormatter.PrintIdentifier(namespaceDeclaration.Name);
 
267
//                      outputFormatter.NewLine();
 
268
//                      
 
269
//                      ++outputFormatter.IndentationLevel;
 
270
//                      namespaceDeclaration.AcceptChildren(this, data);
 
271
//                      --outputFormatter.IndentationLevel;
 
272
//                      
 
273
//                      outputFormatter.Indent();
 
274
//                      outputFormatter.PrintToken(Tokens.End);
 
275
//                      outputFormatter.Space();
 
276
//                      outputFormatter.PrintToken(Tokens.Namespace);
 
277
//                      outputFormatter.NewLine();
 
278
//                      return null;
 
279
//              }
 
280
//              
 
281
//              static int GetTypeToken(TypeDeclaration typeDeclaration)
 
282
//              {
 
283
//                      switch (typeDeclaration.Type) {
 
284
//                              case ClassType.Class:
 
285
//                                      return Tokens.Class;
 
286
//                              case ClassType.Enum:
 
287
//                                      return Tokens.Enum;
 
288
//                              case ClassType.Interface:
 
289
//                                      return Tokens.Interface;
 
290
//                              case ClassType.Struct:
 
291
//                                      return Tokens.Structure;
 
292
//                              case ClassType.Module:
 
293
//                                      return Tokens.Module;
 
294
//                              default:
 
295
//                                      return Tokens.Class;
 
296
//                      }
 
297
//              }
 
298
//              
 
299
//              void PrintTemplates(List<TemplateDefinition> templates)
 
300
//              {
 
301
//                      if (templates != null && templates.Count > 0) {
 
302
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
303
//                              outputFormatter.PrintToken(Tokens.Of);
 
304
//                              outputFormatter.Space();
 
305
//                              AppendCommaSeparatedList(templates);
 
306
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
307
//                      }
 
308
//              }
 
309
//              
 
310
//              public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
 
311
//              {
 
312
//                      VisitAttributes(typeDeclaration.Attributes, data);
 
313
//                      
 
314
//                      outputFormatter.Indent();
 
315
//                      OutputModifier(typeDeclaration.Modifier, true, false);
 
316
//                      
 
317
//                      int typeToken = GetTypeToken(typeDeclaration);
 
318
//                      outputFormatter.PrintToken(typeToken);
 
319
//                      outputFormatter.Space();
 
320
//                      outputFormatter.PrintIdentifier(typeDeclaration.Name);
 
321
//                      
 
322
//                      PrintTemplates(typeDeclaration.Templates);
 
323
//                      
 
324
//                      if (typeDeclaration.Type == ClassType.Enum
 
325
//                          && typeDeclaration.BaseTypes != null && typeDeclaration.BaseTypes.Count > 0)
 
326
//                      {
 
327
//                              outputFormatter.Space();
 
328
//                              outputFormatter.PrintToken(Tokens.As);
 
329
//                              outputFormatter.Space();
 
330
//                              foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
 
331
//                                      TrackedVisit(baseTypeRef, data);
 
332
//                              }
 
333
//                      }
 
334
//                      
 
335
//                      outputFormatter.NewLine();
 
336
//                      ++outputFormatter.IndentationLevel;
 
337
//                      
 
338
//                      if (typeDeclaration.BaseTypes != null && typeDeclaration.Type != ClassType.Enum) {
 
339
//                              foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
 
340
//                                      outputFormatter.Indent();
 
341
//                                      
 
342
//                                      string baseType = baseTypeRef.Type;
 
343
//                                      if (baseType.IndexOf('.') >= 0) {
 
344
//                                              baseType = baseType.Substring(baseType.LastIndexOf('.') + 1);
 
345
//                                      }
 
346
//                                      bool baseTypeIsInterface = baseType.Length >= 2 && baseType[0] == 'I' && Char.IsUpper(baseType[1]);
 
347
//                                      
 
348
//                                      if (!baseTypeIsInterface || typeDeclaration.Type == ClassType.Interface) {
 
349
//                                              outputFormatter.PrintToken(Tokens.Inherits);
 
350
//                                      } else {
 
351
//                                              outputFormatter.PrintToken(Tokens.Implements);
 
352
//                                      }
 
353
//                                      outputFormatter.Space();
 
354
//                                      TrackedVisit(baseTypeRef, data);
 
355
//                                      outputFormatter.NewLine();
 
356
//                              }
 
357
//                      }
 
358
//                      
 
359
//                      TypeDeclaration oldType = currentType;
 
360
//                      currentType = typeDeclaration;
 
361
//                      
 
362
//                      if (typeDeclaration.Type == ClassType.Enum) {
 
363
//                              OutputEnumMembers(typeDeclaration, data);
 
364
//                      } else {
 
365
//                              typeDeclaration.AcceptChildren(this, data);
 
366
//                      }
 
367
//                      currentType = oldType;
 
368
//                      
 
369
//                      --outputFormatter.IndentationLevel;
 
370
//                      
 
371
//                      
 
372
//                      outputFormatter.Indent();
 
373
//                      outputFormatter.PrintToken(Tokens.End);
 
374
//                      outputFormatter.Space();
 
375
//                      outputFormatter.PrintToken(typeToken);
 
376
//                      outputFormatter.NewLine();
 
377
//                      return null;
 
378
//              }
 
379
//              
 
380
//              void OutputEnumMembers(TypeDeclaration typeDeclaration, object data)
 
381
//              {
 
382
//                      foreach (FieldDeclaration fieldDeclaration in typeDeclaration.Children) {
 
383
//                              BeginVisit(fieldDeclaration);
 
384
//                              VariableDeclaration f = (VariableDeclaration)fieldDeclaration.Fields[0];
 
385
//                              VisitAttributes(fieldDeclaration.Attributes, data);
 
386
//                              outputFormatter.Indent();
 
387
//                              outputFormatter.PrintIdentifier(f.Name);
 
388
//                              if (f.Initializer != null && !f.Initializer.IsNull) {
 
389
//                                      outputFormatter.Space();
 
390
//                                      outputFormatter.PrintToken(Tokens.Assign);
 
391
//                                      outputFormatter.Space();
 
392
//                                      TrackedVisit(f.Initializer, data);
 
393
//                              }
 
394
//                              outputFormatter.NewLine();
 
395
//                              EndVisit(fieldDeclaration);
 
396
//                      }
 
397
//              }
 
398
//              
 
399
//              public override object TrackedVisitTemplateDefinition(TemplateDefinition templateDefinition, object data)
 
400
//              {
 
401
//                      VisitAttributes(templateDefinition.Attributes, data);
 
402
//                      switch (templateDefinition.VarianceModifier) {
 
403
//                              case VarianceModifier.Invariant:
 
404
//                                      // nothing
 
405
//                                      break;
 
406
//                              case VarianceModifier.Covariant:
 
407
//                                      outputFormatter.Space();
 
408
//                                      outputFormatter.PrintToken(Tokens.Out);
 
409
//                                      outputFormatter.Space();
 
410
//                                      break;
 
411
//                              case VarianceModifier.Contravariant:
 
412
//                                      outputFormatter.Space();
 
413
//                                      outputFormatter.PrintToken(Tokens.In);
 
414
//                                      outputFormatter.Space();
 
415
//                                      break;
 
416
//                              default:
 
417
//                                      throw new Exception("Invalid value for VarianceModifier");
 
418
//                      }
 
419
//                      outputFormatter.PrintIdentifier(templateDefinition.Name);
 
420
//                      if (templateDefinition.Bases.Count > 0) {
 
421
//                              outputFormatter.PrintText(" As ");
 
422
//                              VisitReturnTypeAttributes(templateDefinition.Attributes, data);
 
423
//                              if (templateDefinition.Bases.Count == 1) {
 
424
//                                      TrackedVisit(templateDefinition.Bases[0], data);
 
425
//                              } else {
 
426
//                                      outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
 
427
//                                      AppendCommaSeparatedList(templateDefinition.Bases);
 
428
//                                      outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
 
429
//                              }
 
430
//                      }
 
431
//                      return null;
 
432
//              }
 
433
//              
 
434
//              public override object TrackedVisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data)
 
435
//              {
 
436
//                      VisitAttributes(delegateDeclaration.Attributes, data);
 
437
//                      
 
438
//                      outputFormatter.Indent();
 
439
//                      OutputModifier(delegateDeclaration.Modifier, true, false);
 
440
//                      outputFormatter.PrintToken(Tokens.Delegate);
 
441
//                      outputFormatter.Space();
 
442
//                      
 
443
//                      bool isFunction = (delegateDeclaration.ReturnType.Type != "System.Void");
 
444
//                      if (isFunction) {
 
445
//                              outputFormatter.PrintToken(Tokens.Function);
 
446
//                              outputFormatter.Space();
 
447
//                      } else {
 
448
//                              outputFormatter.PrintToken(Tokens.Sub);
 
449
//                              outputFormatter.Space();
 
450
//                      }
 
451
//                      outputFormatter.PrintIdentifier(delegateDeclaration.Name);
 
452
//                      
 
453
//                      PrintTemplates(delegateDeclaration.Templates);
 
454
//                      
 
455
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
456
//                      AppendCommaSeparatedList(delegateDeclaration.Parameters);
 
457
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
458
//                      
 
459
//                      if (isFunction) {
 
460
//                              outputFormatter.Space();
 
461
//                              outputFormatter.PrintToken(Tokens.As);
 
462
//                              outputFormatter.Space();
 
463
//                              VisitReturnTypeAttributes(delegateDeclaration.Attributes, data);
 
464
//                              TrackedVisit(delegateDeclaration.ReturnType, data);
 
465
//                      }
 
466
//                      outputFormatter.NewLine();
 
467
//                      return null;
 
468
//              }
 
469
//              
 
470
//              public override object TrackedVisitOptionDeclaration(OptionDeclaration optionDeclaration, object data)
 
471
//              {
 
472
//                      outputFormatter.PrintToken(Tokens.Option);
 
473
//                      outputFormatter.Space();
 
474
//                      switch (optionDeclaration.OptionType) {
 
475
//                              case OptionType.Strict:
 
476
//                                      outputFormatter.PrintToken(Tokens.Strict);
 
477
//                                      outputFormatter.Space();
 
478
//                                      outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
 
479
//                                      break;
 
480
//                              case OptionType.Explicit:
 
481
//                                      outputFormatter.PrintToken(Tokens.Explicit);
 
482
//                                      outputFormatter.Space();
 
483
//                                      outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
 
484
//                                      break;
 
485
//                              case OptionType.Infer:
 
486
//                                      outputFormatter.PrintToken(Tokens.Infer);
 
487
//                                      outputFormatter.Space();
 
488
//                                      outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
 
489
//                                      break;
 
490
//                              case OptionType.CompareBinary:
 
491
//                                      outputFormatter.PrintToken(Tokens.Compare);
 
492
//                                      outputFormatter.Space();
 
493
//                                      outputFormatter.PrintToken(Tokens.Binary);
 
494
//                                      break;
 
495
//                              case OptionType.CompareText:
 
496
//                                      outputFormatter.PrintToken(Tokens.Compare);
 
497
//                                      outputFormatter.Space();
 
498
//                                      outputFormatter.PrintToken(Tokens.Text);
 
499
//                                      break;
 
500
//                      }
 
501
//                      outputFormatter.NewLine();
 
502
//                      return null;
 
503
//              }
 
504
//              #endregion
 
505
//              
 
506
//              #region Type level
 
507
//              TypeReference currentVariableType;
 
508
//              public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
 
509
//              {
 
510
//                      
 
511
//                      VisitAttributes(fieldDeclaration.Attributes, data);
 
512
//                      outputFormatter.Indent();
 
513
//                      if (fieldDeclaration.Modifier == Modifiers.None) {
 
514
//                              outputFormatter.PrintToken(Tokens.Private);
 
515
//                              outputFormatter.Space();
 
516
//                      } else {
 
517
//                              OutputModifier(fieldDeclaration.Modifier, false, true);
 
518
//                      }
 
519
//                      currentVariableType = fieldDeclaration.TypeReference;
 
520
//                      AppendCommaSeparatedList(fieldDeclaration.Fields);
 
521
//                      currentVariableType = null;
 
522
//                      
 
523
//                      outputFormatter.NewLine();
 
524
//
 
525
//                      return null;
 
526
//              }
 
527
//              
 
528
//              public override object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
 
529
//              {
 
530
//                      outputFormatter.PrintIdentifier(variableDeclaration.Name);
 
531
//                      
 
532
//                      TypeReference varType = currentVariableType;
 
533
//                      if (varType != null && varType.IsNull)
 
534
//                              varType = null;
 
535
//                      if (varType == null && !variableDeclaration.TypeReference.IsNull)
 
536
//                              varType = variableDeclaration.TypeReference;
 
537
//                      
 
538
//                      if (varType != null) {
 
539
//                              outputFormatter.Space();
 
540
//                              outputFormatter.PrintToken(Tokens.As);
 
541
//                              outputFormatter.Space();
 
542
//                              ObjectCreateExpression init = variableDeclaration.Initializer as ObjectCreateExpression;
 
543
//                              if (init != null && TypeReference.AreEqualReferences(init.CreateType, varType)) {
 
544
//                                      TrackedVisit(variableDeclaration.Initializer, data);
 
545
//                                      return null;
 
546
//                              } else {
 
547
//                                      TrackedVisit(varType, data);
 
548
//                              }
 
549
//                      }
 
550
//                      
 
551
//                      if (!variableDeclaration.Initializer.IsNull) {
 
552
//                              outputFormatter.Space();
 
553
//                              outputFormatter.PrintToken(Tokens.Assign);
 
554
//                              outputFormatter.Space();
 
555
//                              TrackedVisit(variableDeclaration.Initializer, data);
 
556
//                      }
 
557
//                      return null;
 
558
//              }
 
559
//              
 
560
//              public override object TrackedVisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
 
561
//              {
 
562
//                      VisitAttributes(propertyDeclaration.Attributes, data);
 
563
//                      outputFormatter.Indent();
 
564
//                      OutputModifier(propertyDeclaration.Modifier);
 
565
//                      
 
566
//                      if ((propertyDeclaration.Modifier & (Modifiers.ReadOnly | Modifiers.WriteOnly)) == Modifiers.None) {
 
567
//                              if (propertyDeclaration.IsReadOnly) {
 
568
//                                      outputFormatter.PrintToken(Tokens.ReadOnly);
 
569
//                                      outputFormatter.Space();
 
570
//                              } else if (propertyDeclaration.IsWriteOnly) {
 
571
//                                      outputFormatter.PrintToken(Tokens.WriteOnly);
 
572
//                                      outputFormatter.Space();
 
573
//                              }
 
574
//                      }
 
575
//                      
 
576
//                      outputFormatter.PrintToken(Tokens.Property);
 
577
//                      outputFormatter.Space();
 
578
//                      outputFormatter.PrintIdentifier(propertyDeclaration.Name);
 
579
//                      
 
580
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
581
//                      AppendCommaSeparatedList(propertyDeclaration.Parameters);
 
582
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
583
//                      
 
584
//                      if (!propertyDeclaration.TypeReference.IsNull) {
 
585
//                              outputFormatter.Space();
 
586
//                              outputFormatter.PrintToken(Tokens.As);
 
587
//                              outputFormatter.Space();
 
588
//                              
 
589
//                              VisitReturnTypeAttributes(propertyDeclaration.Attributes, data);
 
590
//                              
 
591
//                              ObjectCreateExpression init = propertyDeclaration.Initializer as ObjectCreateExpression;
 
592
//                              if (init != null && TypeReference.AreEqualReferences(init.CreateType, propertyDeclaration.TypeReference)) {
 
593
//                                      TrackedVisit(propertyDeclaration.Initializer, data);
 
594
//                              } else {
 
595
//                                      TrackedVisit(propertyDeclaration.TypeReference, data);
 
596
//                              }
 
597
//                      }
 
598
//                      
 
599
//                      PrintInterfaceImplementations(propertyDeclaration.InterfaceImplementations);
 
600
//                      
 
601
//                      if (!propertyDeclaration.Initializer.IsNull && !(propertyDeclaration.Initializer is ObjectCreateExpression)) {
 
602
//                              outputFormatter.Space();
 
603
//                              outputFormatter.PrintToken(Tokens.Assign);
 
604
//                              outputFormatter.Space();
 
605
//                              TrackedVisit(propertyDeclaration.Initializer, data);
 
606
//                      }
 
607
//                      
 
608
//                      outputFormatter.NewLine();
 
609
//                      
 
610
//                      if (!IsAbstract(propertyDeclaration) && (propertyDeclaration.GetRegion.Block != NullBlockStatement.Instance  || propertyDeclaration.SetRegion.Block != NullBlockStatement.Instance)) {
 
611
//                              outputFormatter.IsInMemberBody = true;
 
612
//                              ++outputFormatter.IndentationLevel;
 
613
//                              exitTokenStack.Push(Tokens.Property);
 
614
//                              TrackedVisit(propertyDeclaration.GetRegion, data);
 
615
//                              TrackedVisit(propertyDeclaration.SetRegion, data);
 
616
//                              exitTokenStack.Pop();
 
617
//                              --outputFormatter.IndentationLevel;
 
618
//                              outputFormatter.IsInMemberBody = false;
 
619
//                              
 
620
//                              outputFormatter.Indent();
 
621
//                              outputFormatter.PrintToken(Tokens.End);
 
622
//                              outputFormatter.Space();
 
623
//                              outputFormatter.PrintToken(Tokens.Property);
 
624
//                              outputFormatter.NewLine();
 
625
//                      }
 
626
//                      
 
627
//                      return null;
 
628
//              }
 
629
//              
 
630
//              public override object TrackedVisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data)
 
631
//              {
 
632
//                      VisitAttributes(propertyGetRegion.Attributes, data);
 
633
//                      outputFormatter.Indent();
 
634
//                      OutputModifier(propertyGetRegion.Modifier);
 
635
//                      outputFormatter.PrintToken(Tokens.Get);
 
636
//                      outputFormatter.NewLine();
 
637
//                      
 
638
//                      ++outputFormatter.IndentationLevel;
 
639
//                      TrackedVisit(propertyGetRegion.Block, data);
 
640
//                      --outputFormatter.IndentationLevel;
 
641
//                      outputFormatter.Indent();
 
642
//                      outputFormatter.PrintToken(Tokens.End);
 
643
//                      outputFormatter.Space();
 
644
//                      outputFormatter.PrintToken(Tokens.Get);
 
645
//                      outputFormatter.NewLine();
 
646
//                      return null;
 
647
//              }
 
648
//              
 
649
//              public override object TrackedVisitPropertySetRegion(PropertySetRegion propertySetRegion, object data)
 
650
//              {
 
651
//                      VisitAttributes(propertySetRegion.Attributes, data);
 
652
//                      outputFormatter.Indent();
 
653
//                      OutputModifier(propertySetRegion.Modifier);
 
654
//                      outputFormatter.PrintToken(Tokens.Set);
 
655
//                      outputFormatter.NewLine();
 
656
//                      
 
657
//                      ++outputFormatter.IndentationLevel;
 
658
//                      TrackedVisit(propertySetRegion.Block, data);
 
659
//                      --outputFormatter.IndentationLevel;
 
660
//                      outputFormatter.Indent();
 
661
//                      outputFormatter.PrintToken(Tokens.End);
 
662
//                      outputFormatter.Space();
 
663
//                      outputFormatter.PrintToken(Tokens.Set);
 
664
//                      outputFormatter.NewLine();
 
665
//                      return null;
 
666
//              }
 
667
//              
 
668
//              TypeReference currentEventType = null;
 
669
//              public override object TrackedVisitEventDeclaration(EventDeclaration eventDeclaration, object data)
 
670
//              {
 
671
//                      bool customEvent = eventDeclaration.HasAddRegion  || eventDeclaration.HasRemoveRegion;
 
672
//                      
 
673
//                      VisitAttributes(eventDeclaration.Attributes, data);
 
674
//                      outputFormatter.Indent();
 
675
//                      OutputModifier(eventDeclaration.Modifier);
 
676
//                      if (customEvent) {
 
677
//                              outputFormatter.PrintText("Custom");
 
678
//                              outputFormatter.Space();
 
679
//                      }
 
680
//                      
 
681
//                      outputFormatter.PrintToken(Tokens.Event);
 
682
//                      outputFormatter.Space();
 
683
//                      outputFormatter.PrintIdentifier(eventDeclaration.Name);
 
684
//                      
 
685
//                      if (eventDeclaration.Parameters.Count > 0) {
 
686
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
687
//                              this.AppendCommaSeparatedList(eventDeclaration.Parameters);
 
688
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
689
//                      }
 
690
//                      if (!eventDeclaration.TypeReference.IsNull) {
 
691
//                              outputFormatter.Space();
 
692
//                              outputFormatter.PrintToken(Tokens.As);
 
693
//                              outputFormatter.Space();
 
694
//                              VisitReturnTypeAttributes(eventDeclaration.Attributes, data);
 
695
//                              TrackedVisit(eventDeclaration.TypeReference, data);
 
696
//                      }
 
697
//                      
 
698
//                      PrintInterfaceImplementations(eventDeclaration.InterfaceImplementations);
 
699
//                      
 
700
//                      if (!eventDeclaration.Initializer.IsNull) {
 
701
//                              outputFormatter.Space();
 
702
//                              outputFormatter.PrintToken(Tokens.Assign);
 
703
//                              outputFormatter.Space();
 
704
//                              TrackedVisit(eventDeclaration.Initializer, data);
 
705
//                      }
 
706
//                      
 
707
//                      outputFormatter.NewLine();
 
708
//                      
 
709
//                      if (customEvent) {
 
710
//                              ++outputFormatter.IndentationLevel;
 
711
//                              currentEventType = eventDeclaration.TypeReference;
 
712
//                              exitTokenStack.Push(Tokens.Sub);
 
713
//                              TrackedVisit(eventDeclaration.AddRegion, data);
 
714
//                              TrackedVisit(eventDeclaration.RemoveRegion, data);
 
715
//                              exitTokenStack.Pop();
 
716
//                              --outputFormatter.IndentationLevel;
 
717
//                              
 
718
//                              outputFormatter.Indent();
 
719
//                              outputFormatter.PrintToken(Tokens.End);
 
720
//                              outputFormatter.Space();
 
721
//                              outputFormatter.PrintToken(Tokens.Event);
 
722
//                              outputFormatter.NewLine();
 
723
//                      }
 
724
//                      return null;
 
725
//              }
 
726
//              
 
727
//              void PrintInterfaceImplementations(IList<InterfaceImplementation> list)
 
728
//              {
 
729
//                      if (list == null || list.Count == 0)
 
730
//                              return;
 
731
//                      outputFormatter.Space();
 
732
//                      outputFormatter.PrintToken(Tokens.Implements);
 
733
//                      for (int i = 0; i < list.Count; i++) {
 
734
//                              if (i > 0)
 
735
//                                      outputFormatter.PrintToken(Tokens.Comma);
 
736
//                              outputFormatter.Space();
 
737
//                              TrackedVisit(list[i].InterfaceType, null);
 
738
//                              outputFormatter.PrintToken(Tokens.Dot);
 
739
//                              outputFormatter.PrintIdentifier(list[i].MemberName);
 
740
//                      }
 
741
//              }
 
742
//              
 
743
//              public override object TrackedVisitEventAddRegion(EventAddRegion eventAddRegion, object data)
 
744
//              {
 
745
//                      VisitAttributes(eventAddRegion.Attributes, data);
 
746
//                      outputFormatter.Indent();
 
747
//                      outputFormatter.PrintText("AddHandler(");
 
748
//                      if (eventAddRegion.Parameters.Count == 0) {
 
749
//                              outputFormatter.PrintToken(Tokens.ByVal);
 
750
//                              outputFormatter.Space();
 
751
//                              outputFormatter.PrintIdentifier("value");
 
752
//                              outputFormatter.Space();
 
753
//                              outputFormatter.PrintToken(Tokens.As);
 
754
//                              outputFormatter.Space();
 
755
//                              TrackedVisit(currentEventType, data);
 
756
//                      } else {
 
757
//                              this.AppendCommaSeparatedList(eventAddRegion.Parameters);
 
758
//                      }
 
759
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
760
//                      outputFormatter.NewLine();
 
761
//                      
 
762
//                      ++outputFormatter.IndentationLevel;
 
763
//                      TrackedVisit(eventAddRegion.Block, data);
 
764
//                      --outputFormatter.IndentationLevel;
 
765
//                      
 
766
//                      outputFormatter.Indent();
 
767
//                      outputFormatter.PrintToken(Tokens.End);
 
768
//                      outputFormatter.Space();
 
769
//                      outputFormatter.PrintText("AddHandler");
 
770
//                      outputFormatter.NewLine();
 
771
//                      return null;
 
772
//              }
 
773
//              
 
774
//              public override object TrackedVisitEventRemoveRegion(EventRemoveRegion eventRemoveRegion, object data)
 
775
//              {
 
776
//                      VisitAttributes(eventRemoveRegion.Attributes, data);
 
777
//                      outputFormatter.Indent();
 
778
//                      outputFormatter.PrintText("RemoveHandler");
 
779
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
780
//                      if (eventRemoveRegion.Parameters.Count == 0) {
 
781
//                              outputFormatter.PrintToken(Tokens.ByVal);
 
782
//                              outputFormatter.Space();
 
783
//                              outputFormatter.PrintIdentifier("value");
 
784
//                              outputFormatter.Space();
 
785
//                              outputFormatter.PrintToken(Tokens.As);
 
786
//                              outputFormatter.Space();
 
787
//                              TrackedVisit(currentEventType, data);
 
788
//                      } else {
 
789
//                              this.AppendCommaSeparatedList(eventRemoveRegion.Parameters);
 
790
//                      }
 
791
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
792
//                      outputFormatter.NewLine();
 
793
//                      
 
794
//                      ++outputFormatter.IndentationLevel;
 
795
//                      TrackedVisit(eventRemoveRegion.Block, data);
 
796
//                      --outputFormatter.IndentationLevel;
 
797
//                      
 
798
//                      outputFormatter.Indent();
 
799
//                      outputFormatter.PrintToken(Tokens.End);
 
800
//                      outputFormatter.Space();
 
801
//                      outputFormatter.PrintText("RemoveHandler");
 
802
//                      outputFormatter.NewLine();
 
803
//                      return null;
 
804
//              }
 
805
//              
 
806
//              public override object TrackedVisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data)
 
807
//              {
 
808
//                      VisitAttributes(eventRaiseRegion.Attributes, data);
 
809
//                      outputFormatter.Indent();
 
810
//                      outputFormatter.PrintText("RaiseEvent");
 
811
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
812
//                      if (eventRaiseRegion.Parameters.Count == 0) {
 
813
//                              outputFormatter.PrintToken(Tokens.ByVal);
 
814
//                              outputFormatter.Space();
 
815
//                              outputFormatter.PrintIdentifier("value");
 
816
//                              outputFormatter.Space();
 
817
//                              outputFormatter.PrintToken(Tokens.As);
 
818
//                              outputFormatter.Space();
 
819
//                              TrackedVisit(currentEventType, data);
 
820
//                      } else {
 
821
//                              this.AppendCommaSeparatedList(eventRaiseRegion.Parameters);
 
822
//                      }
 
823
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
824
//                      outputFormatter.NewLine();
 
825
//                      
 
826
//                      ++outputFormatter.IndentationLevel;
 
827
//                      TrackedVisit(eventRaiseRegion.Block, data);
 
828
//                      --outputFormatter.IndentationLevel;
 
829
//                      
 
830
//                      outputFormatter.Indent();
 
831
//                      outputFormatter.PrintToken(Tokens.End);
 
832
//                      outputFormatter.Space();
 
833
//                      outputFormatter.PrintText("RaiseEvent");
 
834
//                      outputFormatter.NewLine();
 
835
//                      return null;
 
836
//              }
 
837
//              
 
838
//              public override object TrackedVisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data)
 
839
//              {
 
840
//                      printAttributeSectionInline = true;
 
841
//                      VisitAttributes(parameterDeclarationExpression.Attributes, data);
 
842
//                      printAttributeSectionInline = false;
 
843
//                      OutputModifier(parameterDeclarationExpression.ParamModifier);
 
844
//                      outputFormatter.PrintIdentifier(parameterDeclarationExpression.ParameterName);
 
845
//                      if (!parameterDeclarationExpression.TypeReference.IsNull) {
 
846
//                              outputFormatter.Space();
 
847
//                              outputFormatter.PrintToken(Tokens.As);
 
848
//                              outputFormatter.Space();
 
849
//                              VisitReturnTypeAttributes(parameterDeclarationExpression.Attributes, data);
 
850
//                              TrackedVisit(parameterDeclarationExpression.TypeReference, data);
 
851
//                      }
 
852
//                      if (!parameterDeclarationExpression.DefaultValue.IsNull) {
 
853
//                              outputFormatter.Space();
 
854
//                              outputFormatter.PrintToken(Tokens.Assign);
 
855
//                              outputFormatter.Space();
 
856
//                              TrackedVisit(parameterDeclarationExpression.DefaultValue, data);
 
857
//                      }
 
858
//                      return null;
 
859
//              }
 
860
//              
 
861
//              public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
 
862
//              {
 
863
//                      VisitAttributes(methodDeclaration.Attributes, data);
 
864
//                      if (methodDeclaration.IsExtensionMethod) {
 
865
//                              outputFormatter.Indent();
 
866
//                              outputFormatter.PrintText("<System.Runtime.CompilerServices.Extension> _");
 
867
//                              outputFormatter.NewLine();
 
868
//                      }
 
869
//                      outputFormatter.Indent();
 
870
//                      OutputModifier(methodDeclaration.Modifier);
 
871
//                      
 
872
//                      bool isSub = methodDeclaration.TypeReference.IsNull ||
 
873
//                              methodDeclaration.TypeReference.Type == "System.Void";
 
874
//                      
 
875
//                      if (isSub) {
 
876
//                              outputFormatter.PrintToken(Tokens.Sub);
 
877
//                      } else {
 
878
//                              outputFormatter.PrintToken(Tokens.Function);
 
879
//                      }
 
880
//                      outputFormatter.Space();
 
881
//                      outputFormatter.PrintIdentifier(methodDeclaration.Name);
 
882
//                      
 
883
//                      PrintTemplates(methodDeclaration.Templates);
 
884
//                      
 
885
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
886
//                      AppendCommaSeparatedList(methodDeclaration.Parameters);
 
887
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
888
//                      
 
889
//                      if (!isSub) {
 
890
//                              outputFormatter.Space();
 
891
//                              outputFormatter.PrintToken(Tokens.As);
 
892
//                              outputFormatter.Space();
 
893
//                              VisitReturnTypeAttributes(methodDeclaration.Attributes, data);
 
894
//                              TrackedVisit(methodDeclaration.TypeReference, data);
 
895
//                      }
 
896
//                      
 
897
//                      PrintInterfaceImplementations(methodDeclaration.InterfaceImplementations);
 
898
//                      
 
899
//                      if (methodDeclaration.HandlesClause.Count > 0) {
 
900
//                              outputFormatter.Space();
 
901
//                              outputFormatter.PrintToken(Tokens.Handles);
 
902
//                              for (int i = 0; i < methodDeclaration.HandlesClause.Count; i++) {
 
903
//                                      if (i > 0)
 
904
//                                              outputFormatter.PrintToken(Tokens.Comma);
 
905
//                                      outputFormatter.Space();
 
906
//                                      outputFormatter.PrintText(methodDeclaration.HandlesClause[i]);
 
907
//                              }
 
908
//                      }
 
909
//                      
 
910
//                      outputFormatter.NewLine();
 
911
//                      
 
912
//                      if (!IsAbstract(methodDeclaration)) {
 
913
//                              outputFormatter.IsInMemberBody = true;
 
914
//                              BeginVisit(methodDeclaration.Body);
 
915
//                              ++outputFormatter.IndentationLevel;
 
916
//                              exitTokenStack.Push(isSub ? Tokens.Sub : Tokens.Function);
 
917
//                              // we're doing the tracking manually using BeginVisit/EndVisit, so call Tracked... directly
 
918
//                              this.TrackedVisitBlockStatement(methodDeclaration.Body, data);
 
919
//                              exitTokenStack.Pop();
 
920
//                              --outputFormatter.IndentationLevel;
 
921
//                              
 
922
//                              outputFormatter.Indent();
 
923
//                              outputFormatter.PrintToken(Tokens.End);
 
924
//                              outputFormatter.Space();
 
925
//                              if (isSub) {
 
926
//                                      outputFormatter.PrintToken(Tokens.Sub);
 
927
//                              } else {
 
928
//                                      outputFormatter.PrintToken(Tokens.Function);
 
929
//                              }
 
930
//                              outputFormatter.NewLine();
 
931
//                              EndVisit(methodDeclaration.Body);
 
932
//                              outputFormatter.IsInMemberBody = false;
 
933
//                      }
 
934
//                      return null;
 
935
//              }
 
936
//              
 
937
//              public override object TrackedVisitInterfaceImplementation(InterfaceImplementation interfaceImplementation, object data)
 
938
//              {
 
939
//                      throw new InvalidOperationException();
 
940
//              }
 
941
//              
 
942
//              bool IsAbstract(AttributedNode node)
 
943
//              {
 
944
//                      if ((node.Modifier & Modifiers.Abstract) == Modifiers.Abstract)
 
945
//                              return true;
 
946
//                      return currentType != null && currentType.Type == ClassType.Interface;
 
947
//              }
 
948
//              
 
949
//              public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
 
950
//              {
 
951
//                      VisitAttributes(constructorDeclaration.Attributes, data);
 
952
//                      outputFormatter.Indent();
 
953
//                      OutputModifier(constructorDeclaration.Modifier);
 
954
//                      outputFormatter.PrintToken(Tokens.Sub);
 
955
//                      outputFormatter.Space();
 
956
//                      outputFormatter.PrintToken(Tokens.New);
 
957
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
958
//                      AppendCommaSeparatedList(constructorDeclaration.Parameters);
 
959
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
960
//                      outputFormatter.NewLine();
 
961
//                      
 
962
//                      outputFormatter.IsInMemberBody = true;
 
963
//                      ++outputFormatter.IndentationLevel;
 
964
//                      exitTokenStack.Push(Tokens.Sub);
 
965
//                      
 
966
//                      TrackedVisit(constructorDeclaration.ConstructorInitializer, data);
 
967
//                      
 
968
//                      TrackedVisit(constructorDeclaration.Body, data);
 
969
//                      exitTokenStack.Pop();
 
970
//                      --outputFormatter.IndentationLevel;
 
971
//                      outputFormatter.IsInMemberBody = false;
 
972
//                      
 
973
//                      outputFormatter.Indent();
 
974
//                      outputFormatter.PrintToken(Tokens.End);
 
975
//                      outputFormatter.Space();
 
976
//                      outputFormatter.PrintToken(Tokens.Sub);
 
977
//                      outputFormatter.NewLine();
 
978
//                      
 
979
//                      return null;
 
980
//              }
 
981
//              
 
982
//              public override object TrackedVisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
 
983
//              {
 
984
//                      outputFormatter.Indent();
 
985
//                      if (constructorInitializer.ConstructorInitializerType == ConstructorInitializerType.This) {
 
986
//                              outputFormatter.PrintToken(Tokens.Me);
 
987
//                      } else {
 
988
//                              outputFormatter.PrintToken(Tokens.MyBase);
 
989
//                      }
 
990
//                      outputFormatter.PrintToken(Tokens.Dot);
 
991
//                      outputFormatter.PrintToken(Tokens.New);
 
992
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
993
//                      AppendCommaSeparatedList(constructorInitializer.Arguments);
 
994
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
995
//                      
 
996
//                      outputFormatter.NewLine();
 
997
//                      return null;
 
998
//              }
 
999
//              
 
1000
//              public override object TrackedVisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data)
 
1001
//              {
 
1002
//                      VisitAttributes(operatorDeclaration.Attributes, data);
 
1003
//                      outputFormatter.Indent();
 
1004
//                      OutputModifier(operatorDeclaration.Modifier);
 
1005
//                      
 
1006
//                      if (operatorDeclaration.IsConversionOperator) {
 
1007
//                              if (operatorDeclaration.ConversionType == ConversionType.Implicit) {
 
1008
//                                      outputFormatter.PrintToken(Tokens.Widening);
 
1009
//                              } else {
 
1010
//                                      outputFormatter.PrintToken(Tokens.Narrowing);
 
1011
//                              }
 
1012
//                              outputFormatter.Space();
 
1013
//                      }
 
1014
//                      
 
1015
//                      outputFormatter.PrintToken(Tokens.Operator);
 
1016
//                      outputFormatter.Space();
 
1017
//                      
 
1018
//                      int op = -1;
 
1019
//                      
 
1020
//                      switch(operatorDeclaration.OverloadableOperator)
 
1021
//                      {
 
1022
//                              case OverloadableOperatorType.Add:
 
1023
//                              case OverloadableOperatorType.UnaryPlus:
 
1024
//                                      op = Tokens.Plus;
 
1025
//                                      break;
 
1026
//                              case OverloadableOperatorType.UnaryMinus:
 
1027
//                              case OverloadableOperatorType.Subtract:
 
1028
//                                      op = Tokens.Minus;
 
1029
//                                      break;
 
1030
//                              case OverloadableOperatorType.Multiply:
 
1031
//                                      op = Tokens.Times;
 
1032
//                                      break;
 
1033
//                              case OverloadableOperatorType.Divide:
 
1034
//                                      op = Tokens.Div;
 
1035
//                                      break;
 
1036
//                              case OverloadableOperatorType.Modulus:
 
1037
//                                      op = Tokens.Mod;
 
1038
//                                      break;
 
1039
//                              case OverloadableOperatorType.Concat:
 
1040
//                                      op = Tokens.ConcatString;
 
1041
//                                      break;
 
1042
//                              case OverloadableOperatorType.Not:
 
1043
//                                      op = Tokens.Not;
 
1044
//                                      break;
 
1045
//                              case OverloadableOperatorType.BitNot:
 
1046
//                                      op = Tokens.Not;
 
1047
//                                      break;
 
1048
//                              case OverloadableOperatorType.BitwiseAnd:
 
1049
//                                      op = Tokens.And;
 
1050
//                                      break;
 
1051
//                              case OverloadableOperatorType.BitwiseOr:
 
1052
//                                      op = Tokens.Or;
 
1053
//                                      break;
 
1054
//                              case OverloadableOperatorType.ExclusiveOr:
 
1055
//                                      op = Tokens.Xor;
 
1056
//                                      break;
 
1057
//                              case OverloadableOperatorType.ShiftLeft:
 
1058
//                                      op = Tokens.ShiftLeft;
 
1059
//                                      break;
 
1060
//                              case OverloadableOperatorType.ShiftRight:
 
1061
//                                      op = Tokens.ShiftRight;
 
1062
//                                      break;
 
1063
//                              case OverloadableOperatorType.GreaterThan:
 
1064
//                                      op = Tokens.GreaterThan;
 
1065
//                                      break;
 
1066
//                              case OverloadableOperatorType.GreaterThanOrEqual:
 
1067
//                                      op = Tokens.GreaterEqual;
 
1068
//                                      break;
 
1069
//                              case OverloadableOperatorType.Equality:
 
1070
//                                      op = Tokens.Assign;
 
1071
//                                      break;
 
1072
//                              case OverloadableOperatorType.InEquality:
 
1073
//                                      op = Tokens.NotEqual;
 
1074
//                                      break;
 
1075
//                              case OverloadableOperatorType.LessThan:
 
1076
//                                      op = Tokens.LessThan;
 
1077
//                                      break;
 
1078
//                              case OverloadableOperatorType.LessThanOrEqual:
 
1079
//                                      op = Tokens.LessEqual;
 
1080
//                                      break;
 
1081
//                              case OverloadableOperatorType.Increment:
 
1082
//                                      Error("Increment operator is not supported in Visual Basic", operatorDeclaration.StartLocation);
 
1083
//                                      break;
 
1084
//                              case OverloadableOperatorType.Decrement:
 
1085
//                                      Error("Decrement operator is not supported in Visual Basic", operatorDeclaration.StartLocation);
 
1086
//                                      break;
 
1087
//                              case OverloadableOperatorType.IsTrue:
 
1088
//                                      outputFormatter.PrintText("IsTrue");
 
1089
//                                      break;
 
1090
//                              case OverloadableOperatorType.IsFalse:
 
1091
//                                      outputFormatter.PrintText("IsFalse");
 
1092
//                                      break;
 
1093
//                              case OverloadableOperatorType.Like:
 
1094
//                                      op = Tokens.Like;
 
1095
//                                      break;
 
1096
//                              case OverloadableOperatorType.Power:
 
1097
//                                      op = Tokens.Power;
 
1098
//                                      break;
 
1099
//                              case OverloadableOperatorType.CType:
 
1100
//                                      op = Tokens.CType;
 
1101
//                                      break;
 
1102
//                              case OverloadableOperatorType.DivideInteger:
 
1103
//                                      op = Tokens.DivInteger;
 
1104
//                                      break;
 
1105
//                      }
 
1106
//                      
 
1107
//                      
 
1108
//                      
 
1109
//                      if (operatorDeclaration.IsConversionOperator) {
 
1110
//                              outputFormatter.PrintToken(Tokens.CType);
 
1111
//                      } else {
 
1112
//                              if(op != -1)  outputFormatter.PrintToken(op);
 
1113
//                      }
 
1114
//                      
 
1115
//                      PrintTemplates(operatorDeclaration.Templates);
 
1116
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
1117
//                      AppendCommaSeparatedList(operatorDeclaration.Parameters);
 
1118
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
1119
//                      if (!operatorDeclaration.TypeReference.IsNull) {
 
1120
//                              outputFormatter.Space();
 
1121
//                              outputFormatter.PrintToken(Tokens.As);
 
1122
//                              outputFormatter.Space();
 
1123
//                              VisitReturnTypeAttributes(operatorDeclaration.Attributes, data);
 
1124
//                              TrackedVisit(operatorDeclaration.TypeReference, data);
 
1125
//                      }
 
1126
//                      
 
1127
//                      outputFormatter.NewLine();
 
1128
//                      
 
1129
//                      ++outputFormatter.IndentationLevel;
 
1130
//                      TrackedVisit(operatorDeclaration.Body, data);
 
1131
//                      --outputFormatter.IndentationLevel;
 
1132
//                      
 
1133
//                      outputFormatter.Indent();
 
1134
//                      outputFormatter.PrintToken(Tokens.End);
 
1135
//                      outputFormatter.Space();
 
1136
//                      outputFormatter.PrintToken(Tokens.Operator);
 
1137
//                      outputFormatter.NewLine();
 
1138
//                      
 
1139
//                      return null;
 
1140
//              }
 
1141
//              
 
1142
//              public override object TrackedVisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
 
1143
//              {
 
1144
//                      VisitAttributes(declareDeclaration.Attributes, data);
 
1145
//                      outputFormatter.Indent();
 
1146
//                      OutputModifier(declareDeclaration.Modifier);
 
1147
//                      outputFormatter.PrintToken(Tokens.Declare);
 
1148
//                      outputFormatter.Space();
 
1149
//                      
 
1150
//                      switch (declareDeclaration.Charset) {
 
1151
//                              case CharsetModifier.Auto:
 
1152
//                                      outputFormatter.PrintToken(Tokens.Auto);
 
1153
//                                      outputFormatter.Space();
 
1154
//                                      break;
 
1155
//                              case CharsetModifier.Unicode:
 
1156
//                                      outputFormatter.PrintToken(Tokens.Unicode);
 
1157
//                                      outputFormatter.Space();
 
1158
//                                      break;
 
1159
//                              case CharsetModifier.Ansi:
 
1160
//                                      outputFormatter.PrintToken(Tokens.Ansi);
 
1161
//                                      outputFormatter.Space();
 
1162
//                                      break;
 
1163
//                      }
 
1164
//                      
 
1165
//                      bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.Type == "System.Void";
 
1166
//                      if (isVoid) {
 
1167
//                              outputFormatter.PrintToken(Tokens.Sub);
 
1168
//                      } else {
 
1169
//                              outputFormatter.PrintToken(Tokens.Function);
 
1170
//                      }
 
1171
//                      outputFormatter.Space();
 
1172
//                      
 
1173
//                      outputFormatter.PrintIdentifier(declareDeclaration.Name);
 
1174
//                      
 
1175
//                      outputFormatter.Space();
 
1176
//                      outputFormatter.PrintToken(Tokens.Lib);
 
1177
//                      outputFormatter.Space();
 
1178
//                      outputFormatter.PrintText(ConvertString(declareDeclaration.Library));
 
1179
//                      outputFormatter.Space();
 
1180
//                      
 
1181
//                      if (declareDeclaration.Alias.Length > 0) {
 
1182
//                              outputFormatter.PrintToken(Tokens.Alias);
 
1183
//                              outputFormatter.Space();
 
1184
//                              outputFormatter.PrintText(ConvertString(declareDeclaration.Alias));
 
1185
//                              outputFormatter.Space();
 
1186
//                      }
 
1187
//                      
 
1188
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
1189
//                      AppendCommaSeparatedList(declareDeclaration.Parameters);
 
1190
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
1191
//                      
 
1192
//                      if (!isVoid) {
 
1193
//                              outputFormatter.Space();
 
1194
//                              outputFormatter.PrintToken(Tokens.As);
 
1195
//                              outputFormatter.Space();
 
1196
//                              VisitReturnTypeAttributes(declareDeclaration.Attributes, data);
 
1197
//                              TrackedVisit(declareDeclaration.TypeReference, data);
 
1198
//                      }
 
1199
//                      
 
1200
//                      outputFormatter.NewLine();
 
1201
//                      
 
1202
//                      return null;
 
1203
//              }
 
1204
//              #endregion
 
1205
//              
 
1206
//              #region Statements
 
1207
//              public override object TrackedVisitBlockStatement(BlockStatement blockStatement, object data)
 
1208
//              {
 
1209
//                      if (blockStatement.Parent is BlockStatement) {
 
1210
//                              outputFormatter.Indent();
 
1211
//                              outputFormatter.PrintText("If True Then");
 
1212
//                              outputFormatter.NewLine();
 
1213
//                              outputFormatter.IndentationLevel += 1;
 
1214
//                      }
 
1215
//                      VisitStatementList(blockStatement.Children);
 
1216
//                      if (blockStatement.Parent is BlockStatement) {
 
1217
//                              outputFormatter.IndentationLevel -= 1;
 
1218
//                              outputFormatter.Indent();
 
1219
//                              outputFormatter.PrintText("End If");
 
1220
//                              outputFormatter.NewLine();
 
1221
//                      }
 
1222
//                      return null;
 
1223
//              }
 
1224
//              
 
1225
//              void PrintIndentedBlock(Statement stmt)
 
1226
//              {
 
1227
//                      outputFormatter.IndentationLevel += 1;
 
1228
//                      if (stmt is BlockStatement) {
 
1229
//                              TrackedVisit(stmt, null);
 
1230
//                      } else {
 
1231
//                              outputFormatter.Indent();
 
1232
//                              TrackedVisit(stmt, null);
 
1233
//                              outputFormatter.NewLine();
 
1234
//                      }
 
1235
//                      outputFormatter.IndentationLevel -= 1;
 
1236
//              }
 
1237
//              
 
1238
//              void PrintIndentedBlock(IEnumerable statements)
 
1239
//              {
 
1240
//                      outputFormatter.IndentationLevel += 1;
 
1241
//                      VisitStatementList(statements);
 
1242
//                      outputFormatter.IndentationLevel -= 1;
 
1243
//              }
 
1244
//              
 
1245
//              void VisitStatementList(IEnumerable statements)
 
1246
//              {
 
1247
//                      foreach (Statement stmt in statements) {
 
1248
//                              if (stmt is BlockStatement) {
 
1249
//                                      TrackedVisit(stmt, null);
 
1250
//                              } else {
 
1251
//                                      outputFormatter.Indent();
 
1252
//                                      TrackedVisit(stmt, null);
 
1253
//                                      outputFormatter.NewLine();
 
1254
//                              }
 
1255
//                      }
 
1256
//              }
 
1257
//              
 
1258
//              public override object TrackedVisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data)
 
1259
//              {
 
1260
//                      outputFormatter.PrintToken(Tokens.AddHandler);
 
1261
//                      outputFormatter.Space();
 
1262
//                      TrackedVisit(addHandlerStatement.EventExpression, data);
 
1263
//                      outputFormatter.PrintToken(Tokens.Comma);
 
1264
//                      outputFormatter.Space();
 
1265
//                      TrackedVisit(addHandlerStatement.HandlerExpression, data);
 
1266
//                      return null;
 
1267
//              }
 
1268
//              
 
1269
//              public override object TrackedVisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data)
 
1270
//              {
 
1271
//                      outputFormatter.PrintToken(Tokens.RemoveHandler);
 
1272
//                      outputFormatter.Space();
 
1273
//                      TrackedVisit(removeHandlerStatement.EventExpression, data);
 
1274
//                      outputFormatter.PrintToken(Tokens.Comma);
 
1275
//                      outputFormatter.Space();
 
1276
//                      TrackedVisit(removeHandlerStatement.HandlerExpression, data);
 
1277
//                      return null;
 
1278
//              }
 
1279
//              
 
1280
//              public override object TrackedVisitRaiseEventStatement(RaiseEventStatement raiseEventStatement, object data)
 
1281
//              {
 
1282
//                      outputFormatter.PrintToken(Tokens.RaiseEvent);
 
1283
//                      outputFormatter.Space();
 
1284
//                      outputFormatter.PrintIdentifier(raiseEventStatement.EventName);
 
1285
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
1286
//                      AppendCommaSeparatedList(raiseEventStatement.Arguments);
 
1287
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
1288
//                      return null;
 
1289
//              }
 
1290
//              
 
1291
//              public override object TrackedVisitEraseStatement(EraseStatement eraseStatement, object data)
 
1292
//              {
 
1293
//                      outputFormatter.PrintToken(Tokens.Erase);
 
1294
//                      outputFormatter.Space();
 
1295
//                      AppendCommaSeparatedList(eraseStatement.Expressions);
 
1296
//                      return null;
 
1297
//              }
 
1298
//              
 
1299
//              public override object TrackedVisitErrorStatement(ErrorStatement errorStatement, object data)
 
1300
//              {
 
1301
//                      outputFormatter.PrintToken(Tokens.Error);
 
1302
//                      outputFormatter.Space();
 
1303
//                      TrackedVisit(errorStatement.Expression, data);
 
1304
//                      return null;
 
1305
//              }
 
1306
//              
 
1307
//              public override object TrackedVisitOnErrorStatement(OnErrorStatement onErrorStatement, object data)
 
1308
//              {
 
1309
//                      outputFormatter.PrintToken(Tokens.On);
 
1310
//                      outputFormatter.Space();
 
1311
//                      outputFormatter.PrintToken(Tokens.Error);
 
1312
//                      outputFormatter.Space();
 
1313
//                      TrackedVisit(onErrorStatement.EmbeddedStatement, data);
 
1314
//                      return null;
 
1315
//              }
 
1316
//              
 
1317
//              public override object TrackedVisitReDimStatement(ReDimStatement reDimStatement, object data)
 
1318
//              {
 
1319
//                      outputFormatter.PrintToken(Tokens.ReDim);
 
1320
//                      outputFormatter.Space();
 
1321
//                      if (reDimStatement.IsPreserve) {
 
1322
//                              outputFormatter.PrintToken(Tokens.Preserve);
 
1323
//                              outputFormatter.Space();
 
1324
//                      }
 
1325
//                      
 
1326
//                      AppendCommaSeparatedList(reDimStatement.ReDimClauses);
 
1327
//                      return null;
 
1328
//              }
 
1329
//              
 
1330
//              public override object TrackedVisitExpressionStatement(ExpressionStatement expressionStatement, object data)
 
1331
//              {
 
1332
//                      TrackedVisit(expressionStatement.Expression, data);
 
1333
//                      return null;
 
1334
//              }
 
1335
//              
 
1336
//              public override object TrackedVisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
 
1337
//              {
 
1338
//                      if (localVariableDeclaration.Modifier != Modifiers.None) {
 
1339
//                              OutputModifier(localVariableDeclaration.Modifier & ~Modifiers.Dim);
 
1340
//                      }
 
1341
//                      if (!isUsingResourceAcquisition) {
 
1342
//                              if ((localVariableDeclaration.Modifier & Modifiers.Const) == 0) {
 
1343
//                                      outputFormatter.PrintToken(Tokens.Dim);
 
1344
//                              }
 
1345
//                              outputFormatter.Space();
 
1346
//                      }
 
1347
//                      currentVariableType = localVariableDeclaration.TypeReference;
 
1348
//                      
 
1349
//                      AppendCommaSeparatedList(localVariableDeclaration.Variables);
 
1350
//                      currentVariableType = null;
 
1351
//                      
 
1352
//                      return null;
 
1353
//              }
 
1354
//              
 
1355
//              public override object TrackedVisitReturnStatement(ReturnStatement returnStatement, object data)
 
1356
//              {
 
1357
//                      outputFormatter.PrintToken(Tokens.Return);
 
1358
//                      if (!returnStatement.Expression.IsNull) {
 
1359
//                              outputFormatter.Space();
 
1360
//                              TrackedVisit(returnStatement.Expression, data);
 
1361
//                      }
 
1362
//                      return null;
 
1363
//              }
 
1364
//              
 
1365
//              public override object TrackedVisitIfElseStatement(IfElseStatement ifElseStatement, object data)
 
1366
//              {
 
1367
//                      outputFormatter.PrintToken(Tokens.If);
 
1368
//                      outputFormatter.Space();
 
1369
//                      TrackedVisit(ifElseStatement.Condition, data);
 
1370
//                      outputFormatter.Space();
 
1371
//                      outputFormatter.PrintToken(Tokens.Then);
 
1372
//                      outputFormatter.NewLine();
 
1373
//                      
 
1374
//                      PrintIndentedBlock(ifElseStatement.TrueStatement);
 
1375
//                      
 
1376
//                      foreach (ElseIfSection elseIfSection in ifElseStatement.ElseIfSections) {
 
1377
//                              TrackedVisit(elseIfSection, data);
 
1378
//                      }
 
1379
//                      
 
1380
//                      if (ifElseStatement.HasElseStatements) {
 
1381
//                              outputFormatter.Indent();
 
1382
//                              outputFormatter.PrintToken(Tokens.Else);
 
1383
//                              outputFormatter.NewLine();
 
1384
//                              PrintIndentedBlock(ifElseStatement.FalseStatement);
 
1385
//                      }
 
1386
//                      
 
1387
//                      outputFormatter.Indent();
 
1388
//                      outputFormatter.PrintToken(Tokens.End);
 
1389
//                      outputFormatter.Space();
 
1390
//                      outputFormatter.PrintToken(Tokens.If);
 
1391
//                      return null;
 
1392
//              }
 
1393
//              
 
1394
//              public override object TrackedVisitElseIfSection(ElseIfSection elseIfSection, object data)
 
1395
//              {
 
1396
//                      outputFormatter.Indent();
 
1397
//                      outputFormatter.PrintToken(Tokens.ElseIf);
 
1398
//                      outputFormatter.Space();
 
1399
//                      TrackedVisit(elseIfSection.Condition, data);
 
1400
//                      outputFormatter.Space();
 
1401
//                      outputFormatter.PrintToken(Tokens.Then);
 
1402
//                      outputFormatter.NewLine();
 
1403
//                      PrintIndentedBlock(elseIfSection.EmbeddedStatement);
 
1404
//                      return null;
 
1405
//              }
 
1406
//              
 
1407
//              public override object TrackedVisitLabelStatement(LabelStatement labelStatement, object data)
 
1408
//              {
 
1409
//                      outputFormatter.PrintIdentifier(labelStatement.Label);
 
1410
//                      outputFormatter.PrintToken(Tokens.Colon);
 
1411
//                      return null;
 
1412
//              }
 
1413
//              
 
1414
//              public override object TrackedVisitGotoStatement(GotoStatement gotoStatement, object data)
 
1415
//              {
 
1416
//                      outputFormatter.PrintToken(Tokens.GoTo);
 
1417
//                      outputFormatter.Space();
 
1418
//                      outputFormatter.PrintIdentifier(gotoStatement.Label);
 
1419
//                      return null;
 
1420
//              }
 
1421
//              
 
1422
//              public override object TrackedVisitSwitchStatement(SwitchStatement switchStatement, object data)
 
1423
//              {
 
1424
//                      exitTokenStack.Push(Tokens.Select);
 
1425
//                      outputFormatter.PrintToken(Tokens.Select);
 
1426
//                      outputFormatter.Space();
 
1427
//                      outputFormatter.PrintToken(Tokens.Case);
 
1428
//                      outputFormatter.Space();
 
1429
//                      TrackedVisit(switchStatement.SwitchExpression, data);
 
1430
//                      outputFormatter.NewLine();
 
1431
//                      ++outputFormatter.IndentationLevel;
 
1432
//                      foreach (SwitchSection section in switchStatement.SwitchSections) {
 
1433
//                              TrackedVisit(section, data);
 
1434
//                      }
 
1435
//                      --outputFormatter.IndentationLevel;
 
1436
//                      outputFormatter.Indent();
 
1437
//                      outputFormatter.PrintToken(Tokens.End);
 
1438
//                      outputFormatter.Space();
 
1439
//                      outputFormatter.PrintToken(Tokens.Select);
 
1440
//                      exitTokenStack.Pop();
 
1441
//                      return null;
 
1442
//              }
 
1443
//              
 
1444
//              public override object TrackedVisitSwitchSection(SwitchSection switchSection, object data)
 
1445
//              {
 
1446
//                      outputFormatter.Indent();
 
1447
//                      outputFormatter.PrintToken(Tokens.Case);
 
1448
//                      outputFormatter.Space();
 
1449
//                      this.AppendCommaSeparatedList(switchSection.SwitchLabels);
 
1450
//                      outputFormatter.NewLine();
 
1451
//                      
 
1452
//                      PrintIndentedBlock(switchSection.Children);
 
1453
//                      
 
1454
//                      return null;
 
1455
//              }
 
1456
//              
 
1457
//              public override object TrackedVisitCaseLabel(CaseLabel caseLabel, object data)
 
1458
//              {
 
1459
//                      if (caseLabel.IsDefault) {
 
1460
//                              outputFormatter.PrintToken(Tokens.Else);
 
1461
//                      } else {
 
1462
//                              if (caseLabel.BinaryOperatorType != BinaryOperatorType.None) {
 
1463
//                                      switch (caseLabel.BinaryOperatorType) {
 
1464
//                                              case BinaryOperatorType.Equality:
 
1465
//                                                      outputFormatter.PrintToken(Tokens.Assign);
 
1466
//                                                      break;
 
1467
//                                              case BinaryOperatorType.InEquality:
 
1468
//                                                      outputFormatter.PrintToken(Tokens.LessThan);
 
1469
//                                                      outputFormatter.PrintToken(Tokens.GreaterThan);
 
1470
//                                                      break;
 
1471
//                                                      
 
1472
//                                              case BinaryOperatorType.GreaterThan:
 
1473
//                                                      outputFormatter.PrintToken(Tokens.GreaterThan);
 
1474
//                                                      break;
 
1475
//                                              case BinaryOperatorType.GreaterThanOrEqual:
 
1476
//                                                      outputFormatter.PrintToken(Tokens.GreaterEqual);
 
1477
//                                                      break;
 
1478
//                                              case BinaryOperatorType.LessThan:
 
1479
//                                                      outputFormatter.PrintToken(Tokens.LessThan);
 
1480
//                                                      break;
 
1481
//                                              case BinaryOperatorType.LessThanOrEqual:
 
1482
//                                                      outputFormatter.PrintToken(Tokens.LessEqual);
 
1483
//                                                      break;
 
1484
//                                      }
 
1485
//                                      outputFormatter.Space();
 
1486
//                              }
 
1487
//                              
 
1488
//                              TrackedVisit(caseLabel.Label, data);
 
1489
//                              if (!caseLabel.ToExpression.IsNull) {
 
1490
//                                      outputFormatter.Space();
 
1491
//                                      outputFormatter.PrintToken(Tokens.To);
 
1492
//                                      outputFormatter.Space();
 
1493
//                                      TrackedVisit(caseLabel.ToExpression, data);
 
1494
//                              }
 
1495
//                      }
 
1496
//                      
 
1497
//                      return null;
 
1498
//              }
 
1499
//              
 
1500
//              public override object TrackedVisitStopStatement(StopStatement stopStatement, object data)
 
1501
//              {
 
1502
//                      outputFormatter.PrintToken(Tokens.Stop);
 
1503
//                      return null;
 
1504
//              }
 
1505
//              
 
1506
//              public override object TrackedVisitResumeStatement(ResumeStatement resumeStatement, object data)
 
1507
//              {
 
1508
//                      outputFormatter.PrintToken(Tokens.Resume);
 
1509
//                      outputFormatter.Space();
 
1510
//                      if (resumeStatement.IsResumeNext) {
 
1511
//                              outputFormatter.PrintToken(Tokens.Next);
 
1512
//                      } else {
 
1513
//                              outputFormatter.PrintIdentifier(resumeStatement.LabelName);
 
1514
//                      }
 
1515
//                      return null;
 
1516
//              }
 
1517
//              
 
1518
//              public override object TrackedVisitEndStatement(EndStatement endStatement, object data)
 
1519
//              {
 
1520
//                      outputFormatter.PrintToken(Tokens.End);
 
1521
//                      return null;
 
1522
//              }
 
1523
//              
 
1524
//              public override object TrackedVisitContinueStatement(ContinueStatement continueStatement, object data)
 
1525
//              {
 
1526
//                      outputFormatter.PrintToken(Tokens.Continue);
 
1527
//                      outputFormatter.Space();
 
1528
//                      switch (continueStatement.ContinueType) {
 
1529
//                              case ContinueType.Do:
 
1530
//                                      outputFormatter.PrintToken(Tokens.Do);
 
1531
//                                      break;
 
1532
//                              case ContinueType.For:
 
1533
//                                      outputFormatter.PrintToken(Tokens.For);
 
1534
//                                      break;
 
1535
//                              case ContinueType.While:
 
1536
//                                      outputFormatter.PrintToken(Tokens.While);
 
1537
//                                      break;
 
1538
//                              default:
 
1539
//                                      outputFormatter.PrintToken(exitTokenStack.Peek());
 
1540
//                                      break;
 
1541
//                      }
 
1542
//                      return null;
 
1543
//              }
 
1544
//              
 
1545
//              public override object TrackedVisitDoLoopStatement(DoLoopStatement doLoopStatement, object data)
 
1546
//              {
 
1547
//                      if (doLoopStatement.ConditionPosition == ConditionPosition.None) {
 
1548
//                              Error(String.Format("Unknown condition position for loop : {0}.", doLoopStatement), doLoopStatement.StartLocation);
 
1549
//                      }
 
1550
//                      
 
1551
//                      if (doLoopStatement.ConditionPosition == ConditionPosition.Start) {
 
1552
//                              switch (doLoopStatement.ConditionType) {
 
1553
//                                      case ConditionType.DoWhile:
 
1554
//                                              exitTokenStack.Push(Tokens.Do);
 
1555
//                                              outputFormatter.PrintToken(Tokens.Do);
 
1556
//                                              outputFormatter.Space();
 
1557
//                                              outputFormatter.PrintToken(Tokens.While);
 
1558
//                                              break;
 
1559
//                                      case ConditionType.While:
 
1560
//                                              exitTokenStack.Push(Tokens.While);
 
1561
//                                              outputFormatter.PrintToken(Tokens.While);
 
1562
//                                              break;
 
1563
//                                      case ConditionType.Until:
 
1564
//                                              exitTokenStack.Push(Tokens.Do);
 
1565
//                                              outputFormatter.PrintToken(Tokens.Do);
 
1566
//                                              outputFormatter.Space();
 
1567
//                                              outputFormatter.PrintToken(Tokens.While);
 
1568
//                                              break;
 
1569
//                                      default:
 
1570
//                                              throw new InvalidOperationException();
 
1571
//                              }
 
1572
//                              outputFormatter.Space();
 
1573
//                              TrackedVisit(doLoopStatement.Condition, null);
 
1574
//                      } else {
 
1575
//                              exitTokenStack.Push(Tokens.Do);
 
1576
//                              outputFormatter.PrintToken(Tokens.Do);
 
1577
//                      }
 
1578
//                      
 
1579
//                      outputFormatter.NewLine();
 
1580
//                      
 
1581
//                      PrintIndentedBlock(doLoopStatement.EmbeddedStatement);
 
1582
//                      
 
1583
//                      outputFormatter.Indent();
 
1584
//                      if (doLoopStatement.ConditionPosition == ConditionPosition.Start && doLoopStatement.ConditionType == ConditionType.While) {
 
1585
//                              outputFormatter.PrintToken(Tokens.End);
 
1586
//                              outputFormatter.Space();
 
1587
//                              outputFormatter.PrintToken(Tokens.While);
 
1588
//                      } else {
 
1589
//                              outputFormatter.PrintToken(Tokens.Loop);
 
1590
//                      }
 
1591
//                      
 
1592
//                      if (doLoopStatement.ConditionPosition == ConditionPosition.End && !doLoopStatement.Condition.IsNull) {
 
1593
//                              outputFormatter.Space();
 
1594
//                              switch (doLoopStatement.ConditionType) {
 
1595
//                                      case ConditionType.While:
 
1596
//                                      case ConditionType.DoWhile:
 
1597
//                                              outputFormatter.PrintToken(Tokens.While);
 
1598
//                                              break;
 
1599
//                                      case ConditionType.Until:
 
1600
//                                              outputFormatter.PrintToken(Tokens.Until);
 
1601
//                                              break;
 
1602
//                              }
 
1603
//                              outputFormatter.Space();
 
1604
//                              TrackedVisit(doLoopStatement.Condition, null);
 
1605
//                      }
 
1606
//                      exitTokenStack.Pop();
 
1607
//                      return null;
 
1608
//              }
 
1609
//              
 
1610
//              public override object TrackedVisitForeachStatement(ForeachStatement foreachStatement, object data)
 
1611
//              {
 
1612
//                      exitTokenStack.Push(Tokens.For);
 
1613
//                      outputFormatter.PrintToken(Tokens.For);
 
1614
//                      outputFormatter.Space();
 
1615
//                      outputFormatter.PrintToken(Tokens.Each);
 
1616
//                      outputFormatter.Space();
 
1617
//                      
 
1618
//                      // loop control variable
 
1619
//                      outputFormatter.PrintIdentifier(foreachStatement.VariableName);
 
1620
//                      if (!foreachStatement.TypeReference.IsNull) {
 
1621
//                              outputFormatter.Space();
 
1622
//                              outputFormatter.PrintToken(Tokens.As);
 
1623
//                              outputFormatter.Space();
 
1624
//                              TrackedVisit(foreachStatement.TypeReference, data);
 
1625
//                      }
 
1626
//                      
 
1627
//                      outputFormatter.Space();
 
1628
//                      outputFormatter.PrintToken(Tokens.In);
 
1629
//                      outputFormatter.Space();
 
1630
//                      
 
1631
//                      TrackedVisit(foreachStatement.Expression, data);
 
1632
//                      outputFormatter.NewLine();
 
1633
//                      
 
1634
//                      PrintIndentedBlock(foreachStatement.EmbeddedStatement);
 
1635
//                      
 
1636
//                      outputFormatter.Indent();
 
1637
//                      outputFormatter.PrintToken(Tokens.Next);
 
1638
//                      if (!foreachStatement.NextExpression.IsNull) {
 
1639
//                              outputFormatter.Space();
 
1640
//                              TrackedVisit(foreachStatement.NextExpression, data);
 
1641
//                      }
 
1642
//                      exitTokenStack.Pop();
 
1643
//                      return null;
 
1644
//              }
 
1645
//              
 
1646
//              public override object TrackedVisitLockStatement(LockStatement lockStatement, object data)
 
1647
//              {
 
1648
//                      outputFormatter.PrintToken(Tokens.SyncLock);
 
1649
//                      outputFormatter.Space();
 
1650
//                      TrackedVisit(lockStatement.LockExpression, data);
 
1651
//                      outputFormatter.NewLine();
 
1652
//                      
 
1653
//                      PrintIndentedBlock(lockStatement.EmbeddedStatement);
 
1654
//                      
 
1655
//                      outputFormatter.Indent();
 
1656
//                      outputFormatter.PrintToken(Tokens.End);
 
1657
//                      outputFormatter.Space();
 
1658
//                      outputFormatter.PrintToken(Tokens.SyncLock);
 
1659
//                      return null;
 
1660
//              }
 
1661
//              
 
1662
//              bool isUsingResourceAcquisition;
 
1663
//              
 
1664
//              public override object TrackedVisitUsingStatement(UsingStatement usingStatement, object data)
 
1665
//              {
 
1666
//                      outputFormatter.PrintToken(Tokens.Using);
 
1667
//                      outputFormatter.Space();
 
1668
//                      
 
1669
//                      isUsingResourceAcquisition = true;
 
1670
//                      TrackedVisit(usingStatement.ResourceAcquisition, data);
 
1671
//                      isUsingResourceAcquisition = false;
 
1672
//                      outputFormatter.NewLine();
 
1673
//                      
 
1674
//                      PrintIndentedBlock(usingStatement.EmbeddedStatement);
 
1675
//                      
 
1676
//                      outputFormatter.Indent();
 
1677
//                      outputFormatter.PrintToken(Tokens.End);
 
1678
//                      outputFormatter.Space();
 
1679
//                      outputFormatter.PrintToken(Tokens.Using);
 
1680
//                      
 
1681
//                      return null;
 
1682
//              }
 
1683
//              
 
1684
//              public override object TrackedVisitWithStatement(WithStatement withStatement, object data)
 
1685
//              {
 
1686
//                      outputFormatter.PrintToken(Tokens.With);
 
1687
//                      outputFormatter.Space();
 
1688
//                      TrackedVisit(withStatement.Expression, data);
 
1689
//                      outputFormatter.NewLine();
 
1690
//                      
 
1691
//                      PrintIndentedBlock(withStatement.Body);
 
1692
//                      
 
1693
//                      outputFormatter.PrintToken(Tokens.End);
 
1694
//                      outputFormatter.Space();
 
1695
//                      outputFormatter.PrintToken(Tokens.With);
 
1696
//                      return null;
 
1697
//              }
 
1698
//              
 
1699
//              public override object TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 
1700
//              {
 
1701
//                      exitTokenStack.Push(Tokens.Try);
 
1702
//                      outputFormatter.PrintToken(Tokens.Try);
 
1703
//                      outputFormatter.NewLine();
 
1704
//                      
 
1705
//                      PrintIndentedBlock(tryCatchStatement.StatementBlock);
 
1706
//                      
 
1707
//                      foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
 
1708
//                              TrackedVisit(catchClause, data);
 
1709
//                      }
 
1710
//                      
 
1711
//                      if (!tryCatchStatement.FinallyBlock.IsNull) {
 
1712
//                              outputFormatter.Indent();
 
1713
//                              outputFormatter.PrintToken(Tokens.Finally);
 
1714
//                              outputFormatter.NewLine();
 
1715
//                              PrintIndentedBlock(tryCatchStatement.FinallyBlock);
 
1716
//                      }
 
1717
//                      outputFormatter.Indent();
 
1718
//                      outputFormatter.PrintToken(Tokens.End);
 
1719
//                      outputFormatter.Space();
 
1720
//                      outputFormatter.PrintToken(Tokens.Try);
 
1721
//                      exitTokenStack.Pop();
 
1722
//                      return null;
 
1723
//              }
 
1724
//              
 
1725
//              public override object TrackedVisitCatchClause(CatchClause catchClause, object data)
 
1726
//              {
 
1727
//                      outputFormatter.Indent();
 
1728
//                      outputFormatter.PrintToken(Tokens.Catch);
 
1729
//                      
 
1730
//                      if (!catchClause.TypeReference.IsNull) {
 
1731
//                              outputFormatter.Space();
 
1732
//                              if (catchClause.VariableName.Length > 0) {
 
1733
//                                      outputFormatter.PrintIdentifier(catchClause.VariableName);
 
1734
//                              } else {
 
1735
//                                      outputFormatter.PrintIdentifier("generatedExceptionName");
 
1736
//                              }
 
1737
//                              outputFormatter.Space();
 
1738
//                              outputFormatter.PrintToken(Tokens.As);
 
1739
//                              outputFormatter.Space();
 
1740
//                              outputFormatter.PrintIdentifier(catchClause.TypeReference.Type);
 
1741
//                      }
 
1742
//                      
 
1743
//                      if (!catchClause.Condition.IsNull)  {
 
1744
//                              outputFormatter.Space();
 
1745
//                              outputFormatter.PrintToken(Tokens.When);
 
1746
//                              outputFormatter.Space();
 
1747
//                              TrackedVisit(catchClause.Condition, data);
 
1748
//                      }
 
1749
//                      outputFormatter.NewLine();
 
1750
//                      
 
1751
//                      PrintIndentedBlock(catchClause.StatementBlock);
 
1752
//                      
 
1753
//                      return null;
 
1754
//              }
 
1755
//              
 
1756
//              public override object TrackedVisitThrowStatement(ThrowStatement throwStatement, object data)
 
1757
//              {
 
1758
//                      outputFormatter.PrintToken(Tokens.Throw);
 
1759
//                      if (!throwStatement.Expression.IsNull) {
 
1760
//                              outputFormatter.Space();
 
1761
//                              TrackedVisit(throwStatement.Expression, data);
 
1762
//                      }
 
1763
//                      return null;
 
1764
//              }
 
1765
//              
 
1766
//              public override object TrackedVisitExitStatement(ExitStatement exitStatement, object data)
 
1767
//              {
 
1768
//                      outputFormatter.PrintToken(Tokens.Exit);
 
1769
//                      if (exitStatement.ExitType != ExitType.None) {
 
1770
//                              outputFormatter.Space();
 
1771
//                              switch (exitStatement.ExitType) {
 
1772
//                                      case ExitType.Sub:
 
1773
//                                              outputFormatter.PrintToken(Tokens.Sub);
 
1774
//                                              break;
 
1775
//                                      case ExitType.Function:
 
1776
//                                              outputFormatter.PrintToken(Tokens.Function);
 
1777
//                                              break;
 
1778
//                                      case ExitType.Property:
 
1779
//                                              outputFormatter.PrintToken(Tokens.Property);
 
1780
//                                              break;
 
1781
//                                      case ExitType.Do:
 
1782
//                                              outputFormatter.PrintToken(Tokens.Do);
 
1783
//                                              break;
 
1784
//                                      case ExitType.For:
 
1785
//                                              outputFormatter.PrintToken(Tokens.For);
 
1786
//                                              break;
 
1787
//                                      case ExitType.Try:
 
1788
//                                              outputFormatter.PrintToken(Tokens.Try);
 
1789
//                                              break;
 
1790
//                                      case ExitType.While:
 
1791
//                                              outputFormatter.PrintToken(Tokens.While);
 
1792
//                                              break;
 
1793
//                                      case ExitType.Select:
 
1794
//                                              outputFormatter.PrintToken(Tokens.Select);
 
1795
//                                              break;
 
1796
//                                      default:
 
1797
//                                              Error(String.Format("Unsupported exit type : {0}", exitStatement.ExitType), exitStatement.StartLocation);
 
1798
//                                              break;
 
1799
//                              }
 
1800
//                      }
 
1801
//                      
 
1802
//                      return null;
 
1803
//              }
 
1804
//              
 
1805
//              public override object TrackedVisitForNextStatement(ForNextStatement forNextStatement, object data)
 
1806
//              {
 
1807
//                      exitTokenStack.Push(Tokens.For);
 
1808
//                      outputFormatter.PrintToken(Tokens.For);
 
1809
//                      outputFormatter.Space();
 
1810
//                      
 
1811
//                      if (!forNextStatement.LoopVariableExpression.IsNull) {
 
1812
//                              TrackedVisit(forNextStatement.LoopVariableExpression, data);
 
1813
//                      } else {
 
1814
//                              outputFormatter.PrintIdentifier(forNextStatement.VariableName);
 
1815
//                              
 
1816
//                              if (!forNextStatement.TypeReference.IsNull) {
 
1817
//                                      outputFormatter.Space();
 
1818
//                                      outputFormatter.PrintToken(Tokens.As);
 
1819
//                                      outputFormatter.Space();
 
1820
//                                      TrackedVisit(forNextStatement.TypeReference, data);
 
1821
//                              }
 
1822
//                      }
 
1823
//                      
 
1824
//                      outputFormatter.Space();
 
1825
//                      outputFormatter.PrintToken(Tokens.Assign);
 
1826
//                      outputFormatter.Space();
 
1827
//                      
 
1828
//                      TrackedVisit(forNextStatement.Start, data);
 
1829
//                      
 
1830
//                      outputFormatter.Space();
 
1831
//                      outputFormatter.PrintToken(Tokens.To);
 
1832
//                      outputFormatter.Space();
 
1833
//                      
 
1834
//                      TrackedVisit(forNextStatement.End, data);
 
1835
//                      
 
1836
//                      if (!forNextStatement.Step.IsNull) {
 
1837
//                              outputFormatter.Space();
 
1838
//                              outputFormatter.PrintToken(Tokens.Step);
 
1839
//                              outputFormatter.Space();
 
1840
//                              TrackedVisit(forNextStatement.Step, data);
 
1841
//                      }
 
1842
//                      outputFormatter.NewLine();
 
1843
//                      
 
1844
//                      PrintIndentedBlock(forNextStatement.EmbeddedStatement);
 
1845
//                      
 
1846
//                      outputFormatter.Indent();
 
1847
//                      outputFormatter.PrintToken(Tokens.Next);
 
1848
//                      
 
1849
//                      if (forNextStatement.NextExpressions.Count > 0) {
 
1850
//                              outputFormatter.Space();
 
1851
//                              AppendCommaSeparatedList(forNextStatement.NextExpressions);
 
1852
//                      }
 
1853
//                      exitTokenStack.Pop();
 
1854
//                      return null;
 
1855
//              }
 
1856
//              #endregion
 
1857
//              
 
1858
//              #region Expressions
 
1859
//              
 
1860
//              public override object TrackedVisitClassReferenceExpression(ClassReferenceExpression classReferenceExpression, object data)
 
1861
//              {
 
1862
//                      outputFormatter.PrintToken(Tokens.MyClass);
 
1863
//                      return null;
 
1864
//              }
 
1865
//              
 
1866
//              
 
1867
//              static string ConvertCharLiteral(char ch)
 
1868
//              {
 
1869
//                      if (Char.IsControl(ch)) {
 
1870
//                              string charName = GetCharName(ch);
 
1871
//                              if (charName != null)
 
1872
//                                      return "ControlChars." + charName;
 
1873
//                              else
 
1874
//                                      return "ChrW(" + ((int)ch).ToString() + ")";
 
1875
//                      } else if (ch == '"') {
 
1876
//                              return "\"\"\"\"C";
 
1877
//                      } else {
 
1878
//                              return "\"" + ch.ToString() + "\"C";
 
1879
//                      }
 
1880
//              }
 
1881
//              
 
1882
//              static string GetCharName(char ch)
 
1883
//              {
 
1884
//                      switch (ch) {
 
1885
//                              case '\b':
 
1886
//                                      return "Back";
 
1887
//                              case '\r':
 
1888
//                                      return "Cr";
 
1889
//                              case '\f':
 
1890
//                                      return "FormFeed";
 
1891
//                              case '\n':
 
1892
//                                      return "Lf";
 
1893
//                              case '\0':
 
1894
//                                      return "NullChar";
 
1895
//                              case '\t':
 
1896
//                                      return "Tab";
 
1897
//                              case '\v':
 
1898
//                                      return "VerticalTab";
 
1899
//                              default:
 
1900
//                                      return null;
 
1901
//                      }
 
1902
//              }
 
1903
//              
 
1904
//              static string ConvertString(string str)
 
1905
//              {
 
1906
//                      StringBuilder sb = new StringBuilder();
 
1907
//                      bool inString = false;
 
1908
//                      foreach (char ch in str) {
 
1909
//                              if (char.IsControl(ch)) {
 
1910
//                                      if (inString) {
 
1911
//                                              sb.Append('"');
 
1912
//                                              inString = false;
 
1913
//                                      }
 
1914
//                                      if (sb.Length > 0)
 
1915
//                                              sb.Append(" & ");
 
1916
//                                      string charName = GetCharName(ch);
 
1917
//                                      if (charName != null)
 
1918
//                                              sb.Append("vb" + charName);
 
1919
//                                      else
 
1920
//                                              sb.Append("ChrW(" + ((int)ch) + ")");
 
1921
//                              } else {
 
1922
//                                      if (!inString) {
 
1923
//                                              if (sb.Length > 0)
 
1924
//                                                      sb.Append(" & ");
 
1925
//                                              sb.Append('"');
 
1926
//                                              inString = true;
 
1927
//                                      }
 
1928
//                                      if (ch == '"') {
 
1929
//                                              sb.Append("\"\"");
 
1930
//                                      } else {
 
1931
//                                              sb.Append(ch);
 
1932
//                                      }
 
1933
//                              }
 
1934
//                      }
 
1935
//                      if (inString)
 
1936
//                              sb.Append('"');
 
1937
//                      if (sb.Length == 0)
 
1938
//                              return "\"\"";
 
1939
//                      return sb.ToString();
 
1940
//              }
 
1941
//              
 
1942
//              public override object TrackedVisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
 
1943
//              {
 
1944
//                      outputFormatter.PrintText(ToVBNetString(primitiveExpression));
 
1945
//                      return null;
 
1946
//              }
 
1947
//              
 
1948
//              internal static string ToVBNetString(PrimitiveExpression primitiveExpression)
 
1949
//              {
 
1950
//                      object val = primitiveExpression.Value;
 
1951
//                      if (val == null) {
 
1952
//                              return "Nothing";
 
1953
//                      }
 
1954
//                      if (val is bool) {
 
1955
//                              if ((bool)primitiveExpression.Value) {
 
1956
//                                      return "True";
 
1957
//                              } else {
 
1958
//                                      return "False";
 
1959
//                              }
 
1960
//                      }
 
1961
//                      
 
1962
//                      if (val is string) {
 
1963
//                              return ConvertString((string)val);
 
1964
//                      }
 
1965
//                      
 
1966
//                      if (val is char) {
 
1967
//                              return ConvertCharLiteral((char)primitiveExpression.Value);
 
1968
//                      }
 
1969
//
 
1970
//                      if (val is decimal) {
 
1971
//                              return ((decimal)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "D";
 
1972
//                      }
 
1973
//                      
 
1974
//                      if (val is float) {
 
1975
//                              return ((float)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "F";
 
1976
//                      }
 
1977
//                      
 
1978
//                      if (val is double) {
 
1979
//                              string text = ((double)val).ToString(NumberFormatInfo.InvariantInfo);
 
1980
//                              if (text.IndexOf('.') < 0 && text.IndexOf('E') < 0)
 
1981
//                                      return text + ".0";
 
1982
//                              else
 
1983
//                                      return text;
 
1984
//                      }
 
1985
//                      
 
1986
//                      if (val is IFormattable) {
 
1987
//                              StringBuilder b = new StringBuilder();
 
1988
//                              if (primitiveExpression.LiteralFormat == LiteralFormat.HexadecimalNumber) {
 
1989
//                                      b.Append("&H");
 
1990
//                                      b.Append(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo));
 
1991
//                              } else {
 
1992
//                                      b.Append(((IFormattable)val).ToString(null, NumberFormatInfo.InvariantInfo));
 
1993
//                              }
 
1994
//                              if (val is ushort || val is uint || val is ulong) {
 
1995
//                                      b.Append('U');
 
1996
//                                      if (val is uint)
 
1997
//                                              b.Append('I');
 
1998
//                              }
 
1999
//                              if (val is long || val is ulong)
 
2000
//                                      b.Append('L');
 
2001
//                              if (val is short || val is ushort)
 
2002
//                                      b.Append('S');
 
2003
//                              return b.ToString();
 
2004
//                      } else {
 
2005
//                              return val.ToString();
 
2006
//                      }
 
2007
//              }
 
2008
//              
 
2009
//              public override object TrackedVisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data)
 
2010
//              {
 
2011
//                      int  op = 0;
 
2012
//                      switch (binaryOperatorExpression.Op) {
 
2013
//                              case BinaryOperatorType.Concat:
 
2014
//                                      op = Tokens.ConcatString;
 
2015
//                                      break;
 
2016
//                                      
 
2017
//                              case BinaryOperatorType.Add:
 
2018
//                                      op = Tokens.Plus;
 
2019
//                                      break;
 
2020
//                                      
 
2021
//                              case BinaryOperatorType.Subtract:
 
2022
//                                      op = Tokens.Minus;
 
2023
//                                      break;
 
2024
//                                      
 
2025
//                              case BinaryOperatorType.Multiply:
 
2026
//                                      op = Tokens.Times;
 
2027
//                                      break;
 
2028
//                                      
 
2029
//                              case BinaryOperatorType.Divide:
 
2030
//                                      op = Tokens.Div;
 
2031
//                                      break;
 
2032
//                                      
 
2033
//                              case BinaryOperatorType.DivideInteger:
 
2034
//                                      op = Tokens.DivInteger;
 
2035
//                                      break;
 
2036
//                                      
 
2037
//                              case BinaryOperatorType.Modulus:
 
2038
//                                      op = Tokens.Mod;
 
2039
//                                      break;
 
2040
//                                      
 
2041
//                              case BinaryOperatorType.ShiftLeft:
 
2042
//                                      op = Tokens.ShiftLeft;
 
2043
//                                      break;
 
2044
//                                      
 
2045
//                              case BinaryOperatorType.ShiftRight:
 
2046
//                                      op = Tokens.ShiftRight;
 
2047
//                                      break;
 
2048
//                                      
 
2049
//                              case BinaryOperatorType.BitwiseAnd:
 
2050
//                                      op = Tokens.And;
 
2051
//                                      break;
 
2052
//                              case BinaryOperatorType.BitwiseOr:
 
2053
//                                      op = Tokens.Or;
 
2054
//                                      break;
 
2055
//                              case BinaryOperatorType.ExclusiveOr:
 
2056
//                                      op = Tokens.Xor;
 
2057
//                                      break;
 
2058
//                                      
 
2059
//                              case BinaryOperatorType.LogicalAnd:
 
2060
//                                      op = Tokens.AndAlso;
 
2061
//                                      break;
 
2062
//                              case BinaryOperatorType.LogicalOr:
 
2063
//                                      op = Tokens.OrElse;
 
2064
//                                      break;
 
2065
//                              case BinaryOperatorType.ReferenceEquality:
 
2066
//                                      op = Tokens.Is;
 
2067
//                                      break;
 
2068
//                              case BinaryOperatorType.ReferenceInequality:
 
2069
//                                      op = Tokens.IsNot;
 
2070
//                                      break;
 
2071
//                                      
 
2072
//                              case BinaryOperatorType.Equality:
 
2073
//                                      op = Tokens.Assign;
 
2074
//                                      break;
 
2075
//                              case BinaryOperatorType.GreaterThan:
 
2076
//                                      op = Tokens.GreaterThan;
 
2077
//                                      break;
 
2078
//                              case BinaryOperatorType.GreaterThanOrEqual:
 
2079
//                                      op = Tokens.GreaterEqual;
 
2080
//                                      break;
 
2081
//                              case BinaryOperatorType.InEquality:
 
2082
//                                      op = Tokens.NotEqual;
 
2083
//                                      break;
 
2084
//                              case BinaryOperatorType.NullCoalescing:
 
2085
//                                      outputFormatter.PrintText("If(");
 
2086
//                                      TrackedVisit(binaryOperatorExpression.Left, data);
 
2087
//                                      outputFormatter.PrintToken(Tokens.Comma);
 
2088
//                                      outputFormatter.Space();
 
2089
//                                      TrackedVisit(binaryOperatorExpression.Right, data);
 
2090
//                                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2091
//                                      return null;
 
2092
//                              case BinaryOperatorType.DictionaryAccess:
 
2093
//                                      {
 
2094
//                                              PrimitiveExpression pright = binaryOperatorExpression.Right as PrimitiveExpression;
 
2095
//                                              TrackedVisit(binaryOperatorExpression.Left, data);
 
2096
//                                              if (pright != null && pright.Value is string) {
 
2097
//                                                      outputFormatter.PrintText("!" + (string)pright.Value);
 
2098
//                                              } else {
 
2099
//                                                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2100
//                                                      TrackedVisit(binaryOperatorExpression.Right, data);
 
2101
//                                                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2102
//                                              }
 
2103
//                                              return null;
 
2104
//                                      }
 
2105
//                              case BinaryOperatorType.LessThan:
 
2106
//                                      op = Tokens.LessThan;
 
2107
//                                      break;
 
2108
//                              case BinaryOperatorType.LessThanOrEqual:
 
2109
//                                      op = Tokens.LessEqual;
 
2110
//                                      break;
 
2111
//                      }
 
2112
//                      
 
2113
//                      
 
2114
//                      BinaryOperatorExpression childBoe = binaryOperatorExpression.Left as BinaryOperatorExpression;
 
2115
//                      bool requireParenthesis = childBoe != null && OperatorPrecedence.ComparePrecedenceVB(binaryOperatorExpression.Op, childBoe.Op) > 0;
 
2116
//                      if (requireParenthesis)
 
2117
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2118
//                      TrackedVisit(binaryOperatorExpression.Left, data);
 
2119
//                      if (requireParenthesis)
 
2120
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2121
//                      
 
2122
//                      outputFormatter.Space();
 
2123
//                      outputFormatter.PrintToken(op);
 
2124
//                      outputFormatter.Space();
 
2125
//                      
 
2126
//                      childBoe = binaryOperatorExpression.Right as BinaryOperatorExpression;
 
2127
//                      requireParenthesis = childBoe != null && OperatorPrecedence.ComparePrecedenceVB(binaryOperatorExpression.Op, childBoe.Op) >= 0;
 
2128
//                      if (requireParenthesis)
 
2129
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2130
//                      TrackedVisit(binaryOperatorExpression.Right, data);
 
2131
//                      if (requireParenthesis)
 
2132
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2133
//                      
 
2134
//                      return null;
 
2135
//              }
 
2136
//              
 
2137
//              public override object TrackedVisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
 
2138
//              {
 
2139
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2140
//                      TrackedVisit(parenthesizedExpression.Expression, data);
 
2141
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2142
//                      return null;
 
2143
//              }
 
2144
//              
 
2145
//              public override object TrackedVisitInvocationExpression(InvocationExpression invocationExpression, object data)
 
2146
//              {
 
2147
//                      TrackedVisit(invocationExpression.TargetObject, data);
 
2148
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2149
//                      AppendCommaSeparatedList(invocationExpression.Arguments);
 
2150
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2151
//                      return null;
 
2152
//              }
 
2153
//              
 
2154
//              void PrintTypeArguments(List<TypeReference> typeArguments)
 
2155
//              {
 
2156
//                      if (typeArguments != null && typeArguments.Count > 0) {
 
2157
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2158
//                              outputFormatter.PrintToken(Tokens.Of);
 
2159
//                              outputFormatter.Space();
 
2160
//                              AppendCommaSeparatedList(typeArguments);
 
2161
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2162
//                      }
 
2163
//              }
 
2164
//              
 
2165
//              public override object TrackedVisitIdentifierExpression(SimpleNameExpression identifierExpression, object data)
 
2166
//              {
 
2167
//                      outputFormatter.PrintIdentifier(identifierExpression.Identifier);
 
2168
//                      PrintTypeArguments(identifierExpression.TypeArguments);
 
2169
//                      return null;
 
2170
//              }
 
2171
//              
 
2172
//              public override object TrackedVisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
 
2173
//              {
 
2174
//                      TrackedVisit(typeReferenceExpression.TypeReference, data);
 
2175
//                      return null;
 
2176
//              }
 
2177
//              
 
2178
//              public override object TrackedVisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
 
2179
//              {
 
2180
//                      switch (unaryOperatorExpression.Op) {
 
2181
//                              case UnaryOperatorType.Not:
 
2182
//                              case UnaryOperatorType.BitNot:
 
2183
//                                      outputFormatter.PrintToken(Tokens.Not);
 
2184
//                                      outputFormatter.Space();
 
2185
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2186
//                                      return null;
 
2187
//                                      
 
2188
//                              case UnaryOperatorType.Decrement:
 
2189
//                                      outputFormatter.PrintText("System.Threading.Interlocked.Decrement(");
 
2190
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2191
//                                      outputFormatter.PrintText(")");
 
2192
//                                      return null;
 
2193
//                                      
 
2194
//                              case UnaryOperatorType.Increment:
 
2195
//                                      outputFormatter.PrintText("System.Threading.Interlocked.Increment(");
 
2196
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2197
//                                      outputFormatter.PrintText(")");
 
2198
//                                      return null;
 
2199
//                                      
 
2200
//                              case UnaryOperatorType.Minus:
 
2201
//                                      outputFormatter.PrintToken(Tokens.Minus);
 
2202
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2203
//                                      return null;
 
2204
//                                      
 
2205
//                              case UnaryOperatorType.Plus:
 
2206
//                                      outputFormatter.PrintToken(Tokens.Plus);
 
2207
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2208
//                                      return null;
 
2209
//                                      
 
2210
//                              case UnaryOperatorType.PostDecrement:
 
2211
//                                      outputFormatter.PrintText("System.Math.Max(System.Threading.Interlocked.Decrement(");
 
2212
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2213
//                                      outputFormatter.PrintText("),");
 
2214
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2215
//                                      outputFormatter.PrintText(" + 1)");
 
2216
//                                      return null;
 
2217
//                                      
 
2218
//                              case UnaryOperatorType.PostIncrement:
 
2219
//                                      outputFormatter.PrintText("System.Math.Max(System.Threading.Interlocked.Increment(");
 
2220
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2221
//                                      outputFormatter.PrintText("),");
 
2222
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2223
//                                      outputFormatter.PrintText(" - 1)");
 
2224
//                                      return null;
 
2225
//                                      
 
2226
//                              case UnaryOperatorType.Dereference:
 
2227
//                                      outputFormatter.PrintToken(Tokens.Times);
 
2228
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2229
//                                      return null;
 
2230
//                              case UnaryOperatorType.AddressOf:
 
2231
//                                      outputFormatter.PrintToken(Tokens.AddressOf);
 
2232
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2233
//                                      return null;
 
2234
//                              default:
 
2235
//                                      Error("unknown unary operator: " + unaryOperatorExpression.Op.ToString(), unaryOperatorExpression.StartLocation);
 
2236
//                                      outputFormatter.PrintText(unaryOperatorExpression.Op.ToString());
 
2237
//                                      outputFormatter.PrintText("(");
 
2238
//                                      TrackedVisit(unaryOperatorExpression.Expression, data);
 
2239
//                                      outputFormatter.PrintText(")");
 
2240
//                                      return null;
 
2241
//                      }
 
2242
//              }
 
2243
//              
 
2244
//              public override object TrackedVisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
 
2245
//              {
 
2246
//                      int  op = 0;
 
2247
//                      bool unsupportedOpAssignment = false;
 
2248
//                      switch (assignmentExpression.Op) {
 
2249
//                              case AssignmentOperatorType.Assign:
 
2250
//                                      op = Tokens.Assign;
 
2251
//                                      break;
 
2252
//                              case AssignmentOperatorType.Add:
 
2253
//                                      op = Tokens.PlusAssign;
 
2254
//                                      break;
 
2255
//                              case AssignmentOperatorType.Subtract:
 
2256
//                                      op = Tokens.MinusAssign;
 
2257
//                                      break;
 
2258
//                              case AssignmentOperatorType.Multiply:
 
2259
//                                      op = Tokens.TimesAssign;
 
2260
//                                      break;
 
2261
//                              case AssignmentOperatorType.Divide:
 
2262
//                                      op = Tokens.DivAssign;
 
2263
//                                      break;
 
2264
//                              case AssignmentOperatorType.ShiftLeft:
 
2265
//                                      op = Tokens.ShiftLeftAssign;
 
2266
//                                      break;
 
2267
//                              case AssignmentOperatorType.ShiftRight:
 
2268
//                                      op = Tokens.ShiftRightAssign;
 
2269
//                                      break;
 
2270
//                                      
 
2271
//                              case AssignmentOperatorType.ExclusiveOr:
 
2272
//                                      op = Tokens.Xor;
 
2273
//                                      unsupportedOpAssignment = true;
 
2274
//                                      break;
 
2275
//                              case AssignmentOperatorType.Modulus:
 
2276
//                                      op = Tokens.Mod;
 
2277
//                                      unsupportedOpAssignment = true;
 
2278
//                                      break;
 
2279
//                              case AssignmentOperatorType.BitwiseAnd:
 
2280
//                                      op = Tokens.And;
 
2281
//                                      unsupportedOpAssignment = true;
 
2282
//                                      break;
 
2283
//                              case AssignmentOperatorType.BitwiseOr:
 
2284
//                                      op = Tokens.Or;
 
2285
//                                      unsupportedOpAssignment = true;
 
2286
//                                      break;
 
2287
//                      }
 
2288
//                      
 
2289
//                      TrackedVisit(assignmentExpression.Left, data);
 
2290
//                      outputFormatter.Space();
 
2291
//                      
 
2292
//                      if (unsupportedOpAssignment) { // left = left OP right
 
2293
//                              outputFormatter.PrintToken(Tokens.Assign);
 
2294
//                              outputFormatter.Space();
 
2295
//                              TrackedVisit(assignmentExpression.Left, data);
 
2296
//                              outputFormatter.Space();
 
2297
//                      }
 
2298
//                      
 
2299
//                      outputFormatter.PrintToken(op);
 
2300
//                      outputFormatter.Space();
 
2301
//                      TrackedVisit(assignmentExpression.Right, data);
 
2302
//                      
 
2303
//                      return null;
 
2304
//              }
 
2305
//              
 
2306
//              public override object TrackedVisitTypeOfExpression(TypeOfExpression typeOfExpression, object data)
 
2307
//              {
 
2308
//                      outputFormatter.PrintToken(Tokens.GetType);
 
2309
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2310
//                      TrackedVisit(typeOfExpression.TypeReference, data);
 
2311
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2312
//                      return null;
 
2313
//              }
 
2314
//              
 
2315
//              public override object TrackedVisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
 
2316
//              {
 
2317
//                      // assigning nothing to a generic type in VB compiles to a DefaultValueExpression
 
2318
//                      outputFormatter.PrintToken(Tokens.Nothing);
 
2319
//                      return null;
 
2320
//              }
 
2321
//              
 
2322
//              public override object TrackedVisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data)
 
2323
//              {
 
2324
//                      outputFormatter.PrintToken(Tokens.TypeOf);
 
2325
//                      outputFormatter.Space();
 
2326
//                      TrackedVisit(typeOfIsExpression.Expression, data);
 
2327
//                      outputFormatter.Space();
 
2328
//                      outputFormatter.PrintToken(Tokens.Is);
 
2329
//                      outputFormatter.Space();
 
2330
//                      TrackedVisit(typeOfIsExpression.TypeReference, data);
 
2331
//                      return null;
 
2332
//              }
 
2333
//              
 
2334
//              public override object TrackedVisitAddressOfExpression(AddressOfExpression addressOfExpression, object data)
 
2335
//              {
 
2336
//                      outputFormatter.PrintToken(Tokens.AddressOf);
 
2337
//                      outputFormatter.Space();
 
2338
//                      TrackedVisit(addressOfExpression.Expression, data);
 
2339
//                      return null;
 
2340
//              }
 
2341
//              
 
2342
//              public override object TrackedVisitCastExpression(CastExpression castExpression, object data)
 
2343
//              {
 
2344
//                      if (castExpression.CastType == CastType.TryCast) {
 
2345
//                              return PrintCast(Tokens.TryCast, castExpression);
 
2346
//                      }
 
2347
//                      if (castExpression.CastType == CastType.Cast || castExpression.CastTo.IsArrayType) {
 
2348
//                              return PrintCast(Tokens.DirectCast, castExpression);
 
2349
//                      }
 
2350
//                      switch (castExpression.CastTo.Type) {
 
2351
//                              case "System.Boolean":
 
2352
//                                      outputFormatter.PrintToken(Tokens.CBool);
 
2353
//                                      break;
 
2354
//                              case "System.Byte":
 
2355
//                                      outputFormatter.PrintToken(Tokens.CByte);
 
2356
//                                      break;
 
2357
//                              case "System.SByte":
 
2358
//                                      outputFormatter.PrintToken(Tokens.CSByte);
 
2359
//                                      break;
 
2360
//                              case "System.Char":
 
2361
//                                      outputFormatter.PrintToken(Tokens.CChar);
 
2362
//                                      break;
 
2363
//                              case "System.DateTime":
 
2364
//                                      outputFormatter.PrintToken(Tokens.CDate);
 
2365
//                                      break;
 
2366
//                              case "System.Decimal":
 
2367
//                                      outputFormatter.PrintToken(Tokens.CDec);
 
2368
//                                      break;
 
2369
//                              case "System.Double":
 
2370
//                                      outputFormatter.PrintToken(Tokens.CDbl);
 
2371
//                                      break;
 
2372
//                              case "System.Int16":
 
2373
//                                      outputFormatter.PrintToken(Tokens.CShort);
 
2374
//                                      break;
 
2375
//                              case "System.Int32":
 
2376
//                                      outputFormatter.PrintToken(Tokens.CInt);
 
2377
//                                      break;
 
2378
//                              case "System.Int64":
 
2379
//                                      outputFormatter.PrintToken(Tokens.CLng);
 
2380
//                                      break;
 
2381
//                              case "System.UInt16":
 
2382
//                                      outputFormatter.PrintToken(Tokens.CUShort);
 
2383
//                                      break;
 
2384
//                              case "System.UInt32":
 
2385
//                                      outputFormatter.PrintToken(Tokens.CUInt);
 
2386
//                                      break;
 
2387
//                              case "System.UInt64":
 
2388
//                                      outputFormatter.PrintToken(Tokens.CULng);
 
2389
//                                      break;
 
2390
//                              case "System.Object":
 
2391
//                                      outputFormatter.PrintToken(Tokens.CObj);
 
2392
//                                      break;
 
2393
//                              case "System.Single":
 
2394
//                                      outputFormatter.PrintToken(Tokens.CSng);
 
2395
//                                      break;
 
2396
//                              case "System.String":
 
2397
//                                      outputFormatter.PrintToken(Tokens.CStr);
 
2398
//                                      break;
 
2399
//                              default:
 
2400
//                                      return PrintCast(Tokens.CType, castExpression);
 
2401
//                      }
 
2402
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2403
//                      TrackedVisit(castExpression.Expression, data);
 
2404
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2405
//                      return null;
 
2406
//              }
 
2407
//              
 
2408
//              object PrintCast(int castToken, CastExpression castExpression)
 
2409
//              {
 
2410
//                      outputFormatter.PrintToken(castToken);
 
2411
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2412
//                      TrackedVisit(castExpression.Expression, null);
 
2413
//                      outputFormatter.PrintToken(Tokens.Comma);
 
2414
//                      outputFormatter.Space();
 
2415
//                      TrackedVisit(castExpression.CastTo, null);
 
2416
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2417
//                      return null;
 
2418
//              }
 
2419
//              
 
2420
//              public override object TrackedVisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data)
 
2421
//              {
 
2422
//                      outputFormatter.PrintToken(Tokens.Me);
 
2423
//                      return null;
 
2424
//              }
 
2425
//              
 
2426
//              public override object TrackedVisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data)
 
2427
//              {
 
2428
//                      outputFormatter.PrintToken(Tokens.MyBase);
 
2429
//                      return null;
 
2430
//              }
 
2431
//              
 
2432
//              public override object TrackedVisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
 
2433
//              {
 
2434
//                      outputFormatter.PrintToken(Tokens.New);
 
2435
//                      if (!objectCreateExpression.IsAnonymousType) {
 
2436
//                              outputFormatter.Space();
 
2437
//                              TrackedVisit(objectCreateExpression.CreateType, data);
 
2438
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2439
//                              AppendCommaSeparatedList(objectCreateExpression.Parameters);
 
2440
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2441
//                      }
 
2442
//                      CollectionInitializerExpression initializer = objectCreateExpression.ObjectInitializer;
 
2443
//                      if (!initializer.IsNull) {
 
2444
//                              outputFormatter.Space();
 
2445
//                              if (initializer.CreateExpressions.Any(ce => ce is MemberInitializerExpression))
 
2446
//                                      outputFormatter.PrintToken(Tokens.With);
 
2447
//                              else
 
2448
//                                      outputFormatter.PrintToken(Tokens.From);
 
2449
//                              outputFormatter.Space();
 
2450
//                              outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
 
2451
//                              outputFormatter.IndentationLevel++;
 
2452
//                              for (int i = 0; i < initializer.CreateExpressions.Count; i++) {
 
2453
//                                      Expression expr = initializer.CreateExpressions[i];
 
2454
//                                      if (i > 0)
 
2455
//                                              outputFormatter.PrintToken(Tokens.Comma);
 
2456
//                                      outputFormatter.PrintLineContinuation();
 
2457
//                                      outputFormatter.Indent();
 
2458
//                                      TrackedVisit(expr, data);
 
2459
//                              }
 
2460
//                              outputFormatter.IndentationLevel--;
 
2461
//                              outputFormatter.PrintLineContinuation();
 
2462
//                              outputFormatter.Indent();
 
2463
//                              outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
 
2464
//                      }
 
2465
//                      return null;
 
2466
//              }
 
2467
//              
 
2468
//              public override object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
 
2469
//              {
 
2470
//                      outputFormatter.PrintToken(Tokens.New);
 
2471
//                      outputFormatter.Space();
 
2472
//                      PrintTypeReferenceWithoutArray(arrayCreateExpression.CreateType);
 
2473
//                      
 
2474
//                      if (arrayCreateExpression.Arguments.Count > 0) {
 
2475
//                              outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2476
//                              AppendCommaSeparatedList(arrayCreateExpression.Arguments);
 
2477
//                              outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2478
//                              PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 1);
 
2479
//                      } else {
 
2480
//                              PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 0);
 
2481
//                      }
 
2482
//                      
 
2483
//                      outputFormatter.Space();
 
2484
//                      
 
2485
//                      if (arrayCreateExpression.ArrayInitializer.IsNull) {
 
2486
//                              outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
 
2487
//                              outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
 
2488
//                      } else {
 
2489
//                              TrackedVisit(arrayCreateExpression.ArrayInitializer, data);
 
2490
//                      }
 
2491
//                      return null;
 
2492
//              }
 
2493
//              
 
2494
//              public override object TrackedVisitCollectionInitializerExpression(CollectionInitializerExpression arrayInitializerExpression, object data)
 
2495
//              {
 
2496
//                      outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
 
2497
//                      this.AppendCommaSeparatedList(arrayInitializerExpression.CreateExpressions);
 
2498
//                      outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
 
2499
//                      return null;
 
2500
//              }
 
2501
//              
 
2502
//              public override object TrackedVisitMemberInitializerExpression(MemberInitializerExpression memberInitializerExpression, object data)
 
2503
//              {
 
2504
//                      if (memberInitializerExpression.IsKey) {
 
2505
//                              outputFormatter.PrintToken(Tokens.Key);
 
2506
//                              outputFormatter.Space();
 
2507
//                      }
 
2508
//                      outputFormatter.PrintToken(Tokens.Dot);
 
2509
//                      outputFormatter.PrintIdentifier(memberInitializerExpression.Name);
 
2510
//                      outputFormatter.Space();
 
2511
//                      outputFormatter.PrintToken(Tokens.Assign);
 
2512
//                      outputFormatter.Space();
 
2513
//                      TrackedVisit(memberInitializerExpression.Expression, data);
 
2514
//                      return null;
 
2515
//              }
 
2516
//              
 
2517
//              public override object TrackedVisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
 
2518
//              {
 
2519
//                      TrackedVisit(memberReferenceExpression.TargetObject, data);
 
2520
//                      outputFormatter.PrintToken(Tokens.Dot);
 
2521
//                      if (string.Equals(memberReferenceExpression.MemberName, "New", StringComparison.OrdinalIgnoreCase)
 
2522
//                          && (memberReferenceExpression.TargetObject is BaseReferenceExpression || memberReferenceExpression.TargetObject is ThisReferenceExpression || memberReferenceExpression.TargetObject is ClassReferenceExpression))
 
2523
//                      {
 
2524
//                              outputFormatter.PrintToken(Tokens.New);
 
2525
//                      } else {
 
2526
//                              outputFormatter.PrintIdentifier(memberReferenceExpression.MemberName);
 
2527
//                      }
 
2528
//                      PrintTypeArguments(memberReferenceExpression.TypeArguments);
 
2529
//                      return null;
 
2530
//              }
 
2531
//              
 
2532
//              public override object TrackedVisitDirectionExpression(DirectionExpression directionExpression, object data)
 
2533
//              {
 
2534
//                      // VB does not need to specify the direction in method calls
 
2535
//                      TrackedVisit(directionExpression.Expression, data);
 
2536
//                      return null;
 
2537
//              }
 
2538
//              
 
2539
//              
 
2540
//              public override object TrackedVisitConditionalExpression(ConditionalExpression conditionalExpression, object data)
 
2541
//              {
 
2542
//                      outputFormatter.PrintText("If");
 
2543
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2544
//                      TrackedVisit(conditionalExpression.Condition, data);
 
2545
//                      outputFormatter.PrintToken(Tokens.Comma);
 
2546
//                      outputFormatter.Space();
 
2547
//                      TrackedVisit(conditionalExpression.TrueExpression, data);
 
2548
//                      outputFormatter.PrintToken(Tokens.Comma);
 
2549
//                      outputFormatter.Space();
 
2550
//                      TrackedVisit(conditionalExpression.FalseExpression, data);
 
2551
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2552
//                      return null;
 
2553
//              }
 
2554
//              
 
2555
//              #endregion
 
2556
//              #endregion
 
2557
//              
 
2558
//              
 
2559
//              void OutputModifier(ParameterModifiers modifier)
 
2560
//              {
 
2561
//                      if ((modifier & ParameterModifiers.Optional) == ParameterModifiers.Optional) {
 
2562
//                              outputFormatter.PrintToken(Tokens.Optional);
 
2563
//                              outputFormatter.Space();
 
2564
//                      }
 
2565
//                      if ((modifier & ParameterModifiers.Ref) == ParameterModifiers.Ref
 
2566
//                          || (modifier & ParameterModifiers.Out) == ParameterModifiers.Out) {
 
2567
//                              outputFormatter.PrintToken(Tokens.ByRef);
 
2568
//                              outputFormatter.Space();
 
2569
//                      }
 
2570
//                      if ((modifier & ParameterModifiers.Params) == ParameterModifiers.Params) {
 
2571
//                              outputFormatter.PrintToken(Tokens.ParamArray);
 
2572
//                              outputFormatter.Space();
 
2573
//                      }
 
2574
//                      if (prettyPrintOptions.OutputByValModifier &&
 
2575
//                          (modifier & (ParameterModifiers.Params | ParameterModifiers.Ref)) == ParameterModifiers.None)
 
2576
//                      {
 
2577
//                              outputFormatter.PrintToken(Tokens.ByVal);
 
2578
//                              outputFormatter.Space();
 
2579
//                      }
 
2580
//              }
 
2581
//              
 
2582
//              void OutputModifier(Modifiers modifier)
 
2583
//              {
 
2584
//                      OutputModifier(modifier, false, false);
 
2585
//              }
 
2586
//              
 
2587
//              void OutputModifier(Modifiers modifier, bool forTypeDecl, bool forFieldDecl)
 
2588
//              {
 
2589
//                      if ((modifier & Modifiers.Public) == Modifiers.Public) {
 
2590
//                              outputFormatter.PrintToken(Tokens.Public);
 
2591
//                              outputFormatter.Space();
 
2592
//                      } else if ((modifier & Modifiers.Private) == Modifiers.Private) {
 
2593
//                              outputFormatter.PrintToken(Tokens.Private);
 
2594
//                              outputFormatter.Space();
 
2595
//                      } else if ((modifier & (Modifiers.Protected | Modifiers.Internal)) == (Modifiers.Protected | Modifiers.Internal)) {
 
2596
//                              outputFormatter.PrintToken(Tokens.Protected);
 
2597
//                              outputFormatter.Space();
 
2598
//                              outputFormatter.PrintToken(Tokens.Friend);
 
2599
//                              outputFormatter.Space();
 
2600
//                      } else if ((modifier & Modifiers.Internal) == Modifiers.Internal) {
 
2601
//                              outputFormatter.PrintToken(Tokens.Friend);
 
2602
//                              outputFormatter.Space();
 
2603
//                      } else if ((modifier & Modifiers.Protected) == Modifiers.Protected) {
 
2604
//                              outputFormatter.PrintToken(Tokens.Protected);
 
2605
//                              outputFormatter.Space();
 
2606
//                      }
 
2607
//                      
 
2608
//                      if ((modifier & Modifiers.Static) == Modifiers.Static) {
 
2609
//                              outputFormatter.PrintToken(Tokens.Shared);
 
2610
//                              outputFormatter.Space();
 
2611
//                      }
 
2612
//                      if ((modifier & Modifiers.Virtual) == Modifiers.Virtual) {
 
2613
//                              outputFormatter.PrintToken(Tokens.Overridable);
 
2614
//                              outputFormatter.Space();
 
2615
//                      }
 
2616
//                      if ((modifier & Modifiers.Abstract) == Modifiers.Abstract) {
 
2617
//                              if (forFieldDecl)
 
2618
//                                      outputFormatter.PrintToken(Tokens.Dim);
 
2619
//                              else if (forTypeDecl)
 
2620
//                                      outputFormatter.PrintToken(Tokens.MustInherit);
 
2621
//                              else
 
2622
//                                      outputFormatter.PrintToken(Tokens.MustOverride);
 
2623
//                              outputFormatter.Space();
 
2624
//                      }
 
2625
//                      if ((modifier & Modifiers.Dim) == Modifiers.Dim) {
 
2626
//                              outputFormatter.PrintToken(Tokens.Dim);
 
2627
//                              outputFormatter.Space();
 
2628
//                      }
 
2629
//                      if ((modifier & Modifiers.Overloads) == Modifiers.Overloads) {
 
2630
//                              outputFormatter.PrintToken(Tokens.Overloads);
 
2631
//                              outputFormatter.Space();
 
2632
//                      }
 
2633
//                      if ((modifier & Modifiers.Override) == Modifiers.Override) {
 
2634
//                              outputFormatter.PrintToken(Tokens.Overrides);
 
2635
//                              outputFormatter.Space();
 
2636
//                      }
 
2637
//                      if ((modifier & Modifiers.New) == Modifiers.New) {
 
2638
//                              outputFormatter.PrintToken(Tokens.Shadows);
 
2639
//                              outputFormatter.Space();
 
2640
//                      }
 
2641
//                      
 
2642
//                      if ((modifier & Modifiers.Sealed) == Modifiers.Sealed) {
 
2643
//                              outputFormatter.PrintToken(forTypeDecl ? Tokens.NotInheritable : Tokens.NotOverridable);
 
2644
//                              outputFormatter.Space();
 
2645
//                      }
 
2646
//                      
 
2647
//                      if ((modifier & Modifiers.ReadOnly) == Modifiers.ReadOnly) {
 
2648
//                              outputFormatter.PrintToken(Tokens.ReadOnly);
 
2649
//                              outputFormatter.Space();
 
2650
//                      }
 
2651
//                      if ((modifier & Modifiers.WriteOnly) == Modifiers.WriteOnly) {
 
2652
//                              outputFormatter.PrintToken(Tokens.WriteOnly);
 
2653
//                              outputFormatter.Space();
 
2654
//                      }
 
2655
//                      if ((modifier & Modifiers.Const) == Modifiers.Const) {
 
2656
//                              outputFormatter.PrintToken(Tokens.Const);
 
2657
//                              outputFormatter.Space();
 
2658
//                      }
 
2659
//                      if ((modifier & Modifiers.WithEvents) == Modifiers.WithEvents) {
 
2660
//                              outputFormatter.PrintToken(Tokens.WithEvents);
 
2661
//                              outputFormatter.Space();
 
2662
//                      }
 
2663
//                      if ((modifier & Modifiers.Partial) == Modifiers.Partial) {
 
2664
//                              outputFormatter.PrintToken(Tokens.Partial);
 
2665
//                              outputFormatter.Space();
 
2666
//                      }
 
2667
//                      
 
2668
//                      if ((modifier & Modifiers.Extern) == Modifiers.Extern) {
 
2669
//                              // not required in VB
 
2670
//                      }
 
2671
//                      
 
2672
//                      if ((modifier & Modifiers.Default) == Modifiers.Default) {
 
2673
//                              outputFormatter.PrintToken(Tokens.Default);
 
2674
//                              outputFormatter.Space();
 
2675
//                      }
 
2676
//                      
 
2677
//                      if ((modifier & Modifiers.Volatile) == Modifiers.Volatile) {
 
2678
//                              Error("'Volatile' modifier not convertable", Location.Empty);
 
2679
//                      }
 
2680
//                      
 
2681
//                      if ((modifier & Modifiers.Unsafe) == Modifiers.Unsafe) {
 
2682
//                              Error("'Unsafe' modifier not convertable", Location.Empty);
 
2683
//                      }
 
2684
//              }
 
2685
//              
 
2686
//              public void AppendCommaSeparatedList<T>(ICollection<T> list) where T : class, INode
 
2687
//              {
 
2688
//                      if (list != null) {
 
2689
//                              int i = 0;
 
2690
//                              foreach (T node in list) {
 
2691
//                                      TrackedVisit(node, null);
 
2692
//                                      if (i + 1 < list.Count) {
 
2693
//                                              outputFormatter.PrintToken(Tokens.Comma);
 
2694
//                                              outputFormatter.Space();
 
2695
//                                              if ((i + 1) % 6 == 0) {
 
2696
//                                                      outputFormatter.PrintLineContinuation();
 
2697
//                                                      outputFormatter.Indent();
 
2698
//                                                      outputFormatter.PrintText("\t");
 
2699
//                                              }
 
2700
//                                      }
 
2701
//                                      i++;
 
2702
//                              }
 
2703
//                      }
 
2704
//              }
 
2705
//              
 
2706
//              void VisitAttributes(ICollection attributes, object data)
 
2707
//              {
 
2708
//                      if (attributes == null) {
 
2709
//                              return;
 
2710
//                      }
 
2711
//                      foreach (AttributeSection section in attributes) {
 
2712
//                              if (string.Equals(section.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase))
 
2713
//                                      continue;
 
2714
//                              TrackedVisit(section, data);
 
2715
//                      }
 
2716
//              }
 
2717
//              
 
2718
//              void VisitReturnTypeAttributes(ICollection attributes, object data)
 
2719
//              {
 
2720
//                      if (attributes == null) {
 
2721
//                              return;
 
2722
//                      }
 
2723
//                      printAttributeSectionInline = true;
 
2724
//                      foreach (AttributeSection section in attributes) {
 
2725
//                              if (string.Equals(section.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) {
 
2726
//                                      TrackedVisit(section, data);
 
2727
//                              }
 
2728
//                      }
 
2729
//                      printAttributeSectionInline = false;
 
2730
//              }
 
2731
//              
 
2732
//              public override object TrackedVisitLambdaExpression(LambdaExpression lambdaExpression, object data)
 
2733
//              {
 
2734
//                      bool isSub = !lambdaExpression.ReturnType.IsNull &&
 
2735
//                              lambdaExpression.ReturnType.Type == "System.Void" && lambdaExpression.ReturnType.IsKeyword;
 
2736
//                      
 
2737
//                      if (isSub)
 
2738
//                              outputFormatter.PrintToken(Tokens.Sub);
 
2739
//                      else
 
2740
//                              outputFormatter.PrintToken(Tokens.Function);
 
2741
//                      
 
2742
//                      outputFormatter.PrintToken(Tokens.OpenParenthesis);
 
2743
//                      AppendCommaSeparatedList(lambdaExpression.Parameters);
 
2744
//                      outputFormatter.PrintToken(Tokens.CloseParenthesis);
 
2745
//                      
 
2746
//                      outputFormatter.Space();
 
2747
//                      
 
2748
//                      if (!lambdaExpression.ExpressionBody.IsNull) {
 
2749
//                              return lambdaExpression.ExpressionBody.AcceptVisitor(this, data);
 
2750
//                      } else {
 
2751
//                              if (!isSub && !lambdaExpression.ReturnType.IsNull) {
 
2752
//                                      outputFormatter.PrintToken(Tokens.As);
 
2753
//                                      outputFormatter.Space();
 
2754
//                                      TrackedVisit(lambdaExpression.ReturnType, data);
 
2755
//                              }
 
2756
//                              
 
2757
//                              if (lambdaExpression.StatementBody is BlockStatement)
 
2758
//                                      outputFormatter.NewLine();
 
2759
//                              
 
2760
//                              TrackedVisit(lambdaExpression.StatementBody, data);
 
2761
//                              
 
2762
//                              if (lambdaExpression.StatementBody is BlockStatement) {
 
2763
//                                      outputFormatter.NewLine();
 
2764
//                                      outputFormatter.PrintToken(Tokens.End);
 
2765
//                                      outputFormatter.Space();
 
2766
//                                      if (isSub)
 
2767
//                                              outputFormatter.PrintToken(Tokens.Sub);
 
2768
//                                      else
 
2769
//                                              outputFormatter.PrintToken(Tokens.Function);
 
2770
//                              }
 
2771
//                              
 
2772
//                              return null;
 
2773
//                      }
 
2774
//              }
 
2775
//              
 
2776
//              public override object TrackedVisitQueryExpression(QueryExpression queryExpression, object data)
 
2777
//              {
 
2778
//                      outputFormatter.IndentationLevel++;
 
2779
//                      for (int i = 0; i < queryExpression.Clauses.Count; i++) {
 
2780
//                              QueryExpressionClause clause = queryExpression.Clauses[i];
 
2781
//                              if (!clause.IsNull) {
 
2782
//                                      if (i != 0) {
 
2783
//                                              outputFormatter.PrintLineContinuation();
 
2784
//                                              outputFormatter.Indent();
 
2785
//                                      }
 
2786
//                                      clause.AcceptVisitor(this, null);
 
2787
//                              }
 
2788
//                      }
 
2789
//                      outputFormatter.IndentationLevel--;
 
2790
//                      return null;
 
2791
//              }
 
2792
//              
 
2793
//              void PrintClause(QueryExpressionClause clause)
 
2794
//              {
 
2795
//
 
2796
//              }
 
2797
//              
 
2798
//              public override object TrackedVisitQueryExpressionFromClause(QueryExpressionFromClause fromClause, object data)
 
2799
//              {
 
2800
//                      outputFormatter.PrintText("From");
 
2801
//                      outputFormatter.Space();
 
2802
//                      for (int i = 0; i < fromClause.Sources.Count; i++) {
 
2803
//                              CollectionRangeVariable clause = fromClause.Sources[i];
 
2804
//                              outputFormatter.PrintIdentifier(clause.Identifier);
 
2805
//                              outputFormatter.Space();
 
2806
//                              outputFormatter.PrintToken(Tokens.In);
 
2807
//                              outputFormatter.Space();
 
2808
//                              clause.Expression.AcceptVisitor(this, data);
 
2809
//                              if (i < fromClause.Sources.Count - 1)
 
2810
//                                      outputFormatter.PrintToken(Tokens.Comma);
 
2811
//                      }
 
2812
//                      return null;
 
2813
//              }
 
2814
//              
 
2815
//              public override object TrackedVisitQueryExpressionJoinClause(QueryExpressionJoinClause joinClause, object data)
 
2816
//              {
 
2817
//                      outputFormatter.PrintText("Join");
 
2818
//                      outputFormatter.Space();
 
2819
//                      CollectionRangeVariable clause = joinClause.Source;
 
2820
//                      outputFormatter.PrintIdentifier(clause.Identifier);
 
2821
//                      outputFormatter.Space();
 
2822
//                      outputFormatter.PrintToken(Tokens.In);
 
2823
//                      outputFormatter.Space();
 
2824
//                      clause.Expression.AcceptVisitor(this, data);
 
2825
//                      outputFormatter.Space();
 
2826
//                      outputFormatter.PrintToken(Tokens.On);
 
2827
//                      outputFormatter.Space();
 
2828
//                      joinClause.OnExpression.AcceptVisitor(this, data);
 
2829
//                      outputFormatter.Space();
 
2830
//                      outputFormatter.PrintToken(Tokens.Assign);
 
2831
//                      outputFormatter.Space();
 
2832
//                      joinClause.EqualsExpression.AcceptVisitor(this, data);
 
2833
//                      if (!string.IsNullOrEmpty(joinClause.IntoIdentifier)) {
 
2834
//                              outputFormatter.Space();
 
2835
//                              outputFormatter.PrintText("Into");
 
2836
//                              outputFormatter.Space();
 
2837
//                              outputFormatter.PrintIdentifier(joinClause.IntoIdentifier);
 
2838
//                      }
 
2839
//                      return null;
 
2840
//              }
 
2841
//              
 
2842
////            void VisitQueryExpressionFromOrJoinClause(QueryExpressionFromOrJoinClause clause, object data)
 
2843
////            {
 
2844
////                    outputFormatter.PrintIdentifier(clause.Identifier);
 
2845
////                    outputFormatter.Space();
 
2846
////                    outputFormatter.PrintToken(Tokens.In);
 
2847
////                    outputFormatter.Space();
 
2848
////                    clause.InExpression.AcceptVisitor(this, data);
 
2849
////            }
 
2850
//              
 
2851
//              public override object TrackedVisitQueryExpressionLetClause(QueryExpressionLetClause letClause, object data)
 
2852
//              {
 
2853
//                      outputFormatter.PrintToken(Tokens.Let);
 
2854
//                      outputFormatter.Space();
 
2855
//                      outputFormatter.PrintIdentifier(letClause.Identifier);
 
2856
//                      outputFormatter.Space();
 
2857
//                      outputFormatter.PrintToken(Tokens.Assign);
 
2858
//                      outputFormatter.Space();
 
2859
//                      return letClause.Expression.AcceptVisitor(this, data);
 
2860
//              }
 
2861
//              
 
2862
//              public override object TrackedVisitQueryExpressionGroupClause(QueryExpressionGroupClause groupClause, object data)
 
2863
//              {
 
2864
//                      outputFormatter.PrintText("Group");
 
2865
//                      outputFormatter.Space();
 
2866
//                      groupClause.Projection.AcceptVisitor(this, data);
 
2867
//                      outputFormatter.Space();
 
2868
//                      outputFormatter.PrintText("By");
 
2869
//                      outputFormatter.Space();
 
2870
//                      return groupClause.GroupBy.AcceptVisitor(this, data);
 
2871
//              }
 
2872
//              
 
2873
//              public override object TrackedVisitQueryExpressionOrderClause(QueryExpressionOrderClause queryExpressionOrderClause, object data)
 
2874
//              {
 
2875
//                      outputFormatter.PrintText("Order By");
 
2876
//                      outputFormatter.Space();
 
2877
//                      AppendCommaSeparatedList(queryExpressionOrderClause.Orderings);
 
2878
//                      return null;
 
2879
//              }
 
2880
//              
 
2881
//              public override object TrackedVisitQueryExpressionOrdering(QueryExpressionOrdering ordering, object data)
 
2882
//              {
 
2883
//                      ordering.Criteria.AcceptVisitor(this, data);
 
2884
//                      if (ordering.Direction == QueryExpressionOrderingDirection.Ascending) {
 
2885
//                              outputFormatter.Space();
 
2886
//                              outputFormatter.PrintText("Ascending");
 
2887
//                      } else if (ordering.Direction == QueryExpressionOrderingDirection.Descending) {
 
2888
//                              outputFormatter.Space();
 
2889
//                              outputFormatter.PrintText("Descending");
 
2890
//                      }
 
2891
//                      return null;
 
2892
//              }
 
2893
//              
 
2894
//              public override object TrackedVisitQueryExpressionSelectVBClause(QueryExpressionSelectVBClause selectClause, object data)
 
2895
//              {
 
2896
//                      outputFormatter.PrintToken(Tokens.Select);
 
2897
//                      outputFormatter.Space();
 
2898
//                      foreach (ExpressionRangeVariable var in selectClause.Variables) {
 
2899
//                              var.AcceptVisitor(this, data);
 
2900
//                      }
 
2901
//                      return null;
 
2902
//              }
 
2903
//              
 
2904
//              public override object TrackedVisitQueryExpressionWhereClause(QueryExpressionWhereClause whereClause, object data)
 
2905
//              {
 
2906
//                      outputFormatter.Space();
 
2907
//                      outputFormatter.PrintText("Where");
 
2908
//                      outputFormatter.Space();
 
2909
//                      return whereClause.Condition.AcceptVisitor(this, data);
 
2910
//              }
 
2911
//              
 
2912
//              public override object TrackedVisitExternAliasDirective(ExternAliasDirective externAliasDirective, object data)
 
2913
//              {
 
2914
//                      UnsupportedNode(externAliasDirective);
 
2915
//                      return null;
 
2916
//              }
 
2917
//              
 
2918
//              public override object TrackedVisitXmlContentExpression(XmlContentExpression xmlContentExpression, object data)
 
2919
//              {
 
2920
//                      switch (xmlContentExpression.Type) {
 
2921
//                              case XmlContentType.Comment:
 
2922
//                                      outputFormatter.PrintText("<!--" + xmlContentExpression.Content + "-->");
 
2923
//                                      break;
 
2924
//                              case XmlContentType.Text:
 
2925
//                                      outputFormatter.PrintText(xmlContentExpression.Content);
 
2926
//                                      break;
 
2927
//                              case XmlContentType.CData:
 
2928
//                                      outputFormatter.PrintText("<![CDATA[" + xmlContentExpression.Content + "]]>");
 
2929
//                                      break;
 
2930
//                              case XmlContentType.ProcessingInstruction:
 
2931
//                                      outputFormatter.PrintText("<?" + xmlContentExpression.Content + "?>");
 
2932
//                                      break;
 
2933
//                              default:
 
2934
//                                      throw new Exception("Invalid value for XmlContentType");
 
2935
//                      }
 
2936
//                      return null;
 
2937
//              }
 
2938
//              
 
2939
//              public override object TrackedVisitXmlEmbeddedExpression(XmlEmbeddedExpression xmlEmbeddedExpression, object data)
 
2940
//              {
 
2941
//                      outputFormatter.PrintText("<%=");
 
2942
//                      outputFormatter.Space();
 
2943
//                      xmlEmbeddedExpression.InlineVBExpression.AcceptVisitor(this, data);
 
2944
//                      outputFormatter.Space();
 
2945
//                      outputFormatter.PrintText("%>");
 
2946
//                      return null;
 
2947
//              }
 
2948
//              
 
2949
//              public override object TrackedVisitXmlAttributeExpression(XmlAttributeExpression xmlAttributeExpression, object data)
 
2950
//              {
 
2951
//                      outputFormatter.PrintText(xmlAttributeExpression.Name);
 
2952
//                      outputFormatter.PrintToken(Tokens.Assign);
 
2953
//                      if (xmlAttributeExpression.IsLiteralValue) {
 
2954
//                              if (xmlAttributeExpression.UseDoubleQuotes)
 
2955
//                                      outputFormatter.PrintText("\"");
 
2956
//                              else
 
2957
//                                      outputFormatter.PrintText("'");
 
2958
//                              outputFormatter.PrintText(xmlAttributeExpression.LiteralValue);
 
2959
//                              if (xmlAttributeExpression.UseDoubleQuotes)
 
2960
//                                      outputFormatter.PrintText("\"");
 
2961
//                              else
 
2962
//                                      outputFormatter.PrintText("'");
 
2963
//                      } else
 
2964
//                              xmlAttributeExpression.ExpressionValue.AcceptVisitor(this, data);
 
2965
//                      return null;
 
2966
//              }
 
2967
//              
 
2968
//              public override object TrackedVisitXmlElementExpression(XmlElementExpression xmlElementExpression, object data)
 
2969
//              {
 
2970
//                      outputFormatter.PrintText("<");
 
2971
//                      if (xmlElementExpression.NameIsExpression) {
 
2972
//                              outputFormatter.PrintToken(Tokens.XmlStartInlineVB);
 
2973
//                              outputFormatter.Space();
 
2974
//                              xmlElementExpression.NameExpression.AcceptVisitor(this, data);
 
2975
//                              outputFormatter.Space();
 
2976
//                              outputFormatter.PrintToken(Tokens.XmlEndInlineVB);
 
2977
//                      } else {
 
2978
//                              outputFormatter.PrintText(xmlElementExpression.XmlName);
 
2979
//                      }
 
2980
//                      foreach (XmlExpression attribute in xmlElementExpression.Attributes) {
 
2981
//                              outputFormatter.Space();
 
2982
//                              attribute.AcceptVisitor(this, data);
 
2983
//                      }
 
2984
//                      if (xmlElementExpression.Children.Any()) {
 
2985
//                              outputFormatter.PrintText(">");
 
2986
//                              foreach (INode node in xmlElementExpression.Children) {
 
2987
//                                      node.AcceptVisitor(this, data);
 
2988
//                              }
 
2989
//                              outputFormatter.PrintText("</");
 
2990
//                              if (!xmlElementExpression.NameIsExpression)
 
2991
//                                      outputFormatter.PrintText(xmlElementExpression.XmlName);
 
2992
//                              outputFormatter.PrintText(">");
 
2993
//                      } else {
 
2994
//                              outputFormatter.Space();
 
2995
//                              outputFormatter.PrintText("/>");
 
2996
//                      }
 
2997
//                      return null;
 
2998
//              }
 
2999
//              
 
3000
//              public override object TrackedVisitXmlMemberAccessExpression(XmlMemberAccessExpression xmlMemberAccessExpression, object data)
 
3001
//              {
 
3002
//                      xmlMemberAccessExpression.TargetObject.AcceptVisitor(this, data);
 
3003
//                      switch (xmlMemberAccessExpression.AxisType) {
 
3004
//                              case XmlAxisType.Element:
 
3005
//                                      outputFormatter.PrintToken(Tokens.Dot);
 
3006
//                                      break;
 
3007
//                              case XmlAxisType.Attribute:
 
3008
//                                      outputFormatter.PrintToken(Tokens.DotAt);
 
3009
//                                      break;
 
3010
//                              case XmlAxisType.Descendents:
 
3011
//                                      outputFormatter.PrintToken(Tokens.TripleDot);
 
3012
//                                      break;
 
3013
//                              default:
 
3014
//                                      throw new Exception("Invalid value for XmlAxisType");
 
3015
//                      }
 
3016
//                      if (xmlMemberAccessExpression.IsXmlIdentifier)
 
3017
//                              outputFormatter.PrintText("<" + xmlMemberAccessExpression.Identifier + ">");
 
3018
//                      else
 
3019
//                              outputFormatter.PrintIdentifier(xmlMemberAccessExpression.Identifier);
 
3020
//                      return null;
 
3021
//              }
 
3022
//      }
 
3023
}