コード例 #1
0
		void TestProgram(string program, PrettyPrintOptions options)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(program));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			outputVisitor.Options = options;
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(StripWhitespace(program), StripWhitespace(outputVisitor.Text));
		}
コード例 #2
0
		void TestStatement(string statement, PrettyPrintOptions options)
		{
			StringBuilder b = new StringBuilder();
			b.AppendLine("void Method()");
			b.AppendLine("{");
			using (StringReader r = new StringReader(statement)) {
				string line;
				while ((line = r.ReadLine()) != null) {
					b.Append("  ");
					b.AppendLine(line);
				}
			}
			b.AppendLine("}");
			TestTypeMember(b.ToString(), options);
		}
コード例 #3
0
		void TestTypeMember(string program, PrettyPrintOptions options)
		{
			StringBuilder b = new StringBuilder();
			b.AppendLine("class A");
			b.AppendLine("{");
			using (StringReader r = new StringReader(program)) {
				string line;
				while ((line = r.ReadLine()) != null) {
					b.Append("  ");
					b.AppendLine(line);
				}
			}
			b.AppendLine("}");
			TestProgram(b.ToString(), options);
		}
コード例 #4
0
		public void IfStatementSeparateLines()
		{
			PrettyPrintOptions options = new PrettyPrintOptions();
			options.PlaceElseOnNewLine = true;
			options.StatementBraceStyle = BraceStyle.NextLine;
			
			TestStatement("if (a)\n" +
			              "{\n" +
			              "  m1();\n" +
			              "}\n" +
			              "else\n" +
			              "{\n" +
			              "  m2();\n" +
			              "}", options);
			
			TestStatement("if (a)\n" +
			              "{\n" +
			              "  m1();\n" +
			              "}\n" +
			              "else if (b)\n" +
			              "{\n" +
			              "  m2();\n" +
			              "}\n" +
			              "else\n" +
			              "{\n" +
			              "  m3();\n" +
			              "}", options);
		}
コード例 #5
0
 public CSharpOutputFormatter(PrettyPrintOptions prettyPrintOptions) : base(prettyPrintOptions)
 {
     this.prettyPrintOptions = prettyPrintOptions;
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: superyfwy/db4o
		static PrettyPrintOptions CreatePrettyPrintOptions()
		{
			PrettyPrintOptions options = new PrettyPrintOptions();
			options.PropertyBraceStyle = BraceStyle.NextLine;
			options.PropertyGetBraceStyle = BraceStyle.NextLine;
			options.PropertySetBraceStyle = BraceStyle.NextLine;
			options.ClassBraceStyle = BraceStyle.NextLine;
			options.IndentationChar = ' ';
			options.IndentSize = 4;
			options.TabSize = 4;			
			return options;
		}
コード例 #7
0
		public CSharpOutputFormatter(PrettyPrintOptions prettyPrintOptions) : base(prettyPrintOptions)
		{
			this.prettyPrintOptions = prettyPrintOptions;
		}