public static IEnumerable GetDirectives()

in Backend/Core/ForTea.Core/Tree/T4TreeExtensions.cs [60:102]


    public static IEnumerable<IT4Directive> GetDirectives(
      [NotNull] this IT4File file,
      [NotNull] DirectiveInfo directiveInfo
    ) => file.Blocks.OfType<IT4Directive>().Where(d =>
      directiveInfo.Name.Equals(d.Name?.GetText(), StringComparison.OrdinalIgnoreCase));

    [NotNull]
    public static IEnumerable<IT4DirectiveAttribute> GetAttributes(
      [NotNull] this IT4Directive directive,
      [NotNull] DirectiveAttributeInfo info
    ) => directive.Attributes.Where(it =>
      string.Equals(it.Name.GetText(), info.Name, StringComparison.OrdinalIgnoreCase));

    [CanBeNull]
    public static IT4DirectiveAttribute GetFirstAttribute(
      [NotNull] this IT4Directive directive,
      [NotNull] DirectiveAttributeInfo info
    ) => directive.Attributes.FirstOrDefault(it =>
      string.Equals(it.Name.GetText(), info.Name, StringComparison.OrdinalIgnoreCase));

    /// <summary>Gets a T4 block containing a specified C# node.</summary>
    /// <typeparam name="T">The type of expected T4 container node.</typeparam>
    /// <param name="cSharpNode">The C# node whose T4 container will be retrieved.</param>
    /// <returns>An instance of <see cref="T"/>, or <c>null</c> if no container for <paramref name="cSharpNode"/> can be found.</returns>
    [CanBeNull]
    public static T GetT4ContainerFromCSharpNode<T>([CanBeNull] this ITreeNode cSharpNode)
      where T : class, ITreeNode
    {
      ISecondaryRangeTranslator secondaryRangeTranslator =
        (cSharpNode?.GetContainingFile() as IFileImpl)?.SecondaryRangeTranslator;
      if (secondaryRangeTranslator == null)
        return default;

      DocumentRange range = cSharpNode.GetDocumentRange();
      if (!range.IsValid())
        return default;

      ITreeNode t4Node = secondaryRangeTranslator.OriginalFile.FindNodeAt(range);
      if (t4Node == null)
        return default;

      return t4Node.GetContainingNode<T>(true);
    }