public override IList <IAttributeInstance> GetAttributeInstances(IClrTypeName clrName) { if (AttributeClassNames.IsEmpty()) { return(EmptyList <IAttributeInstance> .Instance); } if (!(GetDeclaration()?.GetFSharpSymbol() is FSharpEntity entity)) { return(EmptyList <IAttributeInstance> .Instance); } var psiModule = GetPsiModule(); var entityAttrs = entity.Attributes; if (entityAttrs.Count == 0) { return(EmptyList <IAttributeInstance> .Instance); } var result = new FrugalLocalList <IAttributeInstance>(); foreach (var fcsAttribute in entityAttrs) { if (new ClrTypeName(fcsAttribute.AttributeType.QualifiedBaseName).Equals(clrName)) { result.Add(new FSharpAttributeInstance(fcsAttribute, psiModule)); } } return(result.ResultingList()); }
public override bool HasAttributeInstance(IClrTypeName clrTypeName) { if (AttributeClassNames.Contains(clrTypeName.ShortName)) { return(false); } // todo: get entity without getting declaration var entity = (GetDeclaration() as IFSharpTypeDeclaration)?.GetFSharpSymbol() as FSharpEntity; return(entity?.Attributes.HasAttributeInstance(clrTypeName.FullName) ?? false); }
public override IList <IAttributeInstance> GetAttributeInstances(IClrTypeName clrName) { if (AttributeClassNames.IsEmpty()) { return(EmptyList <IAttributeInstance> .Instance); } if (!((GetDeclaration() as IFSharpTypeDeclaration)?.GetFSharpSymbol() is FSharpEntity entity)) { return(EmptyList <IAttributeInstance> .Instance); } var psiModule = GetPsiModule(); var entityAttrs = entity.Attributes; var attrs = new IAttributeInstance[entityAttrs.Count]; for (var i = 0; i < attrs.Length; i++) { attrs[i] = new FSharpAttributeInstance(entityAttrs[i], psiModule); } return(attrs); }