當前位置: 首頁>>代碼示例>>C#>>正文


C# AstNode.GetNextNode方法代碼示例

本文整理匯總了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);
			}
		}
開發者ID:0xb1dd1e,項目名稱:NRefactory,代碼行數:23,代碼來源:CSharpParser.cs

示例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());
 }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:24,代碼來源:FormattingVisitor.cs

示例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;
            }
        }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:66,代碼來源:FormattingVisitor.cs

示例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;
		}
開發者ID:telebovich,項目名稱:monodevelop,代碼行數:10,代碼來源:CodeGenerationOptions.cs


注:本文中的AstNode.GetNextNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。