本文整理汇总了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);
}
示例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);
}