private static void ProcessT4FeatureBlock(
            [NotNull] IT4FeatureBlock featureBlock,
            [NotNull] CodeStructureElement parentElement,
            [NotNull] ICSharpFile cSharpFile,
            [NotNull] ISecondaryRangeTranslator secondaryRangeTranslator,
            [NotNull] CSharpCodeStructureProcessingState state
            )
        {
            TreeTextRange t4Range     = featureBlock.Code.GetTreeTextRange();
            TreeTextRange cSharpRange = secondaryRangeTranslator.OriginalToGenerated(t4Range);

            if (!cSharpRange.IsValid())
            {
                return;
            }

            TreeOffset cSharpStart = cSharpRange.StartOffset;
            TreeOffset cSharpEnd   = cSharpRange.EndOffset;

            ITreeNode containingNode = cSharpFile.FindNodeAt(cSharpRange);

            if (containingNode == null)
            {
                return;
            }

            for (ITreeNode node = containingNode.FirstChild; node != null; node = node.NextSibling)
            {
                TreeOffset nodeStart = node.GetTreeStartOffset();
                if (nodeStart >= cSharpStart && nodeStart < cSharpEnd)
                {
                    ProcessCSharpNode(node, parentElement, state);
                }
            }
        }
        /// <summary>Creates a new feature block with new type members.</summary>
        /// <param name="originalFile">The original T4 file where the feature block must be created.</param>
        /// <param name="text">The code representing new C# type members.</param>
        /// <param name="first">The first node.</param>
        /// <param name="last">The last node.</param>
        /// <returns>A <see cref="TreeTextRange"/> representing the code range in the newly created feature block.</returns>
        protected override TreeTextRange CreateTypeMemberNode(IFile originalFile, string text, ITreeNode first, ITreeNode last)
        {
            IT4FeatureBlock featureBlock = T4ElementFactory.CreateFeatureBlock(text);

            featureBlock = ((IT4File)originalFile).AddFeatureBlock(featureBlock);
            return(featureBlock.Code.GetTreeTextRange());
        }
        public override void VisitFeatureBlockNode(IT4FeatureBlock featureBlockParam)
        {
            var code = featureBlockParam.Code;

            if (code == null)
            {
                return;
            }
            AppendFeature(code, new T4CodeDescription(code));
        }
 public override void VisitFeatureBlockNode(
     IT4FeatureBlock featureBlockParam,
     [NotNull] FoldingHighlightingConsumer context
     ) => AddFolding(context, T4CodeFoldingAttributes.FeatureBlock, featureBlockParam, "<#+ ... #>");