internal static void SetModifiers(AstNode node, Modifiers newValue) { Modifiers oldValue = GetModifiers(node); AstNode insertionPos = node.GetChildrenByRole(Attribute.AttributeRole).LastOrDefault(); foreach (Modifiers m in VBModifierToken.AllModifiers) { if ((m & newValue) != 0) { if ((m & oldValue) == 0) { // Modifier was added var newToken = new VBModifierToken(TextLocation.Empty, m); node.InsertChildAfter(insertionPos, newToken, ModifierRole); insertionPos = newToken; } 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(); } } } }
internal static void SetModifiers(AstNode node, LambdaExpressionModifiers newValue) { LambdaExpressionModifiers oldValue = GetModifiers(node); AstNode insertionPos = null; foreach (Modifiers m in VBModifierToken.AllModifiers) { if ((m & (Modifiers)newValue) != 0) { if ((m & (Modifiers)oldValue) == 0) { // Modifier was added var newToken = new VBModifierToken(AstLocation.Empty, m); node.InsertChildAfter(insertionPos, newToken, ModifierRole); insertionPos = newToken; } else { // Modifier already exists insertionPos = node.GetChildrenByRole(ModifierRole).First(t => t.Modifier == m); } } else { if ((m & (Modifiers)oldValue) != 0) { // Modifier was removed node.GetChildrenByRole(ModifierRole).First(t => t.Modifier == m).Remove(); } } } }
internal static void SetModifiers(AstNode node, Modifiers newValue) { Modifiers oldValue = GetModifiers(node); AstNode insertionPos = node.GetChildrenByRole(Attribute.AttributeRole).LastOrDefault(); foreach (Modifiers m in VBModifierToken.AllModifiers) { if ((m & newValue) != 0) { if ((m & oldValue) == 0) { // Modifier was added var newToken = new VBModifierToken(TextLocation.Empty, m); node.InsertChildAfter(insertionPos, newToken, ModifierRole); insertionPos = newToken; } 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(); } } } }
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { VBModifierToken o = other as VBModifierToken; return(o != null && this.modifier == o.modifier); }