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


C# SyntaxTree.AcceptVisitor方法代码示例

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


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

示例1: GenerateText

		public static string GenerateText(TypeDeclaration type, 
			OrderedPartCollection<AbstractDynamicCompilationExtension> extensions,
			HashSet<string> namespaces = null)
		{
			var unit = new SyntaxTree();

			if (namespaces == null)
			{
				namespaces = new HashSet<string>
				{
					typeof (SystemTime).Namespace,
					typeof (AbstractViewGenerator).Namespace,
					typeof (Enumerable).Namespace,
					typeof (IEnumerable<>).Namespace,
					typeof (IEnumerable).Namespace,
					typeof (int).Namespace,
					typeof (LinqOnDynamic).Namespace,
					typeof (Field).Namespace,
					typeof (CultureInfo).Namespace,
					typeof (Regex).Namespace
				};
			}

			foreach (var extension in extensions)
			{
				foreach (var ns in extension.Value.GetNamespacesToImport())
				{
					namespaces.Add(ns);
				}
			}

			foreach (var ns in namespaces)
			{
				unit.Members.Add(new UsingDeclaration(ns));
			}

			unit.Members.Add(new WindowsNewLine());

			unit.Members.Add(type);

			var stringWriter = new StringWriter();
			var output = new CSharpOutputVisitor(stringWriter, FormattingOptionsFactory.CreateSharpDevelop());
			unit.AcceptVisitor(output);

			return stringWriter.GetStringBuilder().ToString();
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:46,代码来源:QueryParsingUtils.cs

示例2: AnalyzeFormatting

		/// <summary>
		/// Analyzes the formatting of a given document and syntax tree.
		/// </summary>
		/// <param name="document">Document.</param>
		/// <param name="syntaxTree">Syntax tree.</param>
		/// <param name="token">The cancellation token.</param>
		public FormattingChanges AnalyzeFormatting(IDocument document, SyntaxTree syntaxTree, CancellationToken token = default (CancellationToken))
		{
			if (document == null)
				throw new ArgumentNullException("document");
			if (syntaxTree == null)
				throw new ArgumentNullException("syntaxTree");
			var result = new FormattingChanges(document);
			var visitor = new FormattingVisitor(this, document, result, token);
			syntaxTree.AcceptVisitor(visitor);
			return result;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:17,代码来源:CSharpFormatter.cs

示例3: ProcessAndReturnTrueIfEverythingIsSupported

 public bool ProcessAndReturnTrueIfEverythingIsSupported(SyntaxTree syntaxTree)
 {
     _result = true;
     syntaxTree.AcceptVisitor(this);
     return _result;
 }
开发者ID:jack128,项目名称:SaltarelleCompiler,代码行数:6,代码来源:UnsupportedConstructsScanner.cs

示例4: CreateNewFoldings

		List<NewFolding> CreateNewFoldings(SyntaxTree syntaxTree, IDocument document)
		{
			FoldingVisitor v = new FoldingVisitor();
			v.document = document;
			syntaxTree.AcceptVisitor(v);
			return v.foldings;
		}
开发者ID:asiazhang,项目名称:SharpDevelop,代码行数:7,代码来源:Parser.cs

示例5: Gather

 public static ISet<string> Gather(SyntaxTree syntaxTree, IEnumerable<string> predefinedSymbols)
 {
     var obj = new DefinedSymbolsGatherer(predefinedSymbols);
     syntaxTree.AcceptVisitor(obj);
     return obj._definedSymbols;
 }
开发者ID:JimmyJune,项目名称:SaltarelleCompiler,代码行数:6,代码来源:DefinedSymbolsGatherer.cs


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