void CheckAttribute(FileDiagnostics diagnostics, Token attribute, MethodAttributeType type) { if (attribute == null) { return; } var newAttribute = new MethodAttributeContext(attribute, type); // If the attribute already exists, syntax error. bool wasCopy = false; for (int c = 0; c < ObtainedAttributes.Count; c++) { if (ObtainedAttributes[c].Type == newAttribute.Type) { newAttribute.Copy(diagnostics); wasCopy = true; break; } } // Add the attribute. ObtainedAttributes.Add(newAttribute); // Additonal syntax errors. Only throw if the attribute is not a copy. if (!wasCopy) { ValidateAttribute(diagnostics, newAttribute); ApplyAttribute(newAttribute); } }
public MethodAttributeContext(Token token, MethodAttributeType type) { Token = token; Type = type; }