当前位置: 首页>>代码示例>>C#>>正文


C# AstNode.InsertChildAfter方法代码示例

本文整理汇总了C#中AstNode.InsertChildAfter方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.InsertChildAfter方法的具体用法?C# AstNode.InsertChildAfter怎么用?C# AstNode.InsertChildAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AstNode的用法示例。


在下文中一共展示了AstNode.InsertChildAfter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetModifiers

		internal static void SetModifiers(AstNode node, Modifiers newValue)
		{
			Modifiers oldValue = GetModifiers(node);
			AstNode insertionPos = node.GetChildrenByRole(AttributeRole).LastOrDefault();
			foreach (Modifiers m in CSharpModifierToken.AllModifiers) {
				if ((m & newValue) != 0) {
					if ((m & oldValue) == 0) {
						// Modifier was added
						node.InsertChildAfter(insertionPos, new CSharpModifierToken(AstLocation.Empty, m), ModifierRole);
					} else {
						// Modifier already exists
						insertionPos = node.GetChildrenByRole(ModifierRole).First(t => t.Modifier == m);
					}
				} else {
					if ((m & oldValue) != 0) {
						// Modifier was removed
						node.GetChildrenByRole (ModifierRole).First(t => t.Modifier == m).Remove();
					}
				}
			}
		}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:21,代码来源:AttributedNode.cs

示例2: AddConstraints

			void AddConstraints(AstNode parent, TypeParameters d)
			{
				if (d == null)
					return;
				for (int i = 0; i < d.Count; i++) {
					var typeParameter = d [i];
					if (typeParameter == null)
						continue;
					var c = typeParameter.Constraints;
					if (c == null)
						continue;
					var location = LocationsBag.GetLocations(c);
					var constraint = new Constraint();
					constraint.AddChild(new CSharpTokenNode(Convert(c.Location), Roles.WhereKeyword), Roles.WhereKeyword);
					constraint.AddChild(new SimpleType(Identifier.Create(c.TypeParameter.Value, Convert(c.TypeParameter.Location))), Roles.ConstraintTypeParameter);
					if (location != null)
						constraint.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.Colon), Roles.Colon);
					var commaLocs = LocationsBag.GetLocations(c.ConstraintExpressions);
					int curComma = 0;
					if (c.ConstraintExpressions != null) {
						foreach (var expr in c.ConstraintExpressions) {
							constraint.AddChild(ConvertToType(expr), Roles.BaseType);
							var sce = expr as SpecialContraintExpr;
							if (sce != null) {
								switch (sce.Constraint) {
									case SpecialConstraint.Class:
										break;
									case SpecialConstraint.Struct:
										break;
									case SpecialConstraint.Constructor:
										var bl = LocationsBag.GetLocations(expr);
										if (bl != null) {
											constraint.AddChild(new CSharpTokenNode(Convert(bl [0]), Roles.LPar), Roles.LPar);
											constraint.AddChild(new CSharpTokenNode(Convert(bl [1]), Roles.RPar), Roles.RPar);
										}
										break;
								}
							}

							if (commaLocs != null && curComma < commaLocs.Count)
								constraint.AddChild(new CSharpTokenNode(Convert(commaLocs [curComma++]), Roles.Comma), Roles.Comma);
						}
					}
					
					// We need to sort the constraints by position; as they might be in a different order than the type parameters
					AstNode prevSibling = parent.LastChild;
					while (prevSibling.StartLocation > constraint.StartLocation && prevSibling.PrevSibling != null)
						prevSibling = prevSibling.PrevSibling;
					parent.InsertChildAfter(prevSibling, constraint, Roles.Constraint);
				}
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:51,代码来源:CSharpParser.cs


注:本文中的AstNode.InsertChildAfter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。