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)
6
using System.Collections;
7
using System.Collections.Generic;
8
using System.Diagnostics;
9
using System.Globalization;
12
using ICSharpCode.NRefactory.VB.Ast;
13
using ICSharpCode.NRefactory.VB.Parser;
14
using ICSharpCode.NRefactory.VB.Visitors;
16
namespace ICSharpCode.NRefactory.VB.PrettyPrinter
18
// public sealed class VBNetOutputVisitor : NodeTrackingAstVisitor, IOutputDomVisitor
20
// Errors errors = new Errors();
21
// VBNetOutputFormatter outputFormatter;
22
// VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions();
23
// TypeDeclaration currentType;
25
// Stack<int> exitTokenStack = new Stack<int>();
27
// public string Text {
29
// return outputFormatter.Text;
33
// public Errors Errors {
39
// AbstractPrettyPrintOptions IOutputDomVisitor.Options {
40
// get { return prettyPrintOptions; }
43
// public VBNetPrettyPrintOptions Options {
44
// get { return prettyPrintOptions; }
47
// public IOutputFormatter OutputFormatter {
49
// return outputFormatter;
53
// public VBNetOutputVisitor()
55
// outputFormatter = new VBNetOutputFormatter(prettyPrintOptions);
58
// public event Action<INode> BeforeNodeVisit;
59
// public event Action<INode> AfterNodeVisit;
61
// protected override void BeginVisit(INode node)
63
// if (BeforeNodeVisit != null) {
64
// BeforeNodeVisit(node);
66
// base.BeginVisit(node);
69
// protected override void EndVisit(INode node)
71
// base.EndVisit(node);
72
// if (AfterNodeVisit != null) {
73
// AfterNodeVisit(node);
77
// object TrackedVisit(INode node, object data)
79
// return node.AcceptVisitor(this, data);
82
// void Error(string text, Location position)
84
// errors.Error(position.Line, position.Column, text);
87
// void UnsupportedNode(INode node)
89
// Error(node.GetType().Name + " is unsupported", node.StartLocation);
92
// #region ICSharpCode.NRefactory.Parser.IAstVisitor interface implementation
93
// public override object TrackedVisitCompilationUnit(CompilationUnit compilationUnit, object data)
95
// compilationUnit.AcceptChildren(this, data);
96
// outputFormatter.EndFile();
101
// /// Converts type name to primitive type name. Returns typeString if typeString is not
102
// /// a primitive type.
104
// static string ConvertTypeString(string typeString)
106
// string primitiveType;
107
// if (TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType))
108
// return primitiveType;
110
// return typeString;
113
// public override object TrackedVisitTypeReference(TypeReference typeReference, object data)
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);
122
// PrintTypeReferenceWithoutArray(typeReference);
123
// if (typeReference.IsArrayType) {
124
// PrintArrayRank(typeReference.RankSpecifier, 0);
130
// void PrintTypeReferenceWithoutArray(TypeReference typeReference)
132
// if (typeReference.IsGlobal) {
133
// outputFormatter.PrintToken(Tokens.Global);
134
// outputFormatter.PrintToken(Tokens.Dot);
136
// bool printGenerics = true;
137
// if (typeReference.IsKeyword) {
138
// outputFormatter.PrintText(ConvertTypeString(typeReference.Type));
140
// outputFormatter.PrintIdentifier(typeReference.Type);
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);
149
// for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
150
// outputFormatter.PrintToken(Tokens.Times);
154
// void PrintArrayRank(int[] rankSpecifier, int startRank)
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);
161
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
165
// public override object TrackedVisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data)
167
// TrackedVisit(innerClassTypeReference.BaseType, data);
168
// outputFormatter.PrintToken(Tokens.Dot);
169
// return VisitTypeReference((TypeReference)innerClassTypeReference, data);
172
// #region Global scope
173
// bool printAttributeSectionInline; // is set to true when printing parameter's attributes
175
// public override object TrackedVisitAttributeSection(AttributeSection attributeSection, object data)
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();
185
// Debug.Assert(attributeSection.Attributes != null);
186
// AppendCommaSeparatedList(attributeSection.Attributes);
188
// outputFormatter.PrintText(">");
190
// if ("assembly".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)
191
// || "module".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)) {
192
// outputFormatter.NewLine();
194
// if (printAttributeSectionInline)
195
// outputFormatter.Space();
197
// outputFormatter.PrintLineContinuation();
203
// public override object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data)
205
// outputFormatter.PrintIdentifier(attribute.Type);
206
// if (attribute.PositionalArguments.Count > 0 || attribute.NamedArguments.Count > 0) {
207
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
208
// AppendCommaSeparatedList(attribute.PositionalArguments);
210
// if (attribute.NamedArguments.Count > 0) {
211
// if (attribute.PositionalArguments.Count > 0) {
212
// outputFormatter.PrintToken(Tokens.Comma);
213
// outputFormatter.Space();
215
// AppendCommaSeparatedList(attribute.NamedArguments);
217
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
222
// public override object TrackedVisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data)
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);
233
// public override object TrackedVisitUsing(ImportsClause @using, object data)
235
// Debug.Fail("Should never be called. The usings should be handled in Visit(UsingDeclaration)");
239
// public override object TrackedVisitUsingDeclaration(ImportsStatement usingDeclaration, object data)
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);
252
// if (i + 1 < usingDeclaration.ImportsClauses.Count) {
253
// outputFormatter.PrintToken(Tokens.Comma);
254
// outputFormatter.Space();
257
// outputFormatter.NewLine();
261
// public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
263
// outputFormatter.Indent();
264
// outputFormatter.PrintToken(Tokens.Namespace);
265
// outputFormatter.Space();
266
// outputFormatter.PrintIdentifier(namespaceDeclaration.Name);
267
// outputFormatter.NewLine();
269
// ++outputFormatter.IndentationLevel;
270
// namespaceDeclaration.AcceptChildren(this, data);
271
// --outputFormatter.IndentationLevel;
273
// outputFormatter.Indent();
274
// outputFormatter.PrintToken(Tokens.End);
275
// outputFormatter.Space();
276
// outputFormatter.PrintToken(Tokens.Namespace);
277
// outputFormatter.NewLine();
281
// static int GetTypeToken(TypeDeclaration typeDeclaration)
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;
295
// return Tokens.Class;
299
// void PrintTemplates(List<TemplateDefinition> templates)
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);
310
// public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
312
// VisitAttributes(typeDeclaration.Attributes, data);
314
// outputFormatter.Indent();
315
// OutputModifier(typeDeclaration.Modifier, true, false);
317
// int typeToken = GetTypeToken(typeDeclaration);
318
// outputFormatter.PrintToken(typeToken);
319
// outputFormatter.Space();
320
// outputFormatter.PrintIdentifier(typeDeclaration.Name);
322
// PrintTemplates(typeDeclaration.Templates);
324
// if (typeDeclaration.Type == ClassType.Enum
325
// && typeDeclaration.BaseTypes != null && typeDeclaration.BaseTypes.Count > 0)
327
// outputFormatter.Space();
328
// outputFormatter.PrintToken(Tokens.As);
329
// outputFormatter.Space();
330
// foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
331
// TrackedVisit(baseTypeRef, data);
335
// outputFormatter.NewLine();
336
// ++outputFormatter.IndentationLevel;
338
// if (typeDeclaration.BaseTypes != null && typeDeclaration.Type != ClassType.Enum) {
339
// foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
340
// outputFormatter.Indent();
342
// string baseType = baseTypeRef.Type;
343
// if (baseType.IndexOf('.') >= 0) {
344
// baseType = baseType.Substring(baseType.LastIndexOf('.') + 1);
346
// bool baseTypeIsInterface = baseType.Length >= 2 && baseType[0] == 'I' && Char.IsUpper(baseType[1]);
348
// if (!baseTypeIsInterface || typeDeclaration.Type == ClassType.Interface) {
349
// outputFormatter.PrintToken(Tokens.Inherits);
351
// outputFormatter.PrintToken(Tokens.Implements);
353
// outputFormatter.Space();
354
// TrackedVisit(baseTypeRef, data);
355
// outputFormatter.NewLine();
359
// TypeDeclaration oldType = currentType;
360
// currentType = typeDeclaration;
362
// if (typeDeclaration.Type == ClassType.Enum) {
363
// OutputEnumMembers(typeDeclaration, data);
365
// typeDeclaration.AcceptChildren(this, data);
367
// currentType = oldType;
369
// --outputFormatter.IndentationLevel;
372
// outputFormatter.Indent();
373
// outputFormatter.PrintToken(Tokens.End);
374
// outputFormatter.Space();
375
// outputFormatter.PrintToken(typeToken);
376
// outputFormatter.NewLine();
380
// void OutputEnumMembers(TypeDeclaration typeDeclaration, object data)
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);
394
// outputFormatter.NewLine();
395
// EndVisit(fieldDeclaration);
399
// public override object TrackedVisitTemplateDefinition(TemplateDefinition templateDefinition, object data)
401
// VisitAttributes(templateDefinition.Attributes, data);
402
// switch (templateDefinition.VarianceModifier) {
403
// case VarianceModifier.Invariant:
406
// case VarianceModifier.Covariant:
407
// outputFormatter.Space();
408
// outputFormatter.PrintToken(Tokens.Out);
409
// outputFormatter.Space();
411
// case VarianceModifier.Contravariant:
412
// outputFormatter.Space();
413
// outputFormatter.PrintToken(Tokens.In);
414
// outputFormatter.Space();
417
// throw new Exception("Invalid value for VarianceModifier");
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);
426
// outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
427
// AppendCommaSeparatedList(templateDefinition.Bases);
428
// outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
434
// public override object TrackedVisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data)
436
// VisitAttributes(delegateDeclaration.Attributes, data);
438
// outputFormatter.Indent();
439
// OutputModifier(delegateDeclaration.Modifier, true, false);
440
// outputFormatter.PrintToken(Tokens.Delegate);
441
// outputFormatter.Space();
443
// bool isFunction = (delegateDeclaration.ReturnType.Type != "System.Void");
445
// outputFormatter.PrintToken(Tokens.Function);
446
// outputFormatter.Space();
448
// outputFormatter.PrintToken(Tokens.Sub);
449
// outputFormatter.Space();
451
// outputFormatter.PrintIdentifier(delegateDeclaration.Name);
453
// PrintTemplates(delegateDeclaration.Templates);
455
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
456
// AppendCommaSeparatedList(delegateDeclaration.Parameters);
457
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
460
// outputFormatter.Space();
461
// outputFormatter.PrintToken(Tokens.As);
462
// outputFormatter.Space();
463
// VisitReturnTypeAttributes(delegateDeclaration.Attributes, data);
464
// TrackedVisit(delegateDeclaration.ReturnType, data);
466
// outputFormatter.NewLine();
470
// public override object TrackedVisitOptionDeclaration(OptionDeclaration optionDeclaration, object data)
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);
480
// case OptionType.Explicit:
481
// outputFormatter.PrintToken(Tokens.Explicit);
482
// outputFormatter.Space();
483
// outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
485
// case OptionType.Infer:
486
// outputFormatter.PrintToken(Tokens.Infer);
487
// outputFormatter.Space();
488
// outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
490
// case OptionType.CompareBinary:
491
// outputFormatter.PrintToken(Tokens.Compare);
492
// outputFormatter.Space();
493
// outputFormatter.PrintToken(Tokens.Binary);
495
// case OptionType.CompareText:
496
// outputFormatter.PrintToken(Tokens.Compare);
497
// outputFormatter.Space();
498
// outputFormatter.PrintToken(Tokens.Text);
501
// outputFormatter.NewLine();
506
// #region Type level
507
// TypeReference currentVariableType;
508
// public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
511
// VisitAttributes(fieldDeclaration.Attributes, data);
512
// outputFormatter.Indent();
513
// if (fieldDeclaration.Modifier == Modifiers.None) {
514
// outputFormatter.PrintToken(Tokens.Private);
515
// outputFormatter.Space();
517
// OutputModifier(fieldDeclaration.Modifier, false, true);
519
// currentVariableType = fieldDeclaration.TypeReference;
520
// AppendCommaSeparatedList(fieldDeclaration.Fields);
521
// currentVariableType = null;
523
// outputFormatter.NewLine();
528
// public override object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
530
// outputFormatter.PrintIdentifier(variableDeclaration.Name);
532
// TypeReference varType = currentVariableType;
533
// if (varType != null && varType.IsNull)
535
// if (varType == null && !variableDeclaration.TypeReference.IsNull)
536
// varType = variableDeclaration.TypeReference;
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);
547
// TrackedVisit(varType, data);
551
// if (!variableDeclaration.Initializer.IsNull) {
552
// outputFormatter.Space();
553
// outputFormatter.PrintToken(Tokens.Assign);
554
// outputFormatter.Space();
555
// TrackedVisit(variableDeclaration.Initializer, data);
560
// public override object TrackedVisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
562
// VisitAttributes(propertyDeclaration.Attributes, data);
563
// outputFormatter.Indent();
564
// OutputModifier(propertyDeclaration.Modifier);
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();
576
// outputFormatter.PrintToken(Tokens.Property);
577
// outputFormatter.Space();
578
// outputFormatter.PrintIdentifier(propertyDeclaration.Name);
580
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
581
// AppendCommaSeparatedList(propertyDeclaration.Parameters);
582
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
584
// if (!propertyDeclaration.TypeReference.IsNull) {
585
// outputFormatter.Space();
586
// outputFormatter.PrintToken(Tokens.As);
587
// outputFormatter.Space();
589
// VisitReturnTypeAttributes(propertyDeclaration.Attributes, data);
591
// ObjectCreateExpression init = propertyDeclaration.Initializer as ObjectCreateExpression;
592
// if (init != null && TypeReference.AreEqualReferences(init.CreateType, propertyDeclaration.TypeReference)) {
593
// TrackedVisit(propertyDeclaration.Initializer, data);
595
// TrackedVisit(propertyDeclaration.TypeReference, data);
599
// PrintInterfaceImplementations(propertyDeclaration.InterfaceImplementations);
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);
608
// outputFormatter.NewLine();
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;
620
// outputFormatter.Indent();
621
// outputFormatter.PrintToken(Tokens.End);
622
// outputFormatter.Space();
623
// outputFormatter.PrintToken(Tokens.Property);
624
// outputFormatter.NewLine();
630
// public override object TrackedVisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data)
632
// VisitAttributes(propertyGetRegion.Attributes, data);
633
// outputFormatter.Indent();
634
// OutputModifier(propertyGetRegion.Modifier);
635
// outputFormatter.PrintToken(Tokens.Get);
636
// outputFormatter.NewLine();
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();
649
// public override object TrackedVisitPropertySetRegion(PropertySetRegion propertySetRegion, object data)
651
// VisitAttributes(propertySetRegion.Attributes, data);
652
// outputFormatter.Indent();
653
// OutputModifier(propertySetRegion.Modifier);
654
// outputFormatter.PrintToken(Tokens.Set);
655
// outputFormatter.NewLine();
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();
668
// TypeReference currentEventType = null;
669
// public override object TrackedVisitEventDeclaration(EventDeclaration eventDeclaration, object data)
671
// bool customEvent = eventDeclaration.HasAddRegion || eventDeclaration.HasRemoveRegion;
673
// VisitAttributes(eventDeclaration.Attributes, data);
674
// outputFormatter.Indent();
675
// OutputModifier(eventDeclaration.Modifier);
676
// if (customEvent) {
677
// outputFormatter.PrintText("Custom");
678
// outputFormatter.Space();
681
// outputFormatter.PrintToken(Tokens.Event);
682
// outputFormatter.Space();
683
// outputFormatter.PrintIdentifier(eventDeclaration.Name);
685
// if (eventDeclaration.Parameters.Count > 0) {
686
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
687
// this.AppendCommaSeparatedList(eventDeclaration.Parameters);
688
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
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);
698
// PrintInterfaceImplementations(eventDeclaration.InterfaceImplementations);
700
// if (!eventDeclaration.Initializer.IsNull) {
701
// outputFormatter.Space();
702
// outputFormatter.PrintToken(Tokens.Assign);
703
// outputFormatter.Space();
704
// TrackedVisit(eventDeclaration.Initializer, data);
707
// outputFormatter.NewLine();
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;
718
// outputFormatter.Indent();
719
// outputFormatter.PrintToken(Tokens.End);
720
// outputFormatter.Space();
721
// outputFormatter.PrintToken(Tokens.Event);
722
// outputFormatter.NewLine();
727
// void PrintInterfaceImplementations(IList<InterfaceImplementation> list)
729
// if (list == null || list.Count == 0)
731
// outputFormatter.Space();
732
// outputFormatter.PrintToken(Tokens.Implements);
733
// for (int i = 0; i < list.Count; i++) {
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);
743
// public override object TrackedVisitEventAddRegion(EventAddRegion eventAddRegion, object data)
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);
757
// this.AppendCommaSeparatedList(eventAddRegion.Parameters);
759
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
760
// outputFormatter.NewLine();
762
// ++outputFormatter.IndentationLevel;
763
// TrackedVisit(eventAddRegion.Block, data);
764
// --outputFormatter.IndentationLevel;
766
// outputFormatter.Indent();
767
// outputFormatter.PrintToken(Tokens.End);
768
// outputFormatter.Space();
769
// outputFormatter.PrintText("AddHandler");
770
// outputFormatter.NewLine();
774
// public override object TrackedVisitEventRemoveRegion(EventRemoveRegion eventRemoveRegion, object data)
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);
789
// this.AppendCommaSeparatedList(eventRemoveRegion.Parameters);
791
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
792
// outputFormatter.NewLine();
794
// ++outputFormatter.IndentationLevel;
795
// TrackedVisit(eventRemoveRegion.Block, data);
796
// --outputFormatter.IndentationLevel;
798
// outputFormatter.Indent();
799
// outputFormatter.PrintToken(Tokens.End);
800
// outputFormatter.Space();
801
// outputFormatter.PrintText("RemoveHandler");
802
// outputFormatter.NewLine();
806
// public override object TrackedVisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data)
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);
821
// this.AppendCommaSeparatedList(eventRaiseRegion.Parameters);
823
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
824
// outputFormatter.NewLine();
826
// ++outputFormatter.IndentationLevel;
827
// TrackedVisit(eventRaiseRegion.Block, data);
828
// --outputFormatter.IndentationLevel;
830
// outputFormatter.Indent();
831
// outputFormatter.PrintToken(Tokens.End);
832
// outputFormatter.Space();
833
// outputFormatter.PrintText("RaiseEvent");
834
// outputFormatter.NewLine();
838
// public override object TrackedVisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data)
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);
852
// if (!parameterDeclarationExpression.DefaultValue.IsNull) {
853
// outputFormatter.Space();
854
// outputFormatter.PrintToken(Tokens.Assign);
855
// outputFormatter.Space();
856
// TrackedVisit(parameterDeclarationExpression.DefaultValue, data);
861
// public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
863
// VisitAttributes(methodDeclaration.Attributes, data);
864
// if (methodDeclaration.IsExtensionMethod) {
865
// outputFormatter.Indent();
866
// outputFormatter.PrintText("<System.Runtime.CompilerServices.Extension> _");
867
// outputFormatter.NewLine();
869
// outputFormatter.Indent();
870
// OutputModifier(methodDeclaration.Modifier);
872
// bool isSub = methodDeclaration.TypeReference.IsNull ||
873
// methodDeclaration.TypeReference.Type == "System.Void";
876
// outputFormatter.PrintToken(Tokens.Sub);
878
// outputFormatter.PrintToken(Tokens.Function);
880
// outputFormatter.Space();
881
// outputFormatter.PrintIdentifier(methodDeclaration.Name);
883
// PrintTemplates(methodDeclaration.Templates);
885
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
886
// AppendCommaSeparatedList(methodDeclaration.Parameters);
887
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
890
// outputFormatter.Space();
891
// outputFormatter.PrintToken(Tokens.As);
892
// outputFormatter.Space();
893
// VisitReturnTypeAttributes(methodDeclaration.Attributes, data);
894
// TrackedVisit(methodDeclaration.TypeReference, data);
897
// PrintInterfaceImplementations(methodDeclaration.InterfaceImplementations);
899
// if (methodDeclaration.HandlesClause.Count > 0) {
900
// outputFormatter.Space();
901
// outputFormatter.PrintToken(Tokens.Handles);
902
// for (int i = 0; i < methodDeclaration.HandlesClause.Count; i++) {
904
// outputFormatter.PrintToken(Tokens.Comma);
905
// outputFormatter.Space();
906
// outputFormatter.PrintText(methodDeclaration.HandlesClause[i]);
910
// outputFormatter.NewLine();
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;
922
// outputFormatter.Indent();
923
// outputFormatter.PrintToken(Tokens.End);
924
// outputFormatter.Space();
926
// outputFormatter.PrintToken(Tokens.Sub);
928
// outputFormatter.PrintToken(Tokens.Function);
930
// outputFormatter.NewLine();
931
// EndVisit(methodDeclaration.Body);
932
// outputFormatter.IsInMemberBody = false;
937
// public override object TrackedVisitInterfaceImplementation(InterfaceImplementation interfaceImplementation, object data)
939
// throw new InvalidOperationException();
942
// bool IsAbstract(AttributedNode node)
944
// if ((node.Modifier & Modifiers.Abstract) == Modifiers.Abstract)
946
// return currentType != null && currentType.Type == ClassType.Interface;
949
// public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
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();
962
// outputFormatter.IsInMemberBody = true;
963
// ++outputFormatter.IndentationLevel;
964
// exitTokenStack.Push(Tokens.Sub);
966
// TrackedVisit(constructorDeclaration.ConstructorInitializer, data);
968
// TrackedVisit(constructorDeclaration.Body, data);
969
// exitTokenStack.Pop();
970
// --outputFormatter.IndentationLevel;
971
// outputFormatter.IsInMemberBody = false;
973
// outputFormatter.Indent();
974
// outputFormatter.PrintToken(Tokens.End);
975
// outputFormatter.Space();
976
// outputFormatter.PrintToken(Tokens.Sub);
977
// outputFormatter.NewLine();
982
// public override object TrackedVisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
984
// outputFormatter.Indent();
985
// if (constructorInitializer.ConstructorInitializerType == ConstructorInitializerType.This) {
986
// outputFormatter.PrintToken(Tokens.Me);
988
// outputFormatter.PrintToken(Tokens.MyBase);
990
// outputFormatter.PrintToken(Tokens.Dot);
991
// outputFormatter.PrintToken(Tokens.New);
992
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
993
// AppendCommaSeparatedList(constructorInitializer.Arguments);
994
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
996
// outputFormatter.NewLine();
1000
// public override object TrackedVisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data)
1002
// VisitAttributes(operatorDeclaration.Attributes, data);
1003
// outputFormatter.Indent();
1004
// OutputModifier(operatorDeclaration.Modifier);
1006
// if (operatorDeclaration.IsConversionOperator) {
1007
// if (operatorDeclaration.ConversionType == ConversionType.Implicit) {
1008
// outputFormatter.PrintToken(Tokens.Widening);
1010
// outputFormatter.PrintToken(Tokens.Narrowing);
1012
// outputFormatter.Space();
1015
// outputFormatter.PrintToken(Tokens.Operator);
1016
// outputFormatter.Space();
1020
// switch(operatorDeclaration.OverloadableOperator)
1022
// case OverloadableOperatorType.Add:
1023
// case OverloadableOperatorType.UnaryPlus:
1024
// op = Tokens.Plus;
1026
// case OverloadableOperatorType.UnaryMinus:
1027
// case OverloadableOperatorType.Subtract:
1028
// op = Tokens.Minus;
1030
// case OverloadableOperatorType.Multiply:
1031
// op = Tokens.Times;
1033
// case OverloadableOperatorType.Divide:
1036
// case OverloadableOperatorType.Modulus:
1039
// case OverloadableOperatorType.Concat:
1040
// op = Tokens.ConcatString;
1042
// case OverloadableOperatorType.Not:
1045
// case OverloadableOperatorType.BitNot:
1048
// case OverloadableOperatorType.BitwiseAnd:
1051
// case OverloadableOperatorType.BitwiseOr:
1054
// case OverloadableOperatorType.ExclusiveOr:
1057
// case OverloadableOperatorType.ShiftLeft:
1058
// op = Tokens.ShiftLeft;
1060
// case OverloadableOperatorType.ShiftRight:
1061
// op = Tokens.ShiftRight;
1063
// case OverloadableOperatorType.GreaterThan:
1064
// op = Tokens.GreaterThan;
1066
// case OverloadableOperatorType.GreaterThanOrEqual:
1067
// op = Tokens.GreaterEqual;
1069
// case OverloadableOperatorType.Equality:
1070
// op = Tokens.Assign;
1072
// case OverloadableOperatorType.InEquality:
1073
// op = Tokens.NotEqual;
1075
// case OverloadableOperatorType.LessThan:
1076
// op = Tokens.LessThan;
1078
// case OverloadableOperatorType.LessThanOrEqual:
1079
// op = Tokens.LessEqual;
1081
// case OverloadableOperatorType.Increment:
1082
// Error("Increment operator is not supported in Visual Basic", operatorDeclaration.StartLocation);
1084
// case OverloadableOperatorType.Decrement:
1085
// Error("Decrement operator is not supported in Visual Basic", operatorDeclaration.StartLocation);
1087
// case OverloadableOperatorType.IsTrue:
1088
// outputFormatter.PrintText("IsTrue");
1090
// case OverloadableOperatorType.IsFalse:
1091
// outputFormatter.PrintText("IsFalse");
1093
// case OverloadableOperatorType.Like:
1094
// op = Tokens.Like;
1096
// case OverloadableOperatorType.Power:
1097
// op = Tokens.Power;
1099
// case OverloadableOperatorType.CType:
1100
// op = Tokens.CType;
1102
// case OverloadableOperatorType.DivideInteger:
1103
// op = Tokens.DivInteger;
1109
// if (operatorDeclaration.IsConversionOperator) {
1110
// outputFormatter.PrintToken(Tokens.CType);
1112
// if(op != -1) outputFormatter.PrintToken(op);
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);
1127
// outputFormatter.NewLine();
1129
// ++outputFormatter.IndentationLevel;
1130
// TrackedVisit(operatorDeclaration.Body, data);
1131
// --outputFormatter.IndentationLevel;
1133
// outputFormatter.Indent();
1134
// outputFormatter.PrintToken(Tokens.End);
1135
// outputFormatter.Space();
1136
// outputFormatter.PrintToken(Tokens.Operator);
1137
// outputFormatter.NewLine();
1142
// public override object TrackedVisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
1144
// VisitAttributes(declareDeclaration.Attributes, data);
1145
// outputFormatter.Indent();
1146
// OutputModifier(declareDeclaration.Modifier);
1147
// outputFormatter.PrintToken(Tokens.Declare);
1148
// outputFormatter.Space();
1150
// switch (declareDeclaration.Charset) {
1151
// case CharsetModifier.Auto:
1152
// outputFormatter.PrintToken(Tokens.Auto);
1153
// outputFormatter.Space();
1155
// case CharsetModifier.Unicode:
1156
// outputFormatter.PrintToken(Tokens.Unicode);
1157
// outputFormatter.Space();
1159
// case CharsetModifier.Ansi:
1160
// outputFormatter.PrintToken(Tokens.Ansi);
1161
// outputFormatter.Space();
1165
// bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.Type == "System.Void";
1167
// outputFormatter.PrintToken(Tokens.Sub);
1169
// outputFormatter.PrintToken(Tokens.Function);
1171
// outputFormatter.Space();
1173
// outputFormatter.PrintIdentifier(declareDeclaration.Name);
1175
// outputFormatter.Space();
1176
// outputFormatter.PrintToken(Tokens.Lib);
1177
// outputFormatter.Space();
1178
// outputFormatter.PrintText(ConvertString(declareDeclaration.Library));
1179
// outputFormatter.Space();
1181
// if (declareDeclaration.Alias.Length > 0) {
1182
// outputFormatter.PrintToken(Tokens.Alias);
1183
// outputFormatter.Space();
1184
// outputFormatter.PrintText(ConvertString(declareDeclaration.Alias));
1185
// outputFormatter.Space();
1188
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
1189
// AppendCommaSeparatedList(declareDeclaration.Parameters);
1190
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
1193
// outputFormatter.Space();
1194
// outputFormatter.PrintToken(Tokens.As);
1195
// outputFormatter.Space();
1196
// VisitReturnTypeAttributes(declareDeclaration.Attributes, data);
1197
// TrackedVisit(declareDeclaration.TypeReference, data);
1200
// outputFormatter.NewLine();
1206
// #region Statements
1207
// public override object TrackedVisitBlockStatement(BlockStatement blockStatement, object data)
1209
// if (blockStatement.Parent is BlockStatement) {
1210
// outputFormatter.Indent();
1211
// outputFormatter.PrintText("If True Then");
1212
// outputFormatter.NewLine();
1213
// outputFormatter.IndentationLevel += 1;
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();
1225
// void PrintIndentedBlock(Statement stmt)
1227
// outputFormatter.IndentationLevel += 1;
1228
// if (stmt is BlockStatement) {
1229
// TrackedVisit(stmt, null);
1231
// outputFormatter.Indent();
1232
// TrackedVisit(stmt, null);
1233
// outputFormatter.NewLine();
1235
// outputFormatter.IndentationLevel -= 1;
1238
// void PrintIndentedBlock(IEnumerable statements)
1240
// outputFormatter.IndentationLevel += 1;
1241
// VisitStatementList(statements);
1242
// outputFormatter.IndentationLevel -= 1;
1245
// void VisitStatementList(IEnumerable statements)
1247
// foreach (Statement stmt in statements) {
1248
// if (stmt is BlockStatement) {
1249
// TrackedVisit(stmt, null);
1251
// outputFormatter.Indent();
1252
// TrackedVisit(stmt, null);
1253
// outputFormatter.NewLine();
1258
// public override object TrackedVisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data)
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);
1269
// public override object TrackedVisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data)
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);
1280
// public override object TrackedVisitRaiseEventStatement(RaiseEventStatement raiseEventStatement, object data)
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);
1291
// public override object TrackedVisitEraseStatement(EraseStatement eraseStatement, object data)
1293
// outputFormatter.PrintToken(Tokens.Erase);
1294
// outputFormatter.Space();
1295
// AppendCommaSeparatedList(eraseStatement.Expressions);
1299
// public override object TrackedVisitErrorStatement(ErrorStatement errorStatement, object data)
1301
// outputFormatter.PrintToken(Tokens.Error);
1302
// outputFormatter.Space();
1303
// TrackedVisit(errorStatement.Expression, data);
1307
// public override object TrackedVisitOnErrorStatement(OnErrorStatement onErrorStatement, object data)
1309
// outputFormatter.PrintToken(Tokens.On);
1310
// outputFormatter.Space();
1311
// outputFormatter.PrintToken(Tokens.Error);
1312
// outputFormatter.Space();
1313
// TrackedVisit(onErrorStatement.EmbeddedStatement, data);
1317
// public override object TrackedVisitReDimStatement(ReDimStatement reDimStatement, object data)
1319
// outputFormatter.PrintToken(Tokens.ReDim);
1320
// outputFormatter.Space();
1321
// if (reDimStatement.IsPreserve) {
1322
// outputFormatter.PrintToken(Tokens.Preserve);
1323
// outputFormatter.Space();
1326
// AppendCommaSeparatedList(reDimStatement.ReDimClauses);
1330
// public override object TrackedVisitExpressionStatement(ExpressionStatement expressionStatement, object data)
1332
// TrackedVisit(expressionStatement.Expression, data);
1336
// public override object TrackedVisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
1338
// if (localVariableDeclaration.Modifier != Modifiers.None) {
1339
// OutputModifier(localVariableDeclaration.Modifier & ~Modifiers.Dim);
1341
// if (!isUsingResourceAcquisition) {
1342
// if ((localVariableDeclaration.Modifier & Modifiers.Const) == 0) {
1343
// outputFormatter.PrintToken(Tokens.Dim);
1345
// outputFormatter.Space();
1347
// currentVariableType = localVariableDeclaration.TypeReference;
1349
// AppendCommaSeparatedList(localVariableDeclaration.Variables);
1350
// currentVariableType = null;
1355
// public override object TrackedVisitReturnStatement(ReturnStatement returnStatement, object data)
1357
// outputFormatter.PrintToken(Tokens.Return);
1358
// if (!returnStatement.Expression.IsNull) {
1359
// outputFormatter.Space();
1360
// TrackedVisit(returnStatement.Expression, data);
1365
// public override object TrackedVisitIfElseStatement(IfElseStatement ifElseStatement, object data)
1367
// outputFormatter.PrintToken(Tokens.If);
1368
// outputFormatter.Space();
1369
// TrackedVisit(ifElseStatement.Condition, data);
1370
// outputFormatter.Space();
1371
// outputFormatter.PrintToken(Tokens.Then);
1372
// outputFormatter.NewLine();
1374
// PrintIndentedBlock(ifElseStatement.TrueStatement);
1376
// foreach (ElseIfSection elseIfSection in ifElseStatement.ElseIfSections) {
1377
// TrackedVisit(elseIfSection, data);
1380
// if (ifElseStatement.HasElseStatements) {
1381
// outputFormatter.Indent();
1382
// outputFormatter.PrintToken(Tokens.Else);
1383
// outputFormatter.NewLine();
1384
// PrintIndentedBlock(ifElseStatement.FalseStatement);
1387
// outputFormatter.Indent();
1388
// outputFormatter.PrintToken(Tokens.End);
1389
// outputFormatter.Space();
1390
// outputFormatter.PrintToken(Tokens.If);
1394
// public override object TrackedVisitElseIfSection(ElseIfSection elseIfSection, object data)
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);
1407
// public override object TrackedVisitLabelStatement(LabelStatement labelStatement, object data)
1409
// outputFormatter.PrintIdentifier(labelStatement.Label);
1410
// outputFormatter.PrintToken(Tokens.Colon);
1414
// public override object TrackedVisitGotoStatement(GotoStatement gotoStatement, object data)
1416
// outputFormatter.PrintToken(Tokens.GoTo);
1417
// outputFormatter.Space();
1418
// outputFormatter.PrintIdentifier(gotoStatement.Label);
1422
// public override object TrackedVisitSwitchStatement(SwitchStatement switchStatement, object data)
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);
1435
// --outputFormatter.IndentationLevel;
1436
// outputFormatter.Indent();
1437
// outputFormatter.PrintToken(Tokens.End);
1438
// outputFormatter.Space();
1439
// outputFormatter.PrintToken(Tokens.Select);
1440
// exitTokenStack.Pop();
1444
// public override object TrackedVisitSwitchSection(SwitchSection switchSection, object data)
1446
// outputFormatter.Indent();
1447
// outputFormatter.PrintToken(Tokens.Case);
1448
// outputFormatter.Space();
1449
// this.AppendCommaSeparatedList(switchSection.SwitchLabels);
1450
// outputFormatter.NewLine();
1452
// PrintIndentedBlock(switchSection.Children);
1457
// public override object TrackedVisitCaseLabel(CaseLabel caseLabel, object data)
1459
// if (caseLabel.IsDefault) {
1460
// outputFormatter.PrintToken(Tokens.Else);
1462
// if (caseLabel.BinaryOperatorType != BinaryOperatorType.None) {
1463
// switch (caseLabel.BinaryOperatorType) {
1464
// case BinaryOperatorType.Equality:
1465
// outputFormatter.PrintToken(Tokens.Assign);
1467
// case BinaryOperatorType.InEquality:
1468
// outputFormatter.PrintToken(Tokens.LessThan);
1469
// outputFormatter.PrintToken(Tokens.GreaterThan);
1472
// case BinaryOperatorType.GreaterThan:
1473
// outputFormatter.PrintToken(Tokens.GreaterThan);
1475
// case BinaryOperatorType.GreaterThanOrEqual:
1476
// outputFormatter.PrintToken(Tokens.GreaterEqual);
1478
// case BinaryOperatorType.LessThan:
1479
// outputFormatter.PrintToken(Tokens.LessThan);
1481
// case BinaryOperatorType.LessThanOrEqual:
1482
// outputFormatter.PrintToken(Tokens.LessEqual);
1485
// outputFormatter.Space();
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);
1500
// public override object TrackedVisitStopStatement(StopStatement stopStatement, object data)
1502
// outputFormatter.PrintToken(Tokens.Stop);
1506
// public override object TrackedVisitResumeStatement(ResumeStatement resumeStatement, object data)
1508
// outputFormatter.PrintToken(Tokens.Resume);
1509
// outputFormatter.Space();
1510
// if (resumeStatement.IsResumeNext) {
1511
// outputFormatter.PrintToken(Tokens.Next);
1513
// outputFormatter.PrintIdentifier(resumeStatement.LabelName);
1518
// public override object TrackedVisitEndStatement(EndStatement endStatement, object data)
1520
// outputFormatter.PrintToken(Tokens.End);
1524
// public override object TrackedVisitContinueStatement(ContinueStatement continueStatement, object data)
1526
// outputFormatter.PrintToken(Tokens.Continue);
1527
// outputFormatter.Space();
1528
// switch (continueStatement.ContinueType) {
1529
// case ContinueType.Do:
1530
// outputFormatter.PrintToken(Tokens.Do);
1532
// case ContinueType.For:
1533
// outputFormatter.PrintToken(Tokens.For);
1535
// case ContinueType.While:
1536
// outputFormatter.PrintToken(Tokens.While);
1539
// outputFormatter.PrintToken(exitTokenStack.Peek());
1545
// public override object TrackedVisitDoLoopStatement(DoLoopStatement doLoopStatement, object data)
1547
// if (doLoopStatement.ConditionPosition == ConditionPosition.None) {
1548
// Error(String.Format("Unknown condition position for loop : {0}.", doLoopStatement), doLoopStatement.StartLocation);
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);
1559
// case ConditionType.While:
1560
// exitTokenStack.Push(Tokens.While);
1561
// outputFormatter.PrintToken(Tokens.While);
1563
// case ConditionType.Until:
1564
// exitTokenStack.Push(Tokens.Do);
1565
// outputFormatter.PrintToken(Tokens.Do);
1566
// outputFormatter.Space();
1567
// outputFormatter.PrintToken(Tokens.While);
1570
// throw new InvalidOperationException();
1572
// outputFormatter.Space();
1573
// TrackedVisit(doLoopStatement.Condition, null);
1575
// exitTokenStack.Push(Tokens.Do);
1576
// outputFormatter.PrintToken(Tokens.Do);
1579
// outputFormatter.NewLine();
1581
// PrintIndentedBlock(doLoopStatement.EmbeddedStatement);
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);
1589
// outputFormatter.PrintToken(Tokens.Loop);
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);
1599
// case ConditionType.Until:
1600
// outputFormatter.PrintToken(Tokens.Until);
1603
// outputFormatter.Space();
1604
// TrackedVisit(doLoopStatement.Condition, null);
1606
// exitTokenStack.Pop();
1610
// public override object TrackedVisitForeachStatement(ForeachStatement foreachStatement, object data)
1612
// exitTokenStack.Push(Tokens.For);
1613
// outputFormatter.PrintToken(Tokens.For);
1614
// outputFormatter.Space();
1615
// outputFormatter.PrintToken(Tokens.Each);
1616
// outputFormatter.Space();
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);
1627
// outputFormatter.Space();
1628
// outputFormatter.PrintToken(Tokens.In);
1629
// outputFormatter.Space();
1631
// TrackedVisit(foreachStatement.Expression, data);
1632
// outputFormatter.NewLine();
1634
// PrintIndentedBlock(foreachStatement.EmbeddedStatement);
1636
// outputFormatter.Indent();
1637
// outputFormatter.PrintToken(Tokens.Next);
1638
// if (!foreachStatement.NextExpression.IsNull) {
1639
// outputFormatter.Space();
1640
// TrackedVisit(foreachStatement.NextExpression, data);
1642
// exitTokenStack.Pop();
1646
// public override object TrackedVisitLockStatement(LockStatement lockStatement, object data)
1648
// outputFormatter.PrintToken(Tokens.SyncLock);
1649
// outputFormatter.Space();
1650
// TrackedVisit(lockStatement.LockExpression, data);
1651
// outputFormatter.NewLine();
1653
// PrintIndentedBlock(lockStatement.EmbeddedStatement);
1655
// outputFormatter.Indent();
1656
// outputFormatter.PrintToken(Tokens.End);
1657
// outputFormatter.Space();
1658
// outputFormatter.PrintToken(Tokens.SyncLock);
1662
// bool isUsingResourceAcquisition;
1664
// public override object TrackedVisitUsingStatement(UsingStatement usingStatement, object data)
1666
// outputFormatter.PrintToken(Tokens.Using);
1667
// outputFormatter.Space();
1669
// isUsingResourceAcquisition = true;
1670
// TrackedVisit(usingStatement.ResourceAcquisition, data);
1671
// isUsingResourceAcquisition = false;
1672
// outputFormatter.NewLine();
1674
// PrintIndentedBlock(usingStatement.EmbeddedStatement);
1676
// outputFormatter.Indent();
1677
// outputFormatter.PrintToken(Tokens.End);
1678
// outputFormatter.Space();
1679
// outputFormatter.PrintToken(Tokens.Using);
1684
// public override object TrackedVisitWithStatement(WithStatement withStatement, object data)
1686
// outputFormatter.PrintToken(Tokens.With);
1687
// outputFormatter.Space();
1688
// TrackedVisit(withStatement.Expression, data);
1689
// outputFormatter.NewLine();
1691
// PrintIndentedBlock(withStatement.Body);
1693
// outputFormatter.PrintToken(Tokens.End);
1694
// outputFormatter.Space();
1695
// outputFormatter.PrintToken(Tokens.With);
1699
// public override object TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
1701
// exitTokenStack.Push(Tokens.Try);
1702
// outputFormatter.PrintToken(Tokens.Try);
1703
// outputFormatter.NewLine();
1705
// PrintIndentedBlock(tryCatchStatement.StatementBlock);
1707
// foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
1708
// TrackedVisit(catchClause, data);
1711
// if (!tryCatchStatement.FinallyBlock.IsNull) {
1712
// outputFormatter.Indent();
1713
// outputFormatter.PrintToken(Tokens.Finally);
1714
// outputFormatter.NewLine();
1715
// PrintIndentedBlock(tryCatchStatement.FinallyBlock);
1717
// outputFormatter.Indent();
1718
// outputFormatter.PrintToken(Tokens.End);
1719
// outputFormatter.Space();
1720
// outputFormatter.PrintToken(Tokens.Try);
1721
// exitTokenStack.Pop();
1725
// public override object TrackedVisitCatchClause(CatchClause catchClause, object data)
1727
// outputFormatter.Indent();
1728
// outputFormatter.PrintToken(Tokens.Catch);
1730
// if (!catchClause.TypeReference.IsNull) {
1731
// outputFormatter.Space();
1732
// if (catchClause.VariableName.Length > 0) {
1733
// outputFormatter.PrintIdentifier(catchClause.VariableName);
1735
// outputFormatter.PrintIdentifier("generatedExceptionName");
1737
// outputFormatter.Space();
1738
// outputFormatter.PrintToken(Tokens.As);
1739
// outputFormatter.Space();
1740
// outputFormatter.PrintIdentifier(catchClause.TypeReference.Type);
1743
// if (!catchClause.Condition.IsNull) {
1744
// outputFormatter.Space();
1745
// outputFormatter.PrintToken(Tokens.When);
1746
// outputFormatter.Space();
1747
// TrackedVisit(catchClause.Condition, data);
1749
// outputFormatter.NewLine();
1751
// PrintIndentedBlock(catchClause.StatementBlock);
1756
// public override object TrackedVisitThrowStatement(ThrowStatement throwStatement, object data)
1758
// outputFormatter.PrintToken(Tokens.Throw);
1759
// if (!throwStatement.Expression.IsNull) {
1760
// outputFormatter.Space();
1761
// TrackedVisit(throwStatement.Expression, data);
1766
// public override object TrackedVisitExitStatement(ExitStatement exitStatement, object data)
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);
1775
// case ExitType.Function:
1776
// outputFormatter.PrintToken(Tokens.Function);
1778
// case ExitType.Property:
1779
// outputFormatter.PrintToken(Tokens.Property);
1781
// case ExitType.Do:
1782
// outputFormatter.PrintToken(Tokens.Do);
1784
// case ExitType.For:
1785
// outputFormatter.PrintToken(Tokens.For);
1787
// case ExitType.Try:
1788
// outputFormatter.PrintToken(Tokens.Try);
1790
// case ExitType.While:
1791
// outputFormatter.PrintToken(Tokens.While);
1793
// case ExitType.Select:
1794
// outputFormatter.PrintToken(Tokens.Select);
1797
// Error(String.Format("Unsupported exit type : {0}", exitStatement.ExitType), exitStatement.StartLocation);
1805
// public override object TrackedVisitForNextStatement(ForNextStatement forNextStatement, object data)
1807
// exitTokenStack.Push(Tokens.For);
1808
// outputFormatter.PrintToken(Tokens.For);
1809
// outputFormatter.Space();
1811
// if (!forNextStatement.LoopVariableExpression.IsNull) {
1812
// TrackedVisit(forNextStatement.LoopVariableExpression, data);
1814
// outputFormatter.PrintIdentifier(forNextStatement.VariableName);
1816
// if (!forNextStatement.TypeReference.IsNull) {
1817
// outputFormatter.Space();
1818
// outputFormatter.PrintToken(Tokens.As);
1819
// outputFormatter.Space();
1820
// TrackedVisit(forNextStatement.TypeReference, data);
1824
// outputFormatter.Space();
1825
// outputFormatter.PrintToken(Tokens.Assign);
1826
// outputFormatter.Space();
1828
// TrackedVisit(forNextStatement.Start, data);
1830
// outputFormatter.Space();
1831
// outputFormatter.PrintToken(Tokens.To);
1832
// outputFormatter.Space();
1834
// TrackedVisit(forNextStatement.End, data);
1836
// if (!forNextStatement.Step.IsNull) {
1837
// outputFormatter.Space();
1838
// outputFormatter.PrintToken(Tokens.Step);
1839
// outputFormatter.Space();
1840
// TrackedVisit(forNextStatement.Step, data);
1842
// outputFormatter.NewLine();
1844
// PrintIndentedBlock(forNextStatement.EmbeddedStatement);
1846
// outputFormatter.Indent();
1847
// outputFormatter.PrintToken(Tokens.Next);
1849
// if (forNextStatement.NextExpressions.Count > 0) {
1850
// outputFormatter.Space();
1851
// AppendCommaSeparatedList(forNextStatement.NextExpressions);
1853
// exitTokenStack.Pop();
1858
// #region Expressions
1860
// public override object TrackedVisitClassReferenceExpression(ClassReferenceExpression classReferenceExpression, object data)
1862
// outputFormatter.PrintToken(Tokens.MyClass);
1867
// static string ConvertCharLiteral(char ch)
1869
// if (Char.IsControl(ch)) {
1870
// string charName = GetCharName(ch);
1871
// if (charName != null)
1872
// return "ControlChars." + charName;
1874
// return "ChrW(" + ((int)ch).ToString() + ")";
1875
// } else if (ch == '"') {
1876
// return "\"\"\"\"C";
1878
// return "\"" + ch.ToString() + "\"C";
1882
// static string GetCharName(char ch)
1890
// return "FormFeed";
1894
// return "NullChar";
1898
// return "VerticalTab";
1904
// static string ConvertString(string str)
1906
// StringBuilder sb = new StringBuilder();
1907
// bool inString = false;
1908
// foreach (char ch in str) {
1909
// if (char.IsControl(ch)) {
1912
// inString = false;
1914
// if (sb.Length > 0)
1915
// sb.Append(" & ");
1916
// string charName = GetCharName(ch);
1917
// if (charName != null)
1918
// sb.Append("vb" + charName);
1920
// sb.Append("ChrW(" + ((int)ch) + ")");
1923
// if (sb.Length > 0)
1924
// sb.Append(" & ");
1929
// sb.Append("\"\"");
1937
// if (sb.Length == 0)
1939
// return sb.ToString();
1942
// public override object TrackedVisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
1944
// outputFormatter.PrintText(ToVBNetString(primitiveExpression));
1948
// internal static string ToVBNetString(PrimitiveExpression primitiveExpression)
1950
// object val = primitiveExpression.Value;
1951
// if (val == null) {
1952
// return "Nothing";
1954
// if (val is bool) {
1955
// if ((bool)primitiveExpression.Value) {
1962
// if (val is string) {
1963
// return ConvertString((string)val);
1966
// if (val is char) {
1967
// return ConvertCharLiteral((char)primitiveExpression.Value);
1970
// if (val is decimal) {
1971
// return ((decimal)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "D";
1974
// if (val is float) {
1975
// return ((float)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "F";
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";
1986
// if (val is IFormattable) {
1987
// StringBuilder b = new StringBuilder();
1988
// if (primitiveExpression.LiteralFormat == LiteralFormat.HexadecimalNumber) {
1990
// b.Append(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo));
1992
// b.Append(((IFormattable)val).ToString(null, NumberFormatInfo.InvariantInfo));
1994
// if (val is ushort || val is uint || val is ulong) {
1999
// if (val is long || val is ulong)
2001
// if (val is short || val is ushort)
2003
// return b.ToString();
2005
// return val.ToString();
2009
// public override object TrackedVisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data)
2012
// switch (binaryOperatorExpression.Op) {
2013
// case BinaryOperatorType.Concat:
2014
// op = Tokens.ConcatString;
2017
// case BinaryOperatorType.Add:
2018
// op = Tokens.Plus;
2021
// case BinaryOperatorType.Subtract:
2022
// op = Tokens.Minus;
2025
// case BinaryOperatorType.Multiply:
2026
// op = Tokens.Times;
2029
// case BinaryOperatorType.Divide:
2033
// case BinaryOperatorType.DivideInteger:
2034
// op = Tokens.DivInteger;
2037
// case BinaryOperatorType.Modulus:
2041
// case BinaryOperatorType.ShiftLeft:
2042
// op = Tokens.ShiftLeft;
2045
// case BinaryOperatorType.ShiftRight:
2046
// op = Tokens.ShiftRight;
2049
// case BinaryOperatorType.BitwiseAnd:
2052
// case BinaryOperatorType.BitwiseOr:
2055
// case BinaryOperatorType.ExclusiveOr:
2059
// case BinaryOperatorType.LogicalAnd:
2060
// op = Tokens.AndAlso;
2062
// case BinaryOperatorType.LogicalOr:
2063
// op = Tokens.OrElse;
2065
// case BinaryOperatorType.ReferenceEquality:
2068
// case BinaryOperatorType.ReferenceInequality:
2069
// op = Tokens.IsNot;
2072
// case BinaryOperatorType.Equality:
2073
// op = Tokens.Assign;
2075
// case BinaryOperatorType.GreaterThan:
2076
// op = Tokens.GreaterThan;
2078
// case BinaryOperatorType.GreaterThanOrEqual:
2079
// op = Tokens.GreaterEqual;
2081
// case BinaryOperatorType.InEquality:
2082
// op = Tokens.NotEqual;
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);
2092
// case BinaryOperatorType.DictionaryAccess:
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);
2099
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
2100
// TrackedVisit(binaryOperatorExpression.Right, data);
2101
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
2105
// case BinaryOperatorType.LessThan:
2106
// op = Tokens.LessThan;
2108
// case BinaryOperatorType.LessThanOrEqual:
2109
// op = Tokens.LessEqual;
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);
2122
// outputFormatter.Space();
2123
// outputFormatter.PrintToken(op);
2124
// outputFormatter.Space();
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);
2137
// public override object TrackedVisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
2139
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
2140
// TrackedVisit(parenthesizedExpression.Expression, data);
2141
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
2145
// public override object TrackedVisitInvocationExpression(InvocationExpression invocationExpression, object data)
2147
// TrackedVisit(invocationExpression.TargetObject, data);
2148
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
2149
// AppendCommaSeparatedList(invocationExpression.Arguments);
2150
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
2154
// void PrintTypeArguments(List<TypeReference> typeArguments)
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);
2165
// public override object TrackedVisitIdentifierExpression(SimpleNameExpression identifierExpression, object data)
2167
// outputFormatter.PrintIdentifier(identifierExpression.Identifier);
2168
// PrintTypeArguments(identifierExpression.TypeArguments);
2172
// public override object TrackedVisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data)
2174
// TrackedVisit(typeReferenceExpression.TypeReference, data);
2178
// public override object TrackedVisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data)
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);
2188
// case UnaryOperatorType.Decrement:
2189
// outputFormatter.PrintText("System.Threading.Interlocked.Decrement(");
2190
// TrackedVisit(unaryOperatorExpression.Expression, data);
2191
// outputFormatter.PrintText(")");
2194
// case UnaryOperatorType.Increment:
2195
// outputFormatter.PrintText("System.Threading.Interlocked.Increment(");
2196
// TrackedVisit(unaryOperatorExpression.Expression, data);
2197
// outputFormatter.PrintText(")");
2200
// case UnaryOperatorType.Minus:
2201
// outputFormatter.PrintToken(Tokens.Minus);
2202
// TrackedVisit(unaryOperatorExpression.Expression, data);
2205
// case UnaryOperatorType.Plus:
2206
// outputFormatter.PrintToken(Tokens.Plus);
2207
// TrackedVisit(unaryOperatorExpression.Expression, data);
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)");
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)");
2226
// case UnaryOperatorType.Dereference:
2227
// outputFormatter.PrintToken(Tokens.Times);
2228
// TrackedVisit(unaryOperatorExpression.Expression, data);
2230
// case UnaryOperatorType.AddressOf:
2231
// outputFormatter.PrintToken(Tokens.AddressOf);
2232
// TrackedVisit(unaryOperatorExpression.Expression, data);
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(")");
2244
// public override object TrackedVisitAssignmentExpression(AssignmentExpression assignmentExpression, object data)
2247
// bool unsupportedOpAssignment = false;
2248
// switch (assignmentExpression.Op) {
2249
// case AssignmentOperatorType.Assign:
2250
// op = Tokens.Assign;
2252
// case AssignmentOperatorType.Add:
2253
// op = Tokens.PlusAssign;
2255
// case AssignmentOperatorType.Subtract:
2256
// op = Tokens.MinusAssign;
2258
// case AssignmentOperatorType.Multiply:
2259
// op = Tokens.TimesAssign;
2261
// case AssignmentOperatorType.Divide:
2262
// op = Tokens.DivAssign;
2264
// case AssignmentOperatorType.ShiftLeft:
2265
// op = Tokens.ShiftLeftAssign;
2267
// case AssignmentOperatorType.ShiftRight:
2268
// op = Tokens.ShiftRightAssign;
2271
// case AssignmentOperatorType.ExclusiveOr:
2273
// unsupportedOpAssignment = true;
2275
// case AssignmentOperatorType.Modulus:
2277
// unsupportedOpAssignment = true;
2279
// case AssignmentOperatorType.BitwiseAnd:
2281
// unsupportedOpAssignment = true;
2283
// case AssignmentOperatorType.BitwiseOr:
2285
// unsupportedOpAssignment = true;
2289
// TrackedVisit(assignmentExpression.Left, data);
2290
// outputFormatter.Space();
2292
// if (unsupportedOpAssignment) { // left = left OP right
2293
// outputFormatter.PrintToken(Tokens.Assign);
2294
// outputFormatter.Space();
2295
// TrackedVisit(assignmentExpression.Left, data);
2296
// outputFormatter.Space();
2299
// outputFormatter.PrintToken(op);
2300
// outputFormatter.Space();
2301
// TrackedVisit(assignmentExpression.Right, data);
2306
// public override object TrackedVisitTypeOfExpression(TypeOfExpression typeOfExpression, object data)
2308
// outputFormatter.PrintToken(Tokens.GetType);
2309
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
2310
// TrackedVisit(typeOfExpression.TypeReference, data);
2311
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
2315
// public override object TrackedVisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data)
2317
// // assigning nothing to a generic type in VB compiles to a DefaultValueExpression
2318
// outputFormatter.PrintToken(Tokens.Nothing);
2322
// public override object TrackedVisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data)
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);
2334
// public override object TrackedVisitAddressOfExpression(AddressOfExpression addressOfExpression, object data)
2336
// outputFormatter.PrintToken(Tokens.AddressOf);
2337
// outputFormatter.Space();
2338
// TrackedVisit(addressOfExpression.Expression, data);
2342
// public override object TrackedVisitCastExpression(CastExpression castExpression, object data)
2344
// if (castExpression.CastType == CastType.TryCast) {
2345
// return PrintCast(Tokens.TryCast, castExpression);
2347
// if (castExpression.CastType == CastType.Cast || castExpression.CastTo.IsArrayType) {
2348
// return PrintCast(Tokens.DirectCast, castExpression);
2350
// switch (castExpression.CastTo.Type) {
2351
// case "System.Boolean":
2352
// outputFormatter.PrintToken(Tokens.CBool);
2354
// case "System.Byte":
2355
// outputFormatter.PrintToken(Tokens.CByte);
2357
// case "System.SByte":
2358
// outputFormatter.PrintToken(Tokens.CSByte);
2360
// case "System.Char":
2361
// outputFormatter.PrintToken(Tokens.CChar);
2363
// case "System.DateTime":
2364
// outputFormatter.PrintToken(Tokens.CDate);
2366
// case "System.Decimal":
2367
// outputFormatter.PrintToken(Tokens.CDec);
2369
// case "System.Double":
2370
// outputFormatter.PrintToken(Tokens.CDbl);
2372
// case "System.Int16":
2373
// outputFormatter.PrintToken(Tokens.CShort);
2375
// case "System.Int32":
2376
// outputFormatter.PrintToken(Tokens.CInt);
2378
// case "System.Int64":
2379
// outputFormatter.PrintToken(Tokens.CLng);
2381
// case "System.UInt16":
2382
// outputFormatter.PrintToken(Tokens.CUShort);
2384
// case "System.UInt32":
2385
// outputFormatter.PrintToken(Tokens.CUInt);
2387
// case "System.UInt64":
2388
// outputFormatter.PrintToken(Tokens.CULng);
2390
// case "System.Object":
2391
// outputFormatter.PrintToken(Tokens.CObj);
2393
// case "System.Single":
2394
// outputFormatter.PrintToken(Tokens.CSng);
2396
// case "System.String":
2397
// outputFormatter.PrintToken(Tokens.CStr);
2400
// return PrintCast(Tokens.CType, castExpression);
2402
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
2403
// TrackedVisit(castExpression.Expression, data);
2404
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
2408
// object PrintCast(int castToken, CastExpression castExpression)
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);
2420
// public override object TrackedVisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data)
2422
// outputFormatter.PrintToken(Tokens.Me);
2426
// public override object TrackedVisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data)
2428
// outputFormatter.PrintToken(Tokens.MyBase);
2432
// public override object TrackedVisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
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);
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);
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];
2455
// outputFormatter.PrintToken(Tokens.Comma);
2456
// outputFormatter.PrintLineContinuation();
2457
// outputFormatter.Indent();
2458
// TrackedVisit(expr, data);
2460
// outputFormatter.IndentationLevel--;
2461
// outputFormatter.PrintLineContinuation();
2462
// outputFormatter.Indent();
2463
// outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
2468
// public override object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
2470
// outputFormatter.PrintToken(Tokens.New);
2471
// outputFormatter.Space();
2472
// PrintTypeReferenceWithoutArray(arrayCreateExpression.CreateType);
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);
2480
// PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 0);
2483
// outputFormatter.Space();
2485
// if (arrayCreateExpression.ArrayInitializer.IsNull) {
2486
// outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
2487
// outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
2489
// TrackedVisit(arrayCreateExpression.ArrayInitializer, data);
2494
// public override object TrackedVisitCollectionInitializerExpression(CollectionInitializerExpression arrayInitializerExpression, object data)
2496
// outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
2497
// this.AppendCommaSeparatedList(arrayInitializerExpression.CreateExpressions);
2498
// outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
2502
// public override object TrackedVisitMemberInitializerExpression(MemberInitializerExpression memberInitializerExpression, object data)
2504
// if (memberInitializerExpression.IsKey) {
2505
// outputFormatter.PrintToken(Tokens.Key);
2506
// outputFormatter.Space();
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);
2517
// public override object TrackedVisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
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))
2524
// outputFormatter.PrintToken(Tokens.New);
2526
// outputFormatter.PrintIdentifier(memberReferenceExpression.MemberName);
2528
// PrintTypeArguments(memberReferenceExpression.TypeArguments);
2532
// public override object TrackedVisitDirectionExpression(DirectionExpression directionExpression, object data)
2534
// // VB does not need to specify the direction in method calls
2535
// TrackedVisit(directionExpression.Expression, data);
2540
// public override object TrackedVisitConditionalExpression(ConditionalExpression conditionalExpression, object data)
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);
2559
// void OutputModifier(ParameterModifiers modifier)
2561
// if ((modifier & ParameterModifiers.Optional) == ParameterModifiers.Optional) {
2562
// outputFormatter.PrintToken(Tokens.Optional);
2563
// outputFormatter.Space();
2565
// if ((modifier & ParameterModifiers.Ref) == ParameterModifiers.Ref
2566
// || (modifier & ParameterModifiers.Out) == ParameterModifiers.Out) {
2567
// outputFormatter.PrintToken(Tokens.ByRef);
2568
// outputFormatter.Space();
2570
// if ((modifier & ParameterModifiers.Params) == ParameterModifiers.Params) {
2571
// outputFormatter.PrintToken(Tokens.ParamArray);
2572
// outputFormatter.Space();
2574
// if (prettyPrintOptions.OutputByValModifier &&
2575
// (modifier & (ParameterModifiers.Params | ParameterModifiers.Ref)) == ParameterModifiers.None)
2577
// outputFormatter.PrintToken(Tokens.ByVal);
2578
// outputFormatter.Space();
2582
// void OutputModifier(Modifiers modifier)
2584
// OutputModifier(modifier, false, false);
2587
// void OutputModifier(Modifiers modifier, bool forTypeDecl, bool forFieldDecl)
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();
2608
// if ((modifier & Modifiers.Static) == Modifiers.Static) {
2609
// outputFormatter.PrintToken(Tokens.Shared);
2610
// outputFormatter.Space();
2612
// if ((modifier & Modifiers.Virtual) == Modifiers.Virtual) {
2613
// outputFormatter.PrintToken(Tokens.Overridable);
2614
// outputFormatter.Space();
2616
// if ((modifier & Modifiers.Abstract) == Modifiers.Abstract) {
2617
// if (forFieldDecl)
2618
// outputFormatter.PrintToken(Tokens.Dim);
2619
// else if (forTypeDecl)
2620
// outputFormatter.PrintToken(Tokens.MustInherit);
2622
// outputFormatter.PrintToken(Tokens.MustOverride);
2623
// outputFormatter.Space();
2625
// if ((modifier & Modifiers.Dim) == Modifiers.Dim) {
2626
// outputFormatter.PrintToken(Tokens.Dim);
2627
// outputFormatter.Space();
2629
// if ((modifier & Modifiers.Overloads) == Modifiers.Overloads) {
2630
// outputFormatter.PrintToken(Tokens.Overloads);
2631
// outputFormatter.Space();
2633
// if ((modifier & Modifiers.Override) == Modifiers.Override) {
2634
// outputFormatter.PrintToken(Tokens.Overrides);
2635
// outputFormatter.Space();
2637
// if ((modifier & Modifiers.New) == Modifiers.New) {
2638
// outputFormatter.PrintToken(Tokens.Shadows);
2639
// outputFormatter.Space();
2642
// if ((modifier & Modifiers.Sealed) == Modifiers.Sealed) {
2643
// outputFormatter.PrintToken(forTypeDecl ? Tokens.NotInheritable : Tokens.NotOverridable);
2644
// outputFormatter.Space();
2647
// if ((modifier & Modifiers.ReadOnly) == Modifiers.ReadOnly) {
2648
// outputFormatter.PrintToken(Tokens.ReadOnly);
2649
// outputFormatter.Space();
2651
// if ((modifier & Modifiers.WriteOnly) == Modifiers.WriteOnly) {
2652
// outputFormatter.PrintToken(Tokens.WriteOnly);
2653
// outputFormatter.Space();
2655
// if ((modifier & Modifiers.Const) == Modifiers.Const) {
2656
// outputFormatter.PrintToken(Tokens.Const);
2657
// outputFormatter.Space();
2659
// if ((modifier & Modifiers.WithEvents) == Modifiers.WithEvents) {
2660
// outputFormatter.PrintToken(Tokens.WithEvents);
2661
// outputFormatter.Space();
2663
// if ((modifier & Modifiers.Partial) == Modifiers.Partial) {
2664
// outputFormatter.PrintToken(Tokens.Partial);
2665
// outputFormatter.Space();
2668
// if ((modifier & Modifiers.Extern) == Modifiers.Extern) {
2669
// // not required in VB
2672
// if ((modifier & Modifiers.Default) == Modifiers.Default) {
2673
// outputFormatter.PrintToken(Tokens.Default);
2674
// outputFormatter.Space();
2677
// if ((modifier & Modifiers.Volatile) == Modifiers.Volatile) {
2678
// Error("'Volatile' modifier not convertable", Location.Empty);
2681
// if ((modifier & Modifiers.Unsafe) == Modifiers.Unsafe) {
2682
// Error("'Unsafe' modifier not convertable", Location.Empty);
2686
// public void AppendCommaSeparatedList<T>(ICollection<T> list) where T : class, INode
2688
// if (list != null) {
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");
2706
// void VisitAttributes(ICollection attributes, object data)
2708
// if (attributes == null) {
2711
// foreach (AttributeSection section in attributes) {
2712
// if (string.Equals(section.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase))
2714
// TrackedVisit(section, data);
2718
// void VisitReturnTypeAttributes(ICollection attributes, object data)
2720
// if (attributes == null) {
2723
// printAttributeSectionInline = true;
2724
// foreach (AttributeSection section in attributes) {
2725
// if (string.Equals(section.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) {
2726
// TrackedVisit(section, data);
2729
// printAttributeSectionInline = false;
2732
// public override object TrackedVisitLambdaExpression(LambdaExpression lambdaExpression, object data)
2734
// bool isSub = !lambdaExpression.ReturnType.IsNull &&
2735
// lambdaExpression.ReturnType.Type == "System.Void" && lambdaExpression.ReturnType.IsKeyword;
2738
// outputFormatter.PrintToken(Tokens.Sub);
2740
// outputFormatter.PrintToken(Tokens.Function);
2742
// outputFormatter.PrintToken(Tokens.OpenParenthesis);
2743
// AppendCommaSeparatedList(lambdaExpression.Parameters);
2744
// outputFormatter.PrintToken(Tokens.CloseParenthesis);
2746
// outputFormatter.Space();
2748
// if (!lambdaExpression.ExpressionBody.IsNull) {
2749
// return lambdaExpression.ExpressionBody.AcceptVisitor(this, data);
2751
// if (!isSub && !lambdaExpression.ReturnType.IsNull) {
2752
// outputFormatter.PrintToken(Tokens.As);
2753
// outputFormatter.Space();
2754
// TrackedVisit(lambdaExpression.ReturnType, data);
2757
// if (lambdaExpression.StatementBody is BlockStatement)
2758
// outputFormatter.NewLine();
2760
// TrackedVisit(lambdaExpression.StatementBody, data);
2762
// if (lambdaExpression.StatementBody is BlockStatement) {
2763
// outputFormatter.NewLine();
2764
// outputFormatter.PrintToken(Tokens.End);
2765
// outputFormatter.Space();
2767
// outputFormatter.PrintToken(Tokens.Sub);
2769
// outputFormatter.PrintToken(Tokens.Function);
2776
// public override object TrackedVisitQueryExpression(QueryExpression queryExpression, object data)
2778
// outputFormatter.IndentationLevel++;
2779
// for (int i = 0; i < queryExpression.Clauses.Count; i++) {
2780
// QueryExpressionClause clause = queryExpression.Clauses[i];
2781
// if (!clause.IsNull) {
2783
// outputFormatter.PrintLineContinuation();
2784
// outputFormatter.Indent();
2786
// clause.AcceptVisitor(this, null);
2789
// outputFormatter.IndentationLevel--;
2793
// void PrintClause(QueryExpressionClause clause)
2798
// public override object TrackedVisitQueryExpressionFromClause(QueryExpressionFromClause fromClause, object data)
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);
2815
// public override object TrackedVisitQueryExpressionJoinClause(QueryExpressionJoinClause joinClause, object data)
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);
2842
//// void VisitQueryExpressionFromOrJoinClause(QueryExpressionFromOrJoinClause clause, object data)
2844
//// outputFormatter.PrintIdentifier(clause.Identifier);
2845
//// outputFormatter.Space();
2846
//// outputFormatter.PrintToken(Tokens.In);
2847
//// outputFormatter.Space();
2848
//// clause.InExpression.AcceptVisitor(this, data);
2851
// public override object TrackedVisitQueryExpressionLetClause(QueryExpressionLetClause letClause, object data)
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);
2862
// public override object TrackedVisitQueryExpressionGroupClause(QueryExpressionGroupClause groupClause, object data)
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);
2873
// public override object TrackedVisitQueryExpressionOrderClause(QueryExpressionOrderClause queryExpressionOrderClause, object data)
2875
// outputFormatter.PrintText("Order By");
2876
// outputFormatter.Space();
2877
// AppendCommaSeparatedList(queryExpressionOrderClause.Orderings);
2881
// public override object TrackedVisitQueryExpressionOrdering(QueryExpressionOrdering ordering, object data)
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");
2894
// public override object TrackedVisitQueryExpressionSelectVBClause(QueryExpressionSelectVBClause selectClause, object data)
2896
// outputFormatter.PrintToken(Tokens.Select);
2897
// outputFormatter.Space();
2898
// foreach (ExpressionRangeVariable var in selectClause.Variables) {
2899
// var.AcceptVisitor(this, data);
2904
// public override object TrackedVisitQueryExpressionWhereClause(QueryExpressionWhereClause whereClause, object data)
2906
// outputFormatter.Space();
2907
// outputFormatter.PrintText("Where");
2908
// outputFormatter.Space();
2909
// return whereClause.Condition.AcceptVisitor(this, data);
2912
// public override object TrackedVisitExternAliasDirective(ExternAliasDirective externAliasDirective, object data)
2914
// UnsupportedNode(externAliasDirective);
2918
// public override object TrackedVisitXmlContentExpression(XmlContentExpression xmlContentExpression, object data)
2920
// switch (xmlContentExpression.Type) {
2921
// case XmlContentType.Comment:
2922
// outputFormatter.PrintText("<!--" + xmlContentExpression.Content + "-->");
2924
// case XmlContentType.Text:
2925
// outputFormatter.PrintText(xmlContentExpression.Content);
2927
// case XmlContentType.CData:
2928
// outputFormatter.PrintText("<![CDATA[" + xmlContentExpression.Content + "]]>");
2930
// case XmlContentType.ProcessingInstruction:
2931
// outputFormatter.PrintText("<?" + xmlContentExpression.Content + "?>");
2934
// throw new Exception("Invalid value for XmlContentType");
2939
// public override object TrackedVisitXmlEmbeddedExpression(XmlEmbeddedExpression xmlEmbeddedExpression, object data)
2941
// outputFormatter.PrintText("<%=");
2942
// outputFormatter.Space();
2943
// xmlEmbeddedExpression.InlineVBExpression.AcceptVisitor(this, data);
2944
// outputFormatter.Space();
2945
// outputFormatter.PrintText("%>");
2949
// public override object TrackedVisitXmlAttributeExpression(XmlAttributeExpression xmlAttributeExpression, object data)
2951
// outputFormatter.PrintText(xmlAttributeExpression.Name);
2952
// outputFormatter.PrintToken(Tokens.Assign);
2953
// if (xmlAttributeExpression.IsLiteralValue) {
2954
// if (xmlAttributeExpression.UseDoubleQuotes)
2955
// outputFormatter.PrintText("\"");
2957
// outputFormatter.PrintText("'");
2958
// outputFormatter.PrintText(xmlAttributeExpression.LiteralValue);
2959
// if (xmlAttributeExpression.UseDoubleQuotes)
2960
// outputFormatter.PrintText("\"");
2962
// outputFormatter.PrintText("'");
2964
// xmlAttributeExpression.ExpressionValue.AcceptVisitor(this, data);
2968
// public override object TrackedVisitXmlElementExpression(XmlElementExpression xmlElementExpression, object data)
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);
2978
// outputFormatter.PrintText(xmlElementExpression.XmlName);
2980
// foreach (XmlExpression attribute in xmlElementExpression.Attributes) {
2981
// outputFormatter.Space();
2982
// attribute.AcceptVisitor(this, data);
2984
// if (xmlElementExpression.Children.Any()) {
2985
// outputFormatter.PrintText(">");
2986
// foreach (INode node in xmlElementExpression.Children) {
2987
// node.AcceptVisitor(this, data);
2989
// outputFormatter.PrintText("</");
2990
// if (!xmlElementExpression.NameIsExpression)
2991
// outputFormatter.PrintText(xmlElementExpression.XmlName);
2992
// outputFormatter.PrintText(">");
2994
// outputFormatter.Space();
2995
// outputFormatter.PrintText("/>");
3000
// public override object TrackedVisitXmlMemberAccessExpression(XmlMemberAccessExpression xmlMemberAccessExpression, object data)
3002
// xmlMemberAccessExpression.TargetObject.AcceptVisitor(this, data);
3003
// switch (xmlMemberAccessExpression.AxisType) {
3004
// case XmlAxisType.Element:
3005
// outputFormatter.PrintToken(Tokens.Dot);
3007
// case XmlAxisType.Attribute:
3008
// outputFormatter.PrintToken(Tokens.DotAt);
3010
// case XmlAxisType.Descendents:
3011
// outputFormatter.PrintToken(Tokens.TripleDot);
3014
// throw new Exception("Invalid value for XmlAxisType");
3016
// if (xmlMemberAccessExpression.IsXmlIdentifier)
3017
// outputFormatter.PrintText("<" + xmlMemberAccessExpression.Identifier + ">");
3019
// outputFormatter.PrintIdentifier(xmlMemberAccessExpression.Identifier);