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


C# SyntaxNode.WithoutLeadingTrivia方法代码示例

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


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

示例1: Visit

		public override void Visit(SyntaxNode node)
		{
			if (_firstVisit)
			{
				_firstVisit = false;
				var leadingTabs = new String('\t', 2 + ClassDepth);
				_code = node.WithoutLeadingTrivia().WithTrailingTrivia().ToFullString()
					.Replace(leadingTabs, "");

				var nodeLine = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;

				var line = _lineNumberOverride ?? nodeLine;

				var codeBlocks = Regex.Split(_code, @"\/\*\*.*?\*\/", RegexOptions.Singleline)
					.Select(b => b.TrimStart('\r', '\n').TrimEnd('\r', '\n', '\t'))
					.Where(b => !string.IsNullOrEmpty(b) && b != ";")
					.Select(b=>new CodeBlock(b, line))
					.ToList();

				base.Visit(node);

				var nodeHasLeadingTriva = node.HasLeadingTrivia && node.GetLeadingTrivia()
					.Any(c=>c.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia);
				var blocks = codeBlocks.Intertwine<IDocumentationBlock>(this.TextBlocks, swap: nodeHasLeadingTriva);
				this.Blocks.Add(new CombinedBlock(blocks, line));
				return;
			}

			base.Visit(node);
		}
开发者ID:emohebi,项目名称:elasticsearch-net,代码行数:30,代码来源:CodeWithDocumentationWalker.cs

示例2: Visit

		public override void Visit(SyntaxNode node)
		{
			if (_firstVisit)
			{
				_firstVisit = false;

				var repeatedTabs = 2 + ClassDepth;
				var language = Language.CSharp;



				_code = node.WithoutLeadingTrivia().WithTrailingTrivia().ToFullString();
				_code = _code.RemoveNumberOfLeadingTabsAfterNewline(repeatedTabs);

#if !DOTNETCORE
				if (_propertyOrMethodName == "ExpectJson" || _propertyOrMethodName == "QueryJson")
				{
					// try to get the json for the anonymous type.
					// Only supports system types and Json.Net LINQ objects e.g. JObject
					string json;
					if (_code.TryGetJsonForAnonymousType(out json))
					{
						language = Language.JavaScript;
						_code = json;
					}
				}
#endif
				// TODO: Can do this once we get the generic arguments from the Property declaration
				//if (_propertyName == "Fluent")
				//{
				//  // need to know what type we're operating on
				//	_code += $"client.Search({_code});";
				//}

				var nodeLine = node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line;
				var line = _lineNumberOverride ?? nodeLine;
				var codeBlocks = ParseCodeBlocks(_code, line, language, _propertyOrMethodName);

				base.Visit(node);

				var nodeHasLeadingTriva = node.HasLeadingTrivia &&
					node.GetLeadingTrivia().Any(c => c.Kind() == SyntaxKind.MultiLineDocumentationCommentTrivia);
				var blocks = codeBlocks.Intertwine<IDocumentationBlock>(this.TextBlocks, swap: nodeHasLeadingTriva);
				this.Blocks.Add(new CombinedBlock(blocks, line));
				return;
			}

			base.Visit(node);
		}
开发者ID:RossLieberman,项目名称:NEST,代码行数:49,代码来源:CodeWithDocumentationWalker.cs


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