PageRenderTime 39ms CodeModel.GetById 10ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/NRefactory/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs

http://github.com/icsharpcode/ILSpy
C# | 3023 lines | 13 code | 3 blank | 3007 comment | 0 complexity | e098561aafdc0914575cd1308fe85882 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
   2// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
   3
   4using System;
   5using System.Linq;
   6using System.Collections;
   7using System.Collections.Generic;
   8using System.Diagnostics;
   9using System.Globalization;
  10using System.Text;
  11
  12using ICSharpCode.NRefactory.VB.Ast;
  13using ICSharpCode.NRefactory.VB.Parser;
  14using ICSharpCode.NRefactory.VB.Visitors;
  15
  16namespace ICSharpCode.NRefactory.VB.PrettyPrinter
  17{
  18//	public sealed class VBNetOutputVisitor : NodeTrackingAstVisitor, IOutputDomVisitor
  19//	{
  20//		Errors                  errors             = new Errors();
  21//		VBNetOutputFormatter    outputFormatter;
  22//		VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions();
  23//		TypeDeclaration         currentType;
  24//		
  25//		Stack<int> exitTokenStack = new Stack<int>();
  26//		
  27//		public string Text {
  28//			get {
  29//				return outputFormatter.Text;
  30//			}
  31//		}
  32//		
  33//		public Errors Errors {
  34//			get {
  35//				return errors;
  36//			}
  37//		}
  38//		
  39//		AbstractPrettyPrintOptions IOutputDomVisitor.Options {
  40//			get { return prettyPrintOptions; }
  41//		}
  42//		
  43//		public VBNetPrettyPrintOptions Options {
  44//			get { return prettyPrintOptions; }
  45//		}
  46//		
  47//		public IOutputFormatter OutputFormatter {
  48//			get {
  49//				return outputFormatter;
  50//			}
  51//		}
  52//		
  53//		public VBNetOutputVisitor()
  54//		{
  55//			outputFormatter = new VBNetOutputFormatter(prettyPrintOptions);
  56//		}
  57//		
  58//		public event Action<INode> BeforeNodeVisit;
  59//		public event Action<INode> AfterNodeVisit;
  60//		
  61//		protected override void BeginVisit(INode node)
  62//		{
  63//			if (BeforeNodeVisit != null) {
  64//				BeforeNodeVisit(node);
  65//			}
  66//			base.BeginVisit(node);
  67//		}
  68//		
  69//		protected override void EndVisit(INode node)
  70//		{
  71//			base.EndVisit(node);
  72//			if (AfterNodeVisit != null) {
  73//				AfterNodeVisit(node);
  74//			}
  75//		}
  76//		
  77//		object TrackedVisit(INode node, object data)
  78//		{
  79//			return node.AcceptVisitor(this, data);
  80//		}
  81//		
  82//		void Error(string text, Location position)
  83//		{
  84//			errors.Error(position.Line, position.Column, text);
  85//		}
  86//		
  87//		void UnsupportedNode(INode node)
  88//		{
  89//			Error(node.GetType().Name + " is unsupported", node.StartLocation);
  90//		}
  91//		
  92//		#region ICSharpCode.NRefactory.Parser.IAstVisitor interface implementation
  93//		public override object TrackedVisitCompilationUnit(CompilationUnit compilationUnit, object data)
  94//		{
  95//			compilationUnit.AcceptChildren(this, data);
  96//			outputFormatter.EndFile();
  97//			return null;
  98//		}
  99//		
 100//		/// <summary>
 101//		/// Converts type name to primitive type name. Returns typeString if typeString is not
 102//		/// a primitive type.
 103//		/// </summary>
 104//		static string ConvertTypeString(string typeString)
 105//		{
 106//			string primitiveType;
 107//			if (TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType))
 108//				return primitiveType;
 109//			else
 110//				return typeString;
 111//		}
 112//
 113//		public override object TrackedVisitTypeReference(TypeReference typeReference, object data)
 114//		{
 115//			if (typeReference == TypeReference.ClassConstraint) {
 116//				outputFormatter.PrintToken(Tokens.Class);
 117//			} else if (typeReference == TypeReference.StructConstraint) {
 118//				outputFormatter.PrintToken(Tokens.Structure);
 119//			} else if (typeReference == TypeReference.NewConstraint) {
 120//				outputFormatter.PrintToken(Tokens.New);
 121//			} else {
 122//				PrintTypeReferenceWithoutArray(typeReference);
 123//				if (typeReference.IsArrayType) {
 124//					PrintArrayRank(typeReference.RankSpecifier, 0);
 125//				}
 126//			}
 127//			return null;
 128//		}
 129//		
 130//		void PrintTypeReferenceWithoutArray(TypeReference typeReference)
 131//		{
 132//			if (typeReference.IsGlobal) {
 133//				outputFormatter.PrintToken(Tokens.Global);
 134//				outputFormatter.PrintToken(Tokens.Dot);
 135//			}
 136//			bool printGenerics = true;
 137//			if (typeReference.IsKeyword) {
 138//				outputFormatter.PrintText(ConvertTypeString(typeReference.Type));
 139//			} else {
 140//				outputFormatter.PrintIdentifier(typeReference.Type);
 141//			}
 142//			if (printGenerics && typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) {
 143//				outputFormatter.PrintToken(Tokens.OpenParenthesis);
 144//				outputFormatter.PrintToken(Tokens.Of);
 145//				outputFormatter.Space();
 146//				AppendCommaSeparatedList(typeReference.GenericTypes);
 147//				outputFormatter.PrintToken(Tokens.CloseParenthesis);
 148//			}
 149//			for (int i = 0; i < typeReference.PointerNestingLevel; ++i) {
 150//				outputFormatter.PrintToken(Tokens.Times);
 151//			}
 152//		}
 153//		
 154//		void PrintArrayRank(int[] rankSpecifier, int startRank)
 155//		{
 156//			for (int i = startRank; i < rankSpecifier.Length; ++i) {
 157//				outputFormatter.PrintToken(Tokens.OpenParenthesis);
 158//				for (int j = 0; j < rankSpecifier[i]; ++j) {
 159//					outputFormatter.PrintToken(Tokens.Comma);
 160//				}
 161//				outputFormatter.PrintToken(Tokens.CloseParenthesis);
 162//			}
 163//		}
 164//		
 165//		public override object TrackedVisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data)
 166//		{
 167//			TrackedVisit(innerClassTypeReference.BaseType, data);
 168//			outputFormatter.PrintToken(Tokens.Dot);
 169//			return VisitTypeReference((TypeReference)innerClassTypeReference, data);
 170//		}
 171//		
 172//		#region Global scope
 173//		bool printAttributeSectionInline; // is set to true when printing parameter's attributes
 174//		
 175//		public override object TrackedVisitAttributeSection(AttributeSection attributeSection, object data)
 176//		{
 177//			if (!printAttributeSectionInline)
 178//				outputFormatter.Indent();
 179//			outputFormatter.PrintText("<");
 180//			if (!string.IsNullOrEmpty(attributeSection.AttributeTarget) && !string.Equals(attributeSection.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) {
 181//				outputFormatter.PrintText(char.ToUpperInvariant(attributeSection.AttributeTarget[0]) + attributeSection.AttributeTarget.Substring(1));
 182//				outputFormatter.PrintToken(Tokens.Colon);
 183//				outputFormatter.Space();
 184//			}
 185//			Debug.Assert(attributeSection.Attributes != null);
 186//			AppendCommaSeparatedList(attributeSection.Attributes);
 187//			
 188//			outputFormatter.PrintText(">");
 189//			
 190//			if ("assembly".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)
 191//			    || "module".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)) {
 192//				outputFormatter.NewLine();
 193//			} else {
 194//				if (printAttributeSectionInline)
 195//					outputFormatter.Space();
 196//				else
 197//					outputFormatter.PrintLineContinuation();
 198//			}
 199//			
 200//			return null;
 201//		}
 202//		
 203//		public override object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data)
 204//		{
 205//			outputFormatter.PrintIdentifier(attribute.Type);
 206//			if (attribute.PositionalArguments.Count > 0 || attribute.NamedArguments.Count > 0) {
 207//				outputFormatter.PrintToken(Tokens.OpenParenthesis);
 208//				AppendCommaSeparatedList(attribute.PositionalArguments);
 209//				
 210//				if (attribute.NamedArguments.Count > 0) {
 211//					if (attribute.PositionalArguments.Count > 0) {
 212//						outputFormatter.PrintToken(Tokens.Comma);
 213//						outputFormatter.Space();
 214//					}
 215//					AppendCommaSeparatedList(attribute.NamedArguments);
 216//				}
 217//				outputFormatter.PrintToken(Tokens.CloseParenthesis);
 218//			}
 219//			return null;
 220//		}
 221//		
 222//		public override object TrackedVisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data)
 223//		{
 224//			outputFormatter.PrintIdentifier(namedArgumentExpression.Name);
 225//			outputFormatter.Space();
 226//			outputFormatter.PrintToken(Tokens.Colon);
 227//			outputFormatter.PrintToken(Tokens.Assign);
 228//			outputFormatter.Space();
 229//			TrackedVisit(namedArgumentExpression.Expression, data);
 230//			return null;
 231//		}
 232//		
 233//		public override object TrackedVisitUsing(ImportsClause @using, object data)
 234//		{
 235//			Debug.Fail("Should never be called. The usings should be handled in Visit(UsingDeclaration)");
 236//			return null;
 237//		}
 238//		
 239//		public override object TrackedVisitUsingDeclaration(ImportsStatement usingDeclaration, object data)
 240//		{
 241//			outputFormatter.Indent();
 242//			outputFormatter.PrintToken(Tokens.Imports);
 243//			outputFormatter.Space();
 244//			for (int i = 0; i < usingDeclaration.ImportsClauses.Count; ++i) {
 245//				outputFormatter.PrintIdentifier(((ImportsClause)usingDeclaration.ImportsClauses[i]).Name);
 246//				if (((ImportsClause)usingDeclaration.ImportsClauses[i]).IsAlias) {
 247//					outputFormatter.Space();
 248//					outputFormatter.PrintToken(Tokens.Assign);
 249//					outputFormatter.Space();
 250//					TrackedVisit(((ImportsClause)usingDeclaration.ImportsClauses[i]).Alias, data);
 251//				}
 252//				if (i + 1 < usingDeclaration.ImportsClauses.Count) {
 253//					outputFormatter.PrintToken(Tokens.Comma);
 254//					outputFormatter.Space();
 255//				}
 256//			}
 257//			outputFormatter.NewLine();
 258//			return null;
 259//		}
 260//		
 261//		public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
 262//		{
 263//			outputFormatter.Indent();
 264//			outputFormatter.PrintToken(Tokens.Namespace);
 265//			outputFormatter.Space();
 266//			outputFormatter.PrintIdentifier(namespaceDeclaration.Name);
 267//			outputFormatter.NewLine();
 268//			
 269//			++outputFormatter.IndentationLevel;
 270//			namespaceDeclaration.AcceptChildren(this, data);
 271//			--outputFormatter.IndentationLevel;
 272//			
 273//			outputFormatter.Indent();
 274//			outputFormatter.PrintToken(Tokens.End);
 275//			outputFormatter.Space();
 276//			outputFormatter.PrintToken(Tokens.Namespace);
 277//			outputFormatter.NewLine();
 278//			return null;
 279//		}
 280//		
 281//		static int GetTypeToken(TypeDeclaration typeDeclaration)
 282//		{
 283//			switch (typeDeclaration.Type) {
 284//				case ClassType.Class:
 285//					return Tokens.Class;
 286//				case ClassType.Enum:
 287//					return Tokens.Enum;
 288//				case ClassType.Interface:
 289//					return Tokens.Interface;
 290//				case ClassType.Struct:
 291//					return Tokens.Structure;
 292//				case ClassType.Module:
 293//					return Tokens.Module;
 294//				default:
 295//					return Tokens.Class;
 296//			}
 297//		}
 298//		
 299//		void PrintTemplates(List<TemplateDefinition> templates)
 300//		{
 301//			if (templates != null && templates.Count > 0) {
 302//				outputFormatter.PrintToken(Tokens.OpenParenthesis);
 303//				outputFormatter.PrintToken(Tokens.Of);
 304//				outputFormatter.Space();
 305//				AppendCommaSeparatedList(templates);
 306//				outputFormatter.PrintToken(Tokens.CloseParenthesis);
 307//			}
 308//		}
 309//		
 310//		public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
 311//		{
 312//			VisitAttributes(typeDeclaration.Attributes, data);
 313//			
 314//			outputFormatter.Indent();
 315//			OutputModifier(typeDeclaration.Modifier, true, false);
 316//			
 317//			int typeToken = GetTypeToken(typeDeclaration);
 318//			outputFormatter.PrintToken(typeToken);
 319//			outputFormatter.Space();
 320//			outputFormatter.PrintIdentifier(typeDeclaration.Name);
 321//			
 322//			PrintTemplates(typeDeclaration.Templates);
 323//			
 324//			if (typeDeclaration.Type == ClassType.Enum
 325//			    && typeDeclaration.BaseTypes != null && typeDeclaration.BaseTypes.Count > 0)
 326//			{
 327//				outputFormatter.Space();
 328//				outputFormatter.PrintToken(Tokens.As);
 329//				outputFormatter.Space();
 330//				foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
 331//					TrackedVisit(baseTypeRef, data);
 332//				}
 333//			}
 334//			
 335//			outputFormatter.NewLine();
 336//			++outputFormatter.IndentationLevel;
 337//			
 338//			if (typeDeclaration.BaseTypes != null && typeDeclaration.Type != ClassType.Enum) {
 339//				foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
 340//					outputFormatter.Indent();
 341//					
 342//					string baseType = baseTypeRef.Type;
 343//					if (baseType.IndexOf('.') >= 0) {
 344//						baseType = baseType.Substring(baseType.LastIndexOf('.') + 1);
 345//					}
 346//					bool baseTypeIsInterface = baseType.Length >= 2 && baseType[0] == 'I' && Char.IsUpper(baseType[1]);
 347//					
 348//					if (!baseTypeIsInterface || typeDeclaration.Type == ClassType.Interface) {
 349//						outputFormatter.PrintToken(Tokens.Inherits);
 350//					} else {
 351//						outputFormatter.PrintToken(Tokens.Implements);
 352//					}
 353//					outputFormatter.Space();
 354//					TrackedVisit(baseTypeRef, data);
 355//					outputFormatter.NewLine();
 356//				}
 357//			}
 358//			
 359//			TypeDeclaration oldType = currentType;
 360//			currentType = typeDeclaration;
 361//			
 362//			if (typeDeclaration.Type == ClassType.Enum) {
 363//				OutputEnumMembers(typeDeclaration, data);
 364//			} else {
 365//				typeDeclaration.AcceptChildren(this, data);
 366//			}
 367//			currentType = oldType;
 368//			
 369//			--outputFormatter.IndentationLevel;
 370//			
 371//			
 372//			outputFormatter.Indent();
 373//			outputFormatter.PrintToken(Tokens.End);
 374//			outputFormatter.Space();
 375//			outputFormatter.PrintToken(typeToken);
 376//			outputFormatter.NewLine();
 377//			return null;
 378//		}
 379//		
 380//		void OutputEnumMembers(TypeDeclaration typeDeclaration, object data)
 381//		{
 382//			foreach (FieldDeclaration fieldDeclaration in typeDeclaration.Children) {
 383//				BeginVisit(fieldDeclaration);
 384//				VariableDeclaration f = (VariableDeclaration)fieldDeclaration.Fields[0];
 385//				VisitAttributes(fieldDeclaration.Attributes, data);
 386//				outputFormatter.Indent();
 387//				outputFormatter.PrintIdentifier(f.Name);
 388//				if (f.Initializer != null && !f.Initializer.IsNull) {
 389//					outputFormatter.Space();
 390//					outputFormatter.PrintToken(Tokens.Assign);
 391//					outputFormatter.Space();
 392//					TrackedVisit(f.Initializer, data);
 393//				}
 394//				outputFormatter.NewLine();
 395//				EndVisit(fieldDeclaration);
 396//			}
 397//		}
 398//		
 399//		public override object TrackedVisitTemplateDefinition(TemplateDefinition templateDefinition, object data)
 400//		{
 401//			VisitAttributes(templateDefinition.Attributes, data);
 402//			switch (templateDefinition.VarianceModifier) {
 403//				case VarianceModifier.Invariant:
 404//					// nothing
 405//					break;
 406//				case VarianceModifier.Covariant:
 407//					outputFormatter.Space();
 408//					outputFormatter.PrintToken(Tokens.Out);
 409//					outputFormatter.Space();
 410//					break;
 411//				case VarianceModifier.Contravariant:
 412//					outputFormatter.Space();
 413//					outputFormatter.PrintToken(Tokens.In);
 414//					outputFormatter.Space();
 415//					break;
 416//				default:
 417//					throw new Exception("Invalid value for VarianceModifier");
 418//			}
 419//			outputFormatter.PrintIdentifier(templateDefinition.Name);
 420//			if (templateDefinition.Bases.Count > 0) {
 421//				outputFormatter.PrintText(" As ");
 422//				VisitReturnTypeAttributes(templateDefinition.Attributes, data);
 423//				if (templateDefinition.Bases.Count == 1) {
 424//					TrackedVisit(templateDefinition.Bases[0], data);
 425//				} else {
 426//					outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
 427//					AppendCommaSeparatedList(templateDefinition.Bases);
 428//					outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
 429//				}
 430//			}
 431//			return null;
 432//		}
 433//		
 434//		public override object TrackedVisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data)
 435//		{
 436//			VisitAttributes(delegateDeclaration.Attributes, data);
 437//			
 438//			outputFormatter.Indent();
 439//			OutputModifier(delegateDeclaration.Modifier, true, false);
 440//			outputFormatter.PrintToken(Tokens.Delegate);
 441//			outputFormatter.Space();
 442//			
 443//			bool isFunction = (delegateDeclaration.ReturnType.Type != "System.Void");
 444//			if (isFunction) {
 445//				outputFormatter.PrintToken(Tokens.Function);
 446//				outputFormatter.Space();
 447//			} else {
 448//				outputFormatter.PrintToken(Tokens.Sub);
 449//				outputFormatter.Space();
 450//			}
 451//			outputFormatter.PrintIdentifier(delegateDeclaration.Name);
 452//			
 453//			PrintTemplates(delegateDeclaration.Templates);
 454//			
 455//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
 456//			AppendCommaSeparatedList(delegateDeclaration.Parameters);
 457//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
 458//			
 459//			if (isFunction) {
 460//				outputFormatter.Space();
 461//				outputFormatter.PrintToken(Tokens.As);
 462//				outputFormatter.Space();
 463//				VisitReturnTypeAttributes(delegateDeclaration.Attributes, data);
 464//				TrackedVisit(delegateDeclaration.ReturnType, data);
 465//			}
 466//			outputFormatter.NewLine();
 467//			return null;
 468//		}
 469//		
 470//		public override object TrackedVisitOptionDeclaration(OptionDeclaration optionDeclaration, object data)
 471//		{
 472//			outputFormatter.PrintToken(Tokens.Option);
 473//			outputFormatter.Space();
 474//			switch (optionDeclaration.OptionType) {
 475//				case OptionType.Strict:
 476//					outputFormatter.PrintToken(Tokens.Strict);
 477//					outputFormatter.Space();
 478//					outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
 479//					break;
 480//				case OptionType.Explicit:
 481//					outputFormatter.PrintToken(Tokens.Explicit);
 482//					outputFormatter.Space();
 483//					outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
 484//					break;
 485//				case OptionType.Infer:
 486//					outputFormatter.PrintToken(Tokens.Infer);
 487//					outputFormatter.Space();
 488//					outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off);
 489//					break;
 490//				case OptionType.CompareBinary:
 491//					outputFormatter.PrintToken(Tokens.Compare);
 492//					outputFormatter.Space();
 493//					outputFormatter.PrintToken(Tokens.Binary);
 494//					break;
 495//				case OptionType.CompareText:
 496//					outputFormatter.PrintToken(Tokens.Compare);
 497//					outputFormatter.Space();
 498//					outputFormatter.PrintToken(Tokens.Text);
 499//					break;
 500//			}
 501//			outputFormatter.NewLine();
 502//			return null;
 503//		}
 504//		#endregion
 505//		
 506//		#region Type level
 507//		TypeReference currentVariableType;
 508//		public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data)
 509//		{
 510//			
 511//			VisitAttributes(fieldDeclaration.Attributes, data);
 512//			outputFormatter.Indent();
 513//			if (fieldDeclaration.Modifier == Modifiers.None) {
 514//				outputFormatter.PrintToken(Tokens.Private);
 515//				outputFormatter.Space();
 516//			} else {
 517//				OutputModifier(fieldDeclaration.Modifier, false, true);
 518//			}
 519//			currentVariableType = fieldDeclaration.TypeReference;
 520//			AppendCommaSeparatedList(fieldDeclaration.Fields);
 521//			currentVariableType = null;
 522//			
 523//			outputFormatter.NewLine();
 524//
 525//			return null;
 526//		}
 527//		
 528//		public override object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
 529//		{
 530//			outputFormatter.PrintIdentifier(variableDeclaration.Name);
 531//			
 532//			TypeReference varType = currentVariableType;
 533//			if (varType != null && varType.IsNull)
 534//				varType = null;
 535//			if (varType == null && !variableDeclaration.TypeReference.IsNull)
 536//				varType = variableDeclaration.TypeReference;
 537//			
 538//			if (varType != null) {
 539//				outputFormatter.Space();
 540//				outputFormatter.PrintToken(Tokens.As);
 541//				outputFormatter.Space();
 542//				ObjectCreateExpression init = variableDeclaration.Initializer as ObjectCreateExpression;
 543//				if (init != null && TypeReference.AreEqualReferences(init.CreateType, varType)) {
 544//					TrackedVisit(variableDeclaration.Initializer, data);
 545//					return null;
 546//				} else {
 547//					TrackedVisit(varType, data);
 548//				}
 549//			}
 550//			
 551//			if (!variableDeclaration.Initializer.IsNull) {
 552//				outputFormatter.Space();
 553//				outputFormatter.PrintToken(Tokens.Assign);
 554//				outputFormatter.Space();
 555//				TrackedVisit(variableDeclaration.Initializer, data);
 556//			}
 557//			return null;
 558//		}
 559//		
 560//		public override object TrackedVisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
 561//		{
 562//			VisitAttributes(propertyDeclaration.Attributes, data);
 563//			outputFormatter.Indent();
 564//			OutputModifier(propertyDeclaration.Modifier);
 565//			
 566//			if ((propertyDeclaration.Modifier & (Modifiers.ReadOnly | Modifiers.WriteOnly)) == Modifiers.None) {
 567//				if (propertyDeclaration.IsReadOnly) {
 568//					outputFormatter.PrintToken(Tokens.ReadOnly);
 569//					outputFormatter.Space();
 570//				} else if (propertyDeclaration.IsWriteOnly) {
 571//					outputFormatter.PrintToken(Tokens.WriteOnly);
 572//					outputFormatter.Space();
 573//				}
 574//			}
 575//			
 576//			outputFormatter.PrintToken(Tokens.Property);
 577//			outputFormatter.Space();
 578//			outputFormatter.PrintIdentifier(propertyDeclaration.Name);
 579//			
 580//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
 581//			AppendCommaSeparatedList(propertyDeclaration.Parameters);
 582//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
 583//			
 584//			if (!propertyDeclaration.TypeReference.IsNull) {
 585//				outputFormatter.Space();
 586//				outputFormatter.PrintToken(Tokens.As);
 587//				outputFormatter.Space();
 588//				
 589//				VisitReturnTypeAttributes(propertyDeclaration.Attributes, data);
 590//				
 591//				ObjectCreateExpression init = propertyDeclaration.Initializer as ObjectCreateExpression;
 592//				if (init != null && TypeReference.AreEqualReferences(init.CreateType, propertyDeclaration.TypeReference)) {
 593//					TrackedVisit(propertyDeclaration.Initializer, data);
 594//				} else {
 595//					TrackedVisit(propertyDeclaration.TypeReference, data);
 596//				}
 597//			}
 598//			
 599//			PrintInterfaceImplementations(propertyDeclaration.InterfaceImplementations);
 600//			
 601//			if (!propertyDeclaration.Initializer.IsNull && !(propertyDeclaration.Initializer is ObjectCreateExpression)) {
 602//				outputFormatter.Space();
 603//				outputFormatter.PrintToken(Tokens.Assign);
 604//				outputFormatter.Space();
 605//				TrackedVisit(propertyDeclaration.Initializer, data);
 606//			}
 607//			
 608//			outputFormatter.NewLine();
 609//			
 610//			if (!IsAbstract(propertyDeclaration) && (propertyDeclaration.GetRegion.Block != NullBlockStatement.Instance  || propertyDeclaration.SetRegion.Block != NullBlockStatement.Instance)) {
 611//				outputFormatter.IsInMemberBody = true;
 612//				++outputFormatter.IndentationLevel;
 613//				exitTokenStack.Push(Tokens.Property);
 614//				TrackedVisit(propertyDeclaration.GetRegion, data);
 615//				TrackedVisit(propertyDeclaration.SetRegion, data);
 616//				exitTokenStack.Pop();
 617//				--outputFormatter.IndentationLevel;
 618//				outputFormatter.IsInMemberBody = false;
 619//				
 620//				outputFormatter.Indent();
 621//				outputFormatter.PrintToken(Tokens.End);
 622//				outputFormatter.Space();
 623//				outputFormatter.PrintToken(Tokens.Property);
 624//				outputFormatter.NewLine();
 625//			}
 626//			
 627//			return null;
 628//		}
 629//		
 630//		public override object TrackedVisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data)
 631//		{
 632//			VisitAttributes(propertyGetRegion.Attributes, data);
 633//			outputFormatter.Indent();
 634//			OutputModifier(propertyGetRegion.Modifier);
 635//			outputFormatter.PrintToken(Tokens.Get);
 636//			outputFormatter.NewLine();
 637//			
 638//			++outputFormatter.IndentationLevel;
 639//			TrackedVisit(propertyGetRegion.Block, data);
 640//			--outputFormatter.IndentationLevel;
 641//			outputFormatter.Indent();
 642//			outputFormatter.PrintToken(Tokens.End);
 643//			outputFormatter.Space();
 644//			outputFormatter.PrintToken(Tokens.Get);
 645//			outputFormatter.NewLine();
 646//			return null;
 647//		}
 648//		
 649//		public override object TrackedVisitPropertySetRegion(PropertySetRegion propertySetRegion, object data)
 650//		{
 651//			VisitAttributes(propertySetRegion.Attributes, data);
 652//			outputFormatter.Indent();
 653//			OutputModifier(propertySetRegion.Modifier);
 654//			outputFormatter.PrintToken(Tokens.Set);
 655//			outputFormatter.NewLine();
 656//			
 657//			++outputFormatter.IndentationLevel;
 658//			TrackedVisit(propertySetRegion.Block, data);
 659//			--outputFormatter.IndentationLevel;
 660//			outputFormatter.Indent();
 661//			outputFormatter.PrintToken(Tokens.End);
 662//			outputFormatter.Space();
 663//			outputFormatter.PrintToken(Tokens.Set);
 664//			outputFormatter.NewLine();
 665//			return null;
 666//		}
 667//		
 668//		TypeReference currentEventType = null;
 669//		public override object TrackedVisitEventDeclaration(EventDeclaration eventDeclaration, object data)
 670//		{
 671//			bool customEvent = eventDeclaration.HasAddRegion  || eventDeclaration.HasRemoveRegion;
 672//			
 673//			VisitAttributes(eventDeclaration.Attributes, data);
 674//			outputFormatter.Indent();
 675//			OutputModifier(eventDeclaration.Modifier);
 676//			if (customEvent) {
 677//				outputFormatter.PrintText("Custom");
 678//				outputFormatter.Space();
 679//			}
 680//			
 681//			outputFormatter.PrintToken(Tokens.Event);
 682//			outputFormatter.Space();
 683//			outputFormatter.PrintIdentifier(eventDeclaration.Name);
 684//			
 685//			if (eventDeclaration.Parameters.Count > 0) {
 686//				outputFormatter.PrintToken(Tokens.OpenParenthesis);
 687//				this.AppendCommaSeparatedList(eventDeclaration.Parameters);
 688//				outputFormatter.PrintToken(Tokens.CloseParenthesis);
 689//			}
 690//			if (!eventDeclaration.TypeReference.IsNull) {
 691//				outputFormatter.Space();
 692//				outputFormatter.PrintToken(Tokens.As);
 693//				outputFormatter.Space();
 694//				VisitReturnTypeAttributes(eventDeclaration.Attributes, data);
 695//				TrackedVisit(eventDeclaration.TypeReference, data);
 696//			}
 697//			
 698//			PrintInterfaceImplementations(eventDeclaration.InterfaceImplementations);
 699//			
 700//			if (!eventDeclaration.Initializer.IsNull) {
 701//				outputFormatter.Space();
 702//				outputFormatter.PrintToken(Tokens.Assign);
 703//				outputFormatter.Space();
 704//				TrackedVisit(eventDeclaration.Initializer, data);
 705//			}
 706//			
 707//			outputFormatter.NewLine();
 708//			
 709//			if (customEvent) {
 710//				++outputFormatter.IndentationLevel;
 711//				currentEventType = eventDeclaration.TypeReference;
 712//				exitTokenStack.Push(Tokens.Sub);
 713//				TrackedVisit(eventDeclaration.AddRegion, data);
 714//				TrackedVisit(eventDeclaration.RemoveRegion, data);
 715//				exitTokenStack.Pop();
 716//				--outputFormatter.IndentationLevel;
 717//				
 718//				outputFormatter.Indent();
 719//				outputFormatter.PrintToken(Tokens.End);
 720//				outputFormatter.Space();
 721//				outputFormatter.PrintToken(Tokens.Event);
 722//				outputFormatter.NewLine();
 723//			}
 724//			return null;
 725//		}
 726//		
 727//		void PrintInterfaceImplementations(IList<InterfaceImplementation> list)
 728//		{
 729//			if (list == null || list.Count == 0)
 730//				return;
 731//			outputFormatter.Space();
 732//			outputFormatter.PrintToken(Tokens.Implements);
 733//			for (int i = 0; i < list.Count; i++) {
 734//				if (i > 0)
 735//					outputFormatter.PrintToken(Tokens.Comma);
 736//				outputFormatter.Space();
 737//				TrackedVisit(list[i].InterfaceType, null);
 738//				outputFormatter.PrintToken(Tokens.Dot);
 739//				outputFormatter.PrintIdentifier(list[i].MemberName);
 740//			}
 741//		}
 742//		
 743//		public override object TrackedVisitEventAddRegion(EventAddRegion eventAddRegion, object data)
 744//		{
 745//			VisitAttributes(eventAddRegion.Attributes, data);
 746//			outputFormatter.Indent();
 747//			outputFormatter.PrintText("AddHandler(");
 748//			if (eventAddRegion.Parameters.Count == 0) {
 749//				outputFormatter.PrintToken(Tokens.ByVal);
 750//				outputFormatter.Space();
 751//				outputFormatter.PrintIdentifier("value");
 752//				outputFormatter.Space();
 753//				outputFormatter.PrintToken(Tokens.As);
 754//				outputFormatter.Space();
 755//				TrackedVisit(currentEventType, data);
 756//			} else {
 757//				this.AppendCommaSeparatedList(eventAddRegion.Parameters);
 758//			}
 759//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
 760//			outputFormatter.NewLine();
 761//			
 762//			++outputFormatter.IndentationLevel;
 763//			TrackedVisit(eventAddRegion.Block, data);
 764//			--outputFormatter.IndentationLevel;
 765//			
 766//			outputFormatter.Indent();
 767//			outputFormatter.PrintToken(Tokens.End);
 768//			outputFormatter.Space();
 769//			outputFormatter.PrintText("AddHandler");
 770//			outputFormatter.NewLine();
 771//			return null;
 772//		}
 773//		
 774//		public override object TrackedVisitEventRemoveRegion(EventRemoveRegion eventRemoveRegion, object data)
 775//		{
 776//			VisitAttributes(eventRemoveRegion.Attributes, data);
 777//			outputFormatter.Indent();
 778//			outputFormatter.PrintText("RemoveHandler");
 779//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
 780//			if (eventRemoveRegion.Parameters.Count == 0) {
 781//				outputFormatter.PrintToken(Tokens.ByVal);
 782//				outputFormatter.Space();
 783//				outputFormatter.PrintIdentifier("value");
 784//				outputFormatter.Space();
 785//				outputFormatter.PrintToken(Tokens.As);
 786//				outputFormatter.Space();
 787//				TrackedVisit(currentEventType, data);
 788//			} else {
 789//				this.AppendCommaSeparatedList(eventRemoveRegion.Parameters);
 790//			}
 791//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
 792//			outputFormatter.NewLine();
 793//			
 794//			++outputFormatter.IndentationLevel;
 795//			TrackedVisit(eventRemoveRegion.Block, data);
 796//			--outputFormatter.IndentationLevel;
 797//			
 798//			outputFormatter.Indent();
 799//			outputFormatter.PrintToken(Tokens.End);
 800//			outputFormatter.Space();
 801//			outputFormatter.PrintText("RemoveHandler");
 802//			outputFormatter.NewLine();
 803//			return null;
 804//		}
 805//		
 806//		public override object TrackedVisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data)
 807//		{
 808//			VisitAttributes(eventRaiseRegion.Attributes, data);
 809//			outputFormatter.Indent();
 810//			outputFormatter.PrintText("RaiseEvent");
 811//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
 812//			if (eventRaiseRegion.Parameters.Count == 0) {
 813//				outputFormatter.PrintToken(Tokens.ByVal);
 814//				outputFormatter.Space();
 815//				outputFormatter.PrintIdentifier("value");
 816//				outputFormatter.Space();
 817//				outputFormatter.PrintToken(Tokens.As);
 818//				outputFormatter.Space();
 819//				TrackedVisit(currentEventType, data);
 820//			} else {
 821//				this.AppendCommaSeparatedList(eventRaiseRegion.Parameters);
 822//			}
 823//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
 824//			outputFormatter.NewLine();
 825//			
 826//			++outputFormatter.IndentationLevel;
 827//			TrackedVisit(eventRaiseRegion.Block, data);
 828//			--outputFormatter.IndentationLevel;
 829//			
 830//			outputFormatter.Indent();
 831//			outputFormatter.PrintToken(Tokens.End);
 832//			outputFormatter.Space();
 833//			outputFormatter.PrintText("RaiseEvent");
 834//			outputFormatter.NewLine();
 835//			return null;
 836//		}
 837//		
 838//		public override object TrackedVisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data)
 839//		{
 840//			printAttributeSectionInline = true;
 841//			VisitAttributes(parameterDeclarationExpression.Attributes, data);
 842//			printAttributeSectionInline = false;
 843//			OutputModifier(parameterDeclarationExpression.ParamModifier);
 844//			outputFormatter.PrintIdentifier(parameterDeclarationExpression.ParameterName);
 845//			if (!parameterDeclarationExpression.TypeReference.IsNull) {
 846//				outputFormatter.Space();
 847//				outputFormatter.PrintToken(Tokens.As);
 848//				outputFormatter.Space();
 849//				VisitReturnTypeAttributes(parameterDeclarationExpression.Attributes, data);
 850//				TrackedVisit(parameterDeclarationExpression.TypeReference, data);
 851//			}
 852//			if (!parameterDeclarationExpression.DefaultValue.IsNull) {
 853//				outputFormatter.Space();
 854//				outputFormatter.PrintToken(Tokens.Assign);
 855//				outputFormatter.Space();
 856//				TrackedVisit(parameterDeclarationExpression.DefaultValue, data);
 857//			}
 858//			return null;
 859//		}
 860//		
 861//		public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
 862//		{
 863//			VisitAttributes(methodDeclaration.Attributes, data);
 864//			if (methodDeclaration.IsExtensionMethod) {
 865//				outputFormatter.Indent();
 866//				outputFormatter.PrintText("<System.Runtime.CompilerServices.Extension> _");
 867//				outputFormatter.NewLine();
 868//			}
 869//			outputFormatter.Indent();
 870//			OutputModifier(methodDeclaration.Modifier);
 871//			
 872//			bool isSub = methodDeclaration.TypeReference.IsNull ||
 873//				methodDeclaration.TypeReference.Type == "System.Void";
 874//			
 875//			if (isSub) {
 876//				outputFormatter.PrintToken(Tokens.Sub);
 877//			} else {
 878//				outputFormatter.PrintToken(Tokens.Function);
 879//			}
 880//			outputFormatter.Space();
 881//			outputFormatter.PrintIdentifier(methodDeclaration.Name);
 882//			
 883//			PrintTemplates(methodDeclaration.Templates);
 884//			
 885//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
 886//			AppendCommaSeparatedList(methodDeclaration.Parameters);
 887//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
 888//			
 889//			if (!isSub) {
 890//				outputFormatter.Space();
 891//				outputFormatter.PrintToken(Tokens.As);
 892//				outputFormatter.Space();
 893//				VisitReturnTypeAttributes(methodDeclaration.Attributes, data);
 894//				TrackedVisit(methodDeclaration.TypeReference, data);
 895//			}
 896//			
 897//			PrintInterfaceImplementations(methodDeclaration.InterfaceImplementations);
 898//			
 899//			if (methodDeclaration.HandlesClause.Count > 0) {
 900//				outputFormatter.Space();
 901//				outputFormatter.PrintToken(Tokens.Handles);
 902//				for (int i = 0; i < methodDeclaration.HandlesClause.Count; i++) {
 903//					if (i > 0)
 904//						outputFormatter.PrintToken(Tokens.Comma);
 905//					outputFormatter.Space();
 906//					outputFormatter.PrintText(methodDeclaration.HandlesClause[i]);
 907//				}
 908//			}
 909//			
 910//			outputFormatter.NewLine();
 911//			
 912//			if (!IsAbstract(methodDeclaration)) {
 913//				outputFormatter.IsInMemberBody = true;
 914//				BeginVisit(methodDeclaration.Body);
 915//				++outputFormatter.IndentationLevel;
 916//				exitTokenStack.Push(isSub ? Tokens.Sub : Tokens.Function);
 917//				// we're doing the tracking manually using BeginVisit/EndVisit, so call Tracked... directly
 918//				this.TrackedVisitBlockStatement(methodDeclaration.Body, data);
 919//				exitTokenStack.Pop();
 920//				--outputFormatter.IndentationLevel;
 921//				
 922//				outputFormatter.Indent();
 923//				outputFormatter.PrintToken(Tokens.End);
 924//				outputFormatter.Space();
 925//				if (isSub) {
 926//					outputFormatter.PrintToken(Tokens.Sub);
 927//				} else {
 928//					outputFormatter.PrintToken(Tokens.Function);
 929//				}
 930//				outputFormatter.NewLine();
 931//				EndVisit(methodDeclaration.Body);
 932//				outputFormatter.IsInMemberBody = false;
 933//			}
 934//			return null;
 935//		}
 936//		
 937//		public override object TrackedVisitInterfaceImplementation(InterfaceImplementation interfaceImplementation, object data)
 938//		{
 939//			throw new InvalidOperationException();
 940//		}
 941//		
 942//		bool IsAbstract(AttributedNode node)
 943//		{
 944//			if ((node.Modifier & Modifiers.Abstract) == Modifiers.Abstract)
 945//				return true;
 946//			return currentType != null && currentType.Type == ClassType.Interface;
 947//		}
 948//		
 949//		public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
 950//		{
 951//			VisitAttributes(constructorDeclaration.Attributes, data);
 952//			outputFormatter.Indent();
 953//			OutputModifier(constructorDeclaration.Modifier);
 954//			outputFormatter.PrintToken(Tokens.Sub);
 955//			outputFormatter.Space();
 956//			outputFormatter.PrintToken(Tokens.New);
 957//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
 958//			AppendCommaSeparatedList(constructorDeclaration.Parameters);
 959//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
 960//			outputFormatter.NewLine();
 961//			
 962//			outputFormatter.IsInMemberBody = true;
 963//			++outputFormatter.IndentationLevel;
 964//			exitTokenStack.Push(Tokens.Sub);
 965//			
 966//			TrackedVisit(constructorDeclaration.ConstructorInitializer, data);
 967//			
 968//			TrackedVisit(constructorDeclaration.Body, data);
 969//			exitTokenStack.Pop();
 970//			--outputFormatter.IndentationLevel;
 971//			outputFormatter.IsInMemberBody = false;
 972//			
 973//			outputFormatter.Indent();
 974//			outputFormatter.PrintToken(Tokens.End);
 975//			outputFormatter.Space();
 976//			outputFormatter.PrintToken(Tokens.Sub);
 977//			outputFormatter.NewLine();
 978//			
 979//			return null;
 980//		}
 981//		
 982//		public override object TrackedVisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data)
 983//		{
 984//			outputFormatter.Indent();
 985//			if (constructorInitializer.ConstructorInitializerType == ConstructorInitializerType.This) {
 986//				outputFormatter.PrintToken(Tokens.Me);
 987//			} else {
 988//				outputFormatter.PrintToken(Tokens.MyBase);
 989//			}
 990//			outputFormatter.PrintToken(Tokens.Dot);
 991//			outputFormatter.PrintToken(Tokens.New);
 992//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
 993//			AppendCommaSeparatedList(constructorInitializer.Arguments);
 994//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
 995//			
 996//			outputFormatter.NewLine();
 997//			return null;
 998//		}
 999//		
1000//		public override object TrackedVisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data)
1001//		{
1002//			VisitAttributes(operatorDeclaration.Attributes, data);
1003//			outputFormatter.Indent();
1004//			OutputModifier(operatorDeclaration.Modifier);
1005//			
1006//			if (operatorDeclaration.IsConversionOperator) {
1007//				if (operatorDeclaration.ConversionType == ConversionType.Implicit) {
1008//					outputFormatter.PrintToken(Tokens.Widening);
1009//				} else {
1010//					outputFormatter.PrintToken(Tokens.Narrowing);
1011//				}
1012//				outputFormatter.Space();
1013//			}
1014//			
1015//			outputFormatter.PrintToken(Tokens.Operator);
1016//			outputFormatter.Space();
1017//			
1018//			int op = -1;
1019//			
1020//			switch(operatorDeclaration.OverloadableOperator)
1021//			{
1022//				case OverloadableOperatorType.Add:
1023//				case OverloadableOperatorType.UnaryPlus:
1024//					op = Tokens.Plus;
1025//					break;
1026//				case OverloadableOperatorType.UnaryMinus:
1027//				case OverloadableOperatorType.Subtract:
1028//					op = Tokens.Minus;
1029//					break;
1030//				case OverloadableOperatorType.Multiply:
1031//					op = Tokens.Times;
1032//					break;
1033//				case OverloadableOperatorType.Divide:
1034//					op = Tokens.Div;
1035//					break;
1036//				case OverloadableOperatorType.Modulus:
1037//					op = Tokens.Mod;
1038//					break;
1039//				case OverloadableOperatorType.Concat:
1040//					op = Tokens.ConcatString;
1041//					break;
1042//				case OverloadableOperatorType.Not:
1043//					op = Tokens.Not;
1044//					break;
1045//				case OverloadableOperatorType.BitNot:
1046//					op = Tokens.Not;
1047//					break;
1048//				case OverloadableOperatorType.BitwiseAnd:
1049//					op = Tokens.And;
1050//					break;
1051//				case OverloadableOperatorType.BitwiseOr:
1052//					op = Tokens.Or;
1053//					break;
1054//				case OverloadableOperatorType.ExclusiveOr:
1055//					op = Tokens.Xor;
1056//					break;
1057//				case OverloadableOperatorType.ShiftLeft:
1058//					op = Tokens.ShiftLeft;
1059//					break;
1060//				case OverloadableOperatorType.ShiftRight:
1061//					op = Tokens.ShiftRight;
1062//					break;
1063//				case OverloadableOperatorType.GreaterThan:
1064//					op = Tokens.GreaterThan;
1065//					break;
1066//				case OverloadableOperatorType.GreaterThanOrEqual:
1067//					op = Tokens.GreaterEqual;
1068//					break;
1069//				case OverloadableOperatorType.Equality:
1070//					op = Tokens.Assign;
1071//					break;
1072//				case OverloadableOperatorType.InEquality:
1073//					op = Tokens.NotEqual;
1074//					break;
1075//				case OverloadableOperatorType.LessThan:
1076//					op = Tokens.LessThan;
1077//					break;
1078//				case OverloadableOperatorType.LessThanOrEqual:
1079//					op = Tokens.LessEqual;
1080//					break;
1081//				case OverloadableOperatorType.Increment:
1082//					Error("Increment operator is not supported in Visual Basic", operatorDeclaration.StartLocation);
1083//					break;
1084//				case OverloadableOperatorType.Decrement:
1085//					Error("Decrement operator is not supported in Visual Basic", operatorDeclaration.StartLocation);
1086//					break;
1087//				case OverloadableOperatorType.IsTrue:
1088//					outputFormatter.PrintText("IsTrue");
1089//					break;
1090//				case OverloadableOperatorType.IsFalse:
1091//					outputFormatter.PrintText("IsFalse");
1092//					break;
1093//				case OverloadableOperatorType.Like:
1094//					op = Tokens.Like;
1095//					break;
1096//				case OverloadableOperatorType.Power:
1097//					op = Tokens.Power;
1098//					break;
1099//				case OverloadableOperatorType.CType:
1100//					op = Tokens.CType;
1101//					break;
1102//				case OverloadableOperatorType.DivideInteger:
1103//					op = Tokens.DivInteger;
1104//					break;
1105//			}
1106//			
1107//			
1108//			
1109//			if (operatorDeclaration.IsConversionOperator) {
1110//				outputFormatter.PrintToken(Tokens.CType);
1111//			} else {
1112//				if(op != -1)  outputFormatter.PrintToken(op);
1113//			}
1114//			
1115//			PrintTemplates(operatorDeclaration.Templates);
1116//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
1117//			AppendCommaSeparatedList(operatorDeclaration.Parameters);
1118//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
1119//			if (!operatorDeclaration.TypeReference.IsNull) {
1120//				outputFormatter.Space();
1121//				outputFormatter.PrintToken(Tokens.As);
1122//				outputFormatter.Space();
1123//				VisitReturnTypeAttributes(operatorDeclaration.Attributes, data);
1124//				TrackedVisit(operatorDeclaration.TypeReference, data);
1125//			}
1126//			
1127//			outputFormatter.NewLine();
1128//			
1129//			++outputFormatter.IndentationLevel;
1130//			TrackedVisit(operatorDeclaration.Body, data);
1131//			--outputFormatter.IndentationLevel;
1132//			
1133//			outputFormatter.Indent();
1134//			outputFormatter.PrintToken(Tokens.End);
1135//			outputFormatter.Space();
1136//			outputFormatter.PrintToken(Tokens.Operator);
1137//			outputFormatter.NewLine();
1138//			
1139//			return null;
1140//		}
1141//		
1142//		public override object TrackedVisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
1143//		{
1144//			VisitAttributes(declareDeclaration.Attributes, data);
1145//			outputFormatter.Indent();
1146//			OutputModifier(declareDeclaration.Modifier);
1147//			outputFormatter.PrintToken(Tokens.Declare);
1148//			outputFormatter.Space();
1149//			
1150//			switch (declareDeclaration.Charset) {
1151//				case CharsetModifier.Auto:
1152//					outputFormatter.PrintToken(Tokens.Auto);
1153//					outputFormatter.Space();
1154//					break;
1155//				case CharsetModifier.Unicode:
1156//					outputFormatter.PrintToken(Tokens.Unicode);
1157//					outputFormatter.Space();
1158//					break;
1159//				case CharsetModifier.Ansi:
1160//					outputFormatter.PrintToken(Tokens.Ansi);
1161//					outputFormatter.Space();
1162//					break;
1163//			}
1164//			
1165//			bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.Type == "System.Void";
1166//			if (isVoid) {
1167//				outputFormatter.PrintToken(Tokens.Sub);
1168//			} else {
1169//				outputFormatter.PrintToken(Tokens.Function);
1170//			}
1171//			outputFormatter.Space();
1172//			
1173//			outputFormatter.PrintIdentifier(declareDeclaration.Name);
1174//			
1175//			outputFormatter.Space();
1176//			outputFormatter.PrintToken(Tokens.Lib);
1177//			outputFormatter.Space();
1178//			outputFormatter.PrintText(ConvertString(declareDeclaration.Library));
1179//			outputFormatter.Space();
1180//			
1181//			if (declareDeclaration.Alias.Length > 0) {
1182//				outputFormatter.PrintToken(Tokens.Alias);
1183//				outputFormatter.Space();
1184//				outputFormatter.PrintText(ConvertString(declareDeclaration.Alias));
1185//				outputFormatter.Space();
1186//			}
1187//			
1188//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
1189//			AppendCommaSeparatedList(declareDeclaration.Parameters);
1190//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
1191//			
1192//			if (!isVoid) {
1193//				outputFormatter.Space();
1194//				outputFormatter.PrintToken(Tokens.As);
1195//				outputFormatter.Space();
1196//				VisitReturnTypeAttributes(declareDeclaration.Attributes, data);
1197//				TrackedVisit(declareDeclaration.TypeReference, data);
1198//			}
1199//			
1200//			outputFormatter.NewLine();
1201//			
1202//			return null;
1203//		}
1204//		#endregion
1205//		
1206//		#region Statements
1207//		public override object TrackedVisitBlockStatement(BlockStatement blockStatement, object data)
1208//		{
1209//			if (blockStatement.Parent is BlockStatement) {
1210//				outputFormatter.Indent();
1211//				outputFormatter.PrintText("If True Then");
1212//				outputFormatter.NewLine();
1213//				outputFormatter.IndentationLevel += 1;
1214//			}
1215//			VisitStatementList(blockStatement.Children);
1216//			if (blockStatement.Parent is BlockStatement) {
1217//				outputFormatter.IndentationLevel -= 1;
1218//				outputFormatter.Indent();
1219//				outputFormatter.PrintText("End If");
1220//				outputFormatter.NewLine();
1221//			}
1222//			return null;
1223//		}
1224//		
1225//		void PrintIndentedBlock(Statement stmt)
1226//		{
1227//			outputFormatter.IndentationLevel += 1;
1228//			if (stmt is BlockStatement) {
1229//				TrackedVisit(stmt, null);
1230//			} else {
1231//				outputFormatter.Indent();
1232//				TrackedVisit(stmt, null);
1233//				outputFormatter.NewLine();
1234//			}
1235//			outputFormatter.IndentationLevel -= 1;
1236//		}
1237//		
1238//		void PrintIndentedBlock(IEnumerable statements)
1239//		{
1240//			outputFormatter.IndentationLevel += 1;
1241//			VisitStatementList(statements);
1242//			outputFormatter.IndentationLevel -= 1;
1243//		}
1244//		
1245//		void VisitStatementList(IEnumerable statements)
1246//		{
1247//			foreach (Statement stmt in statements) {
1248//				if (stmt is BlockStatement) {
1249//					TrackedVisit(stmt, null);
1250//				} else {
1251//					outputFormatter.Indent();
1252//					TrackedVisit(stmt, null);
1253//					outputFormatter.NewLine();
1254//				}
1255//			}
1256//		}
1257//		
1258//		public override object TrackedVisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data)
1259//		{
1260//			outputFormatter.PrintToken(Tokens.AddHandler);
1261//			outputFormatter.Space();
1262//			TrackedVisit(addHandlerStatement.EventExpression, data);
1263//			outputFormatter.PrintToken(Tokens.Comma);
1264//			outputFormatter.Space();
1265//			TrackedVisit(addHandlerStatement.HandlerExpression, data);
1266//			return null;
1267//		}
1268//		
1269//		public override object TrackedVisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data)
1270//		{
1271//			outputFormatter.PrintToken(Tokens.RemoveHandler);
1272//			outputFormatter.Space();
1273//			TrackedVisit(removeHandlerStatement.EventExpression, data);
1274//			outputFormatter.PrintToken(Tokens.Comma);
1275//			outputFormatter.Space();
1276//			TrackedVisit(removeHandlerStatement.HandlerExpression, data);
1277//			return null;
1278//		}
1279//		
1280//		public override object TrackedVisitRaiseEventStatement(RaiseEventStatement raiseEventStatement, object data)
1281//		{
1282//			outputFormatter.PrintToken(Tokens.RaiseEvent);
1283//			outputFormatter.Space();
1284//			outputFormatter.PrintIdentifier(raiseEventStatement.EventName);
1285//			outputFormatter.PrintToken(Tokens.OpenParenthesis);
1286//			AppendCommaSeparatedList(raiseEventStatement.Arguments);
1287//			outputFormatter.PrintToken(Tokens.CloseParenthesis);
1288//			return null;
1289//		}
1290//		
1291//		public override object TrackedVisitEraseStatement(EraseStatement eraseStatement, object data)
1292//		{
1293//			outputFormatter.PrintToken(Tokens.Erase);
1294//			outputFormatter.Space();
1295//			AppendCommaSeparatedList(eraseStatement.Expressions);
1296//			return null;
1297//		}
1298//		
1299//		public override object TrackedVisitErrorStatement(ErrorStatement errorStatement, object data)
1300//		{
1301//			outputFormatter.PrintToken(Tokens.Error);
1302//			outputFormatter.Space();
1303//			TrackedVisit(errorStatement.Expression, data);
1304//			return null;
1305//		}
1306//		
1307//		public override object TrackedVisitOnErrorStatement(OnErrorStatement onErrorStatement, object data)
1308//		{
1309//			outputFormatter.PrintToken(Tokens.On);
1310//			outputFormatter.Space();
1311//			outputFormatter.PrintToken(Tokens.Error);
1312//			outputFormatter.Space();
1313//			TrackedVisit(onErrorStatement.EmbeddedStatement, data);
1314//			return null;
1315//		}
1316//		
1317//		public override object TrackedVisitReDimStatement(ReDimStatement reDimStatement, object data)
1318//		{
1319//			outputFormatter.PrintToken(Tokens.ReDim);
1320//			outputFormatter.Space();
1321//			if (reDimStatement.IsPreserve) {
1322//				outputFormatter.PrintToken(Tokens.Preserve);
1323//				outputFormatter.Space();
1324//			}
1325//			
1326//			AppendCommaSeparatedList(reDimStatement.ReDimClauses);
1327//			return null;
1328//		}
1329//		
1330//		public override object TrackedVisitExpressionStatement(ExpressionStatement expressionStatement, object data)
1331//		{
1332//			TrackedVisit(expressionStatement.Expression, data);
1333//			return null;
1334//		}
1335//		
1336//		public override object TrackedVisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data)
1337//		{
1338//			if (localVariableDeclaration.Modifier != Modifiers.None) {
1339//				OutputModifier(localVariableDeclaration.Modifier & ~Modifiers.Dim);
1340//			}
1341//			if (!isUsingResourceAcquisition) {
1342//				if ((localVariableDeclaration.Modifier & Modifiers.Const) == 0) {
1343//					outputFormatter.PrintToken(Tokens.Dim);
1344//				}
1345//				outputFormatter.Space();
1346//			}
1347//			currentVariableType = localVariableDeclaration.TypeReference;
1348//			
1349//			AppendCommaSeparatedList(localVariableDeclaration.Variables);
1350//			currentVariableType = null;
1351//			
1352//			return null;
1353//		}
1354//		
1355//		public override object TrackedVisitReturnStatement(ReturnStatement returnStatement, object data)
1356//		{
1357//			outputFormatter.PrintToken(Tokens.Return);
1358//			if (!returnStatement.Expression.IsNull) {
1359//				outputFormatter.Space();
1360//				TrackedVisit(returnStatement.Expression, data);
1361//			}
1362//			return null;
1363//		}
1364//		
1365//		public override object TrackedVisitIfElseStatement(IfElseStatement ifElseStatement, object data)
1366//		{
1367//			outputFormatter.PrintToken(Tokens.If);
1368//			outputFormatter.Space();
1369//			TrackedVisit(ifElseStatement.Condition, data);
1370//			outputFormatter.Space();
1371//			outputFormatter.PrintToken(Tokens.Then);
1372//			outputFormatter.NewLine();
1373//			
1374//			PrintIndentedBlock(ifElseStatement.TrueStatement);
1375//			
1376//			foreach (ElseIfSection elseIfSection in ifElseStatement.ElseIfSections) {
1377//				TrackedVisit(elseIfSection, data);
1378//			}
1379//			
1380//			if (ifElseStatement.HasElseStatements) {
1381//				outputFormatter.Indent();
1382//				outputFormatter.PrintToken(Tokens.Else);
1383//				outputFormatter.NewLine();
1384//				PrintIndentedBlock(ifElseStatement.FalseStatement);
1385//			}
1386//			
1387//			outputFormatter.Indent();
1388//			outputFormatter.PrintToken(Tokens.End);
1389//			outputFormatter.Space();
1390//			outputFormatter.PrintToken(Tokens.If);
1391//			return null;
1392//		}
1393//		
1394//		public override object TrackedVisitElseIfSection(ElseIfSection elseIfSection, object data)
1395//		{
1396//			outputFormatter.Indent();
1397//			outputFormatter.PrintToken(Tokens.ElseIf);
1398//			outputFormatter.Space();
1399//			TrackedVisit(elseIfSection.Condition, data);
1400//			outputFormatter.Space();
1401//			outputFormatter.PrintToken(Tokens.Then);
1402//			outputFormatter.NewLine();
1403//			PrintIndentedBlock(elseIfSection.EmbeddedStatement);
1404//			return null;
1405//		}
1406//		
1407//		public override object TrackedVisitLabelStatement(LabelStatement labelStatement, object data)
1408//		{
1409//			outputFormatter.PrintIdentifier(labelStatement.Label);
1410//			outputFormatter.PrintToken(Tokens.Colon);
1411//			return null;
1412//		}
1413//		
1414//		public override object TrackedVisitGotoStatement(GotoStatement gotoStatement, object data)
1415//		{
1416//			outputFormatter.PrintToken(Tokens.GoTo);
1417//			outputFormatter.Space();
1418//			outputFormatter.PrintIdentifier(gotoStatement.Label);
1419//			return null;
1420//		}
1421//		
1422//		public override object TrackedVisitSwitchStatement(SwitchStatement switchStatement, object data)
1423//		{
1424//			exitTokenStack.Push(Tokens.Select);
1425//			outputFormatter.PrintToken(Tokens.Select);
1426//			outputFormatter.Space();
1427//			outputFormatter.PrintToken(Tokens.Case);
1428//			outputFormatter.Space();
1429//			TrackedVisit(switchStatement.SwitchExpression, data);
1430//			outputFormatter.NewLine();
1431//			++outputFormatter.IndentationLevel;
1432//			foreach…

Large files files are truncated, but you can click here to view the full file