本文整理汇总了C#中SyntaxTriviaList.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTriviaList.Skip方法的具体用法?C# SyntaxTriviaList.Skip怎么用?C# SyntaxTriviaList.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTriviaList
的用法示例。
在下文中一共展示了SyntaxTriviaList.Skip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitList
public override SyntaxTriviaList VisitList(SyntaxTriviaList list)
{
list = base.VisitList(list);
var lineBreaksAtBeginning = list.TakeWhile(t => t.IsKind(SyntaxKind.EndOfLineTrivia)).Count();
if (lineBreaksAtBeginning > 1)
{
list = SyntaxFactory.TriviaList(list.Skip(lineBreaksAtBeginning - 1));
}
return list;
}
示例2: ProcessTriviaList
private static SyntaxNode ProcessTriviaList(SyntaxNode syntaxRoot, SyntaxTriviaList triviaList, SyntaxTrivia singleLineComment)
{
var index = triviaList.IndexOf(singleLineComment);
if (index == -1)
{
return null;
}
do
{
index++;
}
while (!triviaList[index].IsKind(SyntaxKind.EndOfLineTrivia));
var startOfBlankLine = index;
do
{
index++;
}
while (!triviaList[index].IsKind(SyntaxKind.EndOfLineTrivia));
return syntaxRoot.ReplaceTrivia(triviaList.Skip(startOfBlankLine).Take(index - startOfBlankLine), (t1, t2) => default(SyntaxTrivia));
}
示例3: FixTriviaList
private static SyntaxTriviaList FixTriviaList(SyntaxTriviaList triviaList, IEnumerable<SyntaxTrivia> commentTrivias)
{
foreach (var singleLineComment in commentTrivias)
{
int commentLocation = triviaList.IndexOf(singleLineComment);
if (commentLocation == -1)
{
continue;
}
int index = commentLocation + 1;
index++;
while (index < triviaList.Count && index > 0)
{
switch (triviaList[index].Kind())
{
case SyntaxKind.EndOfLineTrivia:
case SyntaxKind.WhitespaceTrivia:
index++;
break;
default:
if (triviaList[index - 1].IsKind(SyntaxKind.WhitespaceTrivia))
{
index--;
}
triviaList = SyntaxTriviaList.Empty.AddRange(triviaList.Take(commentLocation + 2).Concat(triviaList.Skip(index)));
// We found the trivia so we don't have to loop any longer
index = -1;
break;
}
}
if (index == triviaList.Count)
{
if (triviaList[index - 1].IsKind(SyntaxKind.WhitespaceTrivia))
{
index--;
}
triviaList = SyntaxTriviaList.Empty.AddRange(triviaList.Take(commentLocation + 2).Concat(triviaList.Skip(index)));
}
}
return triviaList;
}
示例4: StripFileHeader
private static SyntaxTriviaList StripFileHeader(SyntaxTriviaList newLeadingTrivia)
{
var fileHeader = GetFileHeader(newLeadingTrivia);
return SyntaxTriviaList.Empty.AddRange(newLeadingTrivia.Skip(fileHeader.Count));
}
示例5: RemoveExistingHeader
/// <summary>
/// Remove any copyright header that already exists.
/// </summary>
private SyntaxTriviaList RemoveExistingHeader(SyntaxTriviaList oldList)
{
var foundHeader = false;
var i = 0;
MovePastBlankLines(oldList, ref i);
while (i < oldList.Count && IsLineComment(oldList[i]))
{
if (oldList[i].ToFullString().IndexOf("copyright", StringComparison.OrdinalIgnoreCase) >= 0)
{
foundHeader = true;
}
i++;
}
if (!foundHeader)
{
return oldList;
}
MovePastBlankLines(oldList, ref i);
return CreateTriviaList(oldList.Skip(i));
}
示例6: StripFileHeader
private static List<SyntaxTrivia> StripFileHeader(SyntaxTriviaList leadingTrivia)
{
var fileHeader = GetFileHeader(leadingTrivia);
return leadingTrivia.Skip(fileHeader.Count).ToList();
}