예제 #1
0
		public void GenerateCode(ITextOutput output, Predicate<IAstTransform> transformAbortCondition)
		{
			TransformationPipeline.RunTransformationsUntil(astCompileUnit, transformAbortCondition, context);
			astCompileUnit.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }, null);
			
			var outputFormatter = new TextOutputFormatter(output);
			var formattingPolicy = new CSharpFormattingPolicy();
			// disable whitespace in front of parentheses:
			formattingPolicy.BeforeMethodCallParentheses = false;
			formattingPolicy.BeforeMethodDeclarationParentheses = false;
			formattingPolicy.BeforeConstructorDeclarationParentheses = false;
			formattingPolicy.BeforeDelegateDeclarationParentheses = false;
			astCompileUnit.AcceptVisitor(new OutputVisitor(outputFormatter, formattingPolicy), null);
		}
예제 #2
0
		/// <summary>
		/// Generates C# code from the abstract source tree.
		/// </summary>
		/// <remarks>This method adds ParenthesizedExpressions into the AST, and will run transformations if <see cref="RunTransformations"/> was not called explicitly</remarks>
		public void GenerateCode(ITextOutput output)
		{
			if (!transformationsHaveRun)
				RunTransformations();
			
			astCompileUnit.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }, null);
			var outputFormatter = new TextOutputFormatter(output);
			var formattingPolicy = new CSharpFormattingOptions();
			// disable whitespace in front of parentheses:
			formattingPolicy.SpaceBeforeMethodCallParentheses = false;
			formattingPolicy.SpaceBeforeMethodDeclarationParentheses = false;
			formattingPolicy.SpaceBeforeConstructorDeclarationParentheses = false;
			formattingPolicy.SpaceBeforeDelegateDeclarationParentheses = false;
			astCompileUnit.AcceptVisitor(new OutputVisitor(outputFormatter, formattingPolicy), null);
		}