当前位置: 首页>>代码示例>>C#>>正文


C# CSharpOutputVisitor.VisitCompilationUnit方法代码示例

本文整理汇总了C#中CSharpOutputVisitor.VisitCompilationUnit方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpOutputVisitor.VisitCompilationUnit方法的具体用法?C# CSharpOutputVisitor.VisitCompilationUnit怎么用?C# CSharpOutputVisitor.VisitCompilationUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSharpOutputVisitor的用法示例。


在下文中一共展示了CSharpOutputVisitor.VisitCompilationUnit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestProgram

		void TestProgram(string program)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(program));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(StripWhitespace(program), StripWhitespace(outputVisitor.Text));
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:10,代码来源:CSharpOutputTest.cs

示例2: TestProgram

		public void TestProgram(string input, string expectedOutput)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(input));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			parser.CompilationUnit.AcceptVisitor(new VBNetToCSharpConvertVisitor(), null);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(expectedOutput, outputVisitor.Text);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:11,代码来源:VBToCSharpConverterTest.cs

示例3: TestProgram

		void TestProgram(string program)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, new StringReader(program));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(),
			                                    outputVisitor)) {
				outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			}
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(program.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", ""));
			parser.Dispose();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:14,代码来源:SpecialOutputVisitor.cs

示例4: TestProgram

		public void TestProgram(string input, string expectedOutput)
		{
			IParser parser = ParserFactory.CreateParser(SupportedLanguage.VBNet, new StringReader(input));
			parser.Parse();
			Assert.AreEqual("", parser.Errors.ErrorOutput);
			parser.CompilationUnit.AcceptVisitor(new VBNetConstructsConvertVisitor(), null);
			parser.CompilationUnit.AcceptVisitor(new ToCSharpConvertVisitor(), null);
			CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
			outputVisitor.Options.IndentationChar = ' ';
			outputVisitor.Options.IndentSize = 2;
			outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null);
			Assert.AreEqual("", outputVisitor.Errors.ErrorOutput);
			Assert.AreEqual(expectedOutput.Replace("\r", ""), outputVisitor.Text.Replace("\r", ""));
		}
开发者ID:sharpmonkey,项目名称:SharpDevelop,代码行数:14,代码来源:VBNetToCSharpConverterTest.cs

示例5: GenerateCode

 public static string GenerateCode(CompilationUnit compilationUnit)
 {
     CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor();
     outputVisitor.VisitCompilationUnit(compilationUnit, null);
     return outputVisitor.Text;
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:6,代码来源:TestUtil.cs

示例6: GenerateSourceCode

 /// <summary>
 /// Performs the reverse operation of parsing by serializing the specified <paramref name="compilationUnit"/>
 /// to source code.
 /// </summary>
 /// 
 /// <param name="compilationUnit">
 /// A <see cref="CompilationUnit"/> which is to be turned into source code.
 /// </param>
 /// 
 /// <returns>
 /// A string representing the source code that would compile to the provided <paramref name="compilationUnit"/>.
 /// </returns>
 public static string GenerateSourceCode(this CompilationUnit compilationUnit)
 {
     var outputVisitor = new CSharpOutputVisitor
     {
         Options =
         {
             IndentationChar = ' ',
             TabSize = 4,
             IndentSize = 4,
         }
     };
     using (CodeCommentDecorator.Install(outputVisitor))
     {
         outputVisitor.VisitCompilationUnit(compilationUnit, null);
     }
     return outputVisitor.Text;
 }
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:29,代码来源:RefactoryExtensions.cs

示例7: GenerateCode

        private void GenerateCode()
        {
            foreach (Source entry in Sources.Values)
            {
                if (entry.CodeFile)
                {
                    CSharpOutputVisitor csharpOutputVisitor = new CSharpOutputVisitor();
                    SpecialNodesInserter.Install(entry.Parser.Lexer.SpecialTracker.RetrieveSpecials(), csharpOutputVisitor);
                    csharpOutputVisitor.VisitCompilationUnit(entry.CompilationUnit, null);

                    entry.Code = csharpOutputVisitor.Text;
                }
            }
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:14,代码来源:Translator.cs


注:本文中的CSharpOutputVisitor.VisitCompilationUnit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。