/// <summary>Initializes the specified type member.</summary> /// <param name="typeMember">The type member.</param> /// <exception cref="ArgumentNullException">The type member cannot be null.</exception> private void Initialize([NotNull] ITypeMemberDeclaration typeMember) { if (typeMember == null) { throw new ArgumentNullException("typeMember"); } var sourceFile = typeMember.GetSourceFile(); if (sourceFile == null) { return; } var psiServices = typeMember.GetPsiServices(); if (psiServices == null) { throw new InvalidOperationException("psiServices"); } var cache = psiServices.GetCodeAnnotationsCache(); this.notNull = cache.GetAttributeTypeForElement(typeMember, CodeAnnotationsCache.NotNullAttributeShortName); this.canBeNull = cache.GetAttributeTypeForElement(typeMember, CodeAnnotationsCache.CanBeNullAttributeShortName); }
/// <summary>Initializes a new instance of the <see cref="CodeAnnotation"/> class. /// Codes the annotation.</summary> /// <param name="typeMember">The type member.</param> public CodeAnnotation([NotNull] ITypeMemberDeclaration typeMember) { if (typeMember == null) { throw new ArgumentNullException("typeMember"); } typeMember.GetPsiServices(); this.Initialize(typeMember); }