Exemple #1
0
        protected override void Stmt(string result, LNode input, Action <EcsPrinterOptions> configure = null, Mode mode = Mode.Both)
        {
            bool exprMode = (mode & Mode.Expression) != 0;

            if ((mode & Mode.PrinterTest) == 0)
            {
                return;
            }

            var options = new EcsPrinterOptions();

            options.IndentString = "  ";
            // by default, test the mode that is more difficult to get right
            options.AllowChangeParentheses = false;
            // TODO: make round tripping work without this
            options.NewlineOptions &= ~(NewlineOpt.AfterOpenBraceInNewExpr | NewlineOpt.BeforeCloseBraceInNewExpr);
            if (configure != null)
            {
                configure(options);
            }
            var sb    = new StringBuilder();
            var mode2 = exprMode ? ParsingMode.Expressions : ParsingMode.Statements;

            if (input.Calls(S.Splice))
            {
                EcsLanguageService.Value.Print(input.Args, sb, MessageSink.Default, mode2, options);
            }
            else
            {
                EcsLanguageService.Value.Print(input, sb, MessageSink.Default, mode2, options);
            }
            AreEqual(result, sb.ToString());
        }
Exemple #2
0
		protected override void Stmt(string result, LNode input, Action<EcsPrinterOptions> configure = null, Mode mode = Mode.Both)
		{
			bool exprMode = (mode & Mode.Expression) != 0;
			if ((mode & Mode.PrinterTest) == 0)
				return;

			var options = new EcsPrinterOptions();
			options.IndentString = "  ";
			// by default, test the mode that is more difficult to get right
			options.AllowChangeParentheses = false;
			// TODO: make round tripping work without this
			options.NewlineOptions &= ~(NewlineOpt.AfterOpenBraceInNewExpr | NewlineOpt.BeforeCloseBraceInNewExpr);
			if (configure != null)
				configure(options);
			var sb = new StringBuilder();
			var mode2 = exprMode ? ParsingMode.Expressions : ParsingMode.Statements;
			if (input.Calls(S.Splice))
				EcsLanguageService.Value.Print(input.Args, sb, MessageSink.Default, mode2, options);
			else
				EcsLanguageService.Value.Print(input, sb, MessageSink.Default, mode2, options);
			AreEqual(result, sb.ToString());
		}