本文整理汇总了C#中CsDocument.FindFirstDescendentLexicalElement方法的典型用法代码示例。如果您正苦于以下问题:C# CsDocument.FindFirstDescendentLexicalElement方法的具体用法?C# CsDocument.FindFirstDescendentLexicalElement怎么用?C# CsDocument.FindFirstDescendentLexicalElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsDocument
的用法示例。
在下文中一共展示了CsDocument.FindFirstDescendentLexicalElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckLineSpacing
/// <summary>
/// Checks the line spacing within the given document.
/// </summary>
/// <param name="document">The document to check.</param>
private void CheckLineSpacing(CsDocument document)
{
Param.AssertNotNull(document, "document");
// Set up some variables.
int count = 0;
LexicalElement precedingItem = null;
bool fileHeader = true;
bool firstTokenOnLine = true;
// Loop through all the tokens in the document.
for (LexicalElement item = document.FindFirstDescendentLexicalElement(); item != null; item = item.FindNextDescendentLexicalElementOf(document))
{
// Check for cancel.
if (this.Cancel)
{
break;
}
// Check whether we're through the file header yet.
if (fileHeader &&
item.LexicalElementType != LexicalElementType.EndOfLine &&
item.LexicalElementType != LexicalElementType.WhiteSpace &&
item.LexicalElementType != LexicalElementType.Comment)
{
fileHeader = false;
}
// Check whether this token is an end-of-line character.
if (item.Text == "\n")
{
++count;
// This sets up for the next token, which will the be first token on its line.
firstTokenOnLine = true;
// Process the newline character.
this.CheckLineSpacingNewline(precedingItem, item, count);
}
else if (item.LexicalElementType != LexicalElementType.WhiteSpace)
{
// Process the non-whitespace character.
this.CheckLineSpacingNonWhitespace(document, precedingItem, item, fileHeader, firstTokenOnLine, count);
count = 0;
precedingItem = item;
if (firstTokenOnLine && item.LexicalElementType != LexicalElementType.Comment)
{
firstTokenOnLine = false;
}
}
}
}