List <DAttribute> GetCurrentAttributeSet() { var attrs = new List <DAttribute>(); foreach (var attr in BlockAttributes.ToArray()) { attrs.Add(attr); } while (DeclarationAttributes.Count > 0) { var attr = DeclarationAttributes.Pop(); var m = attr as Modifier; if (m != null) { // If accessor already in attribute array, remove it if (DTokens.IsVisibilityModifier(m.Token)) { Modifier.CleanupAccessorAttributes(attrs); } if (!Modifier.ContainsAttribute(attrs, m.Token)) { attrs.Add(attr); } } else { attrs.Add(attr); } } return(attrs); }
void PushAttribute(DAttribute attr, bool BlockAttributes) { var stk = BlockAttributes?this.BlockAttributes:this.DeclarationAttributes; var m = attr as Modifier; if (m != null) { // If attr would change the accessability of an item, remove all previously found (so the most near attribute that's next to the item is significant) if (DTokens.IsVisibilityModifier(m.Token)) { Modifier.CleanupAccessorAttributes(stk, m.Token); } else { Modifier.RemoveFromStack(stk, m.Token); } } stk.Push(attr); }
List <DAttribute> GetCurrentAttributeSet() { var vis = D_Parser.Dom.Visitors.AstElementHashingVisitor.Instance; var keys = new List <ulong>(); var attrs = new List <DAttribute>(); Modifier lastVisModifier = null; ulong key; int i; foreach (var a in BlockAttributes) { // ISSUE: Theoretically, when having two identically written but semantically different UDA attributes, the first one will become overridden. key = a.Accept(vis); if ((i = keys.IndexOf(key)) > -1) { attrs[i] = a; } else { keys.Add(key); attrs.Insert(0, a); } } foreach (var a in DeclarationAttributes) { key = a.Accept(vis); if ((i = keys.IndexOf(key)) > -1) { attrs[i] = a; } else { keys.Add(key); attrs.Insert(0, a); } } DeclarationAttributes.Clear(); for (i = attrs.Count - 1; i >= 0; i--) { var m = attrs[i] as Modifier; if (m != null) { // If accessor already in attribute array, remove it if (DTokens.IsVisibilityModifier(m.Token)) { lastVisModifier = m; // Temporarily remove all vis modifiers and add the last one again attrs.RemoveAt(i); //keys.RemoveAt(i); -- No need to touch keys anymore continue; } } } if (lastVisModifier != null) { attrs.Insert(0, lastVisModifier); } return(attrs); }