本文整理汇总了C#中AstNode.GetNextNode方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.GetNextNode方法的具体用法?C# AstNode.GetNextNode怎么用?C# AstNode.GetNextNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.GetNextNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertComment
static void InsertComment(ref AstNode insertionPoint, AstNode newNode, Role role, bool isDocumentationComment, AstNode rootNode)
{
TextLocation insertAt = newNode.StartLocation;
// Advance insertionPoint to the first node that has a start location >= insertAt
while (insertionPoint != null && insertionPoint.StartLocation < insertAt) {
// Enter the current node if insertAt is within
while (insertAt < insertionPoint.EndLocation && insertionPoint.FirstChild != null) {
insertionPoint = insertionPoint.FirstChild;
}
// Go to next node (insertionPoint.NextSibling if it exists; otherwise the next sibling of the parent node etc.)
insertionPoint = insertionPoint.GetNextNode();
}
// As a special case, XmlDoc gets inserted at the beginning of the entity declaration
if (isDocumentationComment && insertionPoint is EntityDeclaration && insertionPoint.FirstChild != null) {
insertionPoint = insertionPoint.FirstChild;
}
if (insertionPoint == null) {
// we're at the end of the compilation unit
rootNode.AddChildUnsafe(newNode, role);
} else {
insertionPoint.Parent.InsertChildBeforeUnsafe(insertionPoint, newNode, role);
}
}
示例2: EnsureNewLinesAfter
public void EnsureNewLinesAfter(AstNode node, int blankLines)
{
if (formatter.FormattingMode != FormattingMode.Intrusive)
blankLines = 1;
int foundBlankLines = 0;
var nextNode = node.GetNextNode ();
AstNode lastNewLine = null;
while (nextNode != null) {
if (!(nextNode is NewLineNode))
break;
lastNewLine = nextNode;
foundBlankLines++;
nextNode = nextNode.GetNextNode ();
}
if (nextNode == null)
return;
var start = document.GetOffset(node.EndLocation);
var end = document.GetOffset((lastNewLine ?? nextNode).StartLocation);
var sb = new StringBuilder(options.EolMarker.Length * blankLines);
for (int i = 0; i < blankLines + (lastNewLine != null ? -1 : 0); i++) {
sb.Append(options.EolMarker);
}
AddChange(start, end - start, sb.ToString());
}
示例3: FixOpenBrace
void FixOpenBrace(BraceStyle braceStyle, AstNode lbrace)
{
if (lbrace.IsNull)
return;
switch (braceStyle) {
case BraceStyle.DoNotChange:
return;
case BraceStyle.BannerStyle:
case BraceStyle.EndOfLine:
var prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
int prevOffset = document.GetOffset(prev.EndLocation);
if (prev is Comment || prev is PreProcessorDirective) {
int next = document.GetOffset(lbrace.GetNextNode ().StartLocation);
AddChange(prevOffset, next - prevOffset, "");
while (prev is Comment || prev is PreProcessorDirective)
prev = prev.GetPrevNode();
prevOffset = document.GetOffset(prev.EndLocation);
AddChange(prevOffset, 0, " {");
} else {
int braceOffset2 = document.GetOffset(lbrace.StartLocation);
AddChange(prevOffset, braceOffset2 - prevOffset, " ");
}
break;
case BraceStyle.EndOfLineWithoutSpace:
prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
prevOffset = document.GetOffset(prev.EndLocation);
int braceOffset = document.GetOffset(lbrace.StartLocation);
AddChange(prevOffset, braceOffset - prevOffset, "");
break;
case BraceStyle.NextLine:
prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
prevOffset = document.GetOffset(prev.EndLocation);
braceOffset = document.GetOffset(lbrace.StartLocation);
AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
break;
case BraceStyle.NextLineShifted:
prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
prevOffset = document.GetOffset(prev.EndLocation);
braceOffset = document.GetOffset(lbrace.StartLocation);
curIndent.Push(IndentType.Block);
AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
curIndent.Pop();
break;
case BraceStyle.NextLineShifted2:
prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
prevOffset = document.GetOffset(prev.EndLocation);
braceOffset = document.GetOffset(lbrace.StartLocation);
curIndent.Push(IndentType.Block);
AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
curIndent.Pop();
break;
}
}
示例4: NextExpression
static AstNode NextExpression (AstNode parent)
{
AstNode node = parent.GetNextNode ();
if (node == null)
return null;
while (node != null && !(node is Expression || node is Statement)) {
node = node.GetNextNode ();
}
return node;
}