<commit_before>using System;
using System.Collections.Generic;
using System.Linq;
using hw.Debug;
using hw.Forms;
using hw.Helper;
using Reni.Basics;
using Reni.Code;
using Reni.Context;
using Reni.Feature;
using Reni.TokenClasses;
using Reni.Type;

namespace Reni.Struct
{
    sealed class CompoundView : DumpableObject
    {
        static int _nextObjectId;
        [EnableDump]
        [Node]
        internal readonly Compound Compound;
        [EnableDump]
        [Node]
        internal readonly int ViewPosition;
        [Node]
        readonly ValueCache<CompoundType> _typeCache;
        [Node]
        readonly FunctionCache<int, AccessFeature> _accessFeaturesCache;
        [Node]
        readonly FunctionCache<int, FieldAccessType> _fieldAccessTypeCache;
        [Node]
        readonly FunctionCache<FunctionSyntax, FunctionBodyType> _functionBodyTypeCache;
        [Node]
        readonly ValueCache<CompoundContext> CompoundContextCache;

        internal CompoundView(Compound compound, int viewPosition)
            : base(_nextObjectId++)
        {
            Compound = compound;
            ViewPosition = viewPosition;
            CompoundContextCache = new ValueCache<CompoundContext>
                (() => new CompoundContext(this));

            _typeCache = new ValueCache<CompoundType>(() => new CompoundType(this));

            _accessFeaturesCache
                = new FunctionCache<int, AccessFeature>
                    (position => new AccessFeature(this, position));

            _fieldAccessTypeCache
                = new FunctionCache<int, FieldAccessType>
                    (position => new FieldAccessType(this, position));

            _functionBodyTypeCache
                = new FunctionCache<FunctionSyntax, FunctionBodyType>
                    (syntax => new FunctionBodyType(this, syntax));

            StopByObjectIds(-313);
        }

        public string GetCompoundChildDump()
            => Compound.GetCompoundIdentificationDump() + "@" + ViewPosition;

        public string GetCompoundIdentificationDump()
            => Context.GetContextIdentificationDump();

        [DisableDump]
        internal ContextBase Context
            => Compound.Parent.CompoundPositionContext(Compound.Syntax, ViewPosition);

        [DisableDump]
        internal CompoundType Type => _typeCache.Value;

        protected override string GetNodeDump()
            =>
                base.GetNodeDump() + "(" + Context.GetContextIdentificationDump()+ ")";

        [DisableDump]
        TypeBase IndexType => Compound.IndexType;

        bool _isObtainCompoundSizeActive;

        [DisableDump]
        internal CompoundContext CompoundContext => CompoundContextCache.Value;

        [DisableDump]
        internal Size CompoundViewSize
        {
            get
            {
                if(_isObtainCompoundSizeActive)
                    throw new RecursionWhileObtainingCompoundSizeException(this);<commit_msg>Trace<commit_after>using System;
using System.Collections.Generic;
using System.Linq;
using hw.Debug;
using hw.Forms;
using hw.Helper;
using Reni.Basics;
using Reni.Code;
using Reni.Context;
using Reni.Feature;
using Reni.TokenClasses;
using Reni.Type;

namespace Reni.Struct
{
    sealed class CompoundView : DumpableObject
    {
        static int _nextObjectId;
        [EnableDump]
        [Node]
        internal readonly Compound Compound;
        [EnableDump]
        [Node]
        internal readonly int ViewPosition;
        [Node]
        readonly ValueCache<CompoundType> _typeCache;
        [Node]
        readonly FunctionCache<int, AccessFeature> _accessFeaturesCache;
        [Node]
        readonly FunctionCache<int, FieldAccessType> _fieldAccessTypeCache;
        [Node]
        readonly FunctionCache<FunctionSyntax, FunctionBodyType> _functionBodyTypeCache;
        [Node]
        readonly ValueCache<CompoundContext> CompoundContextCache;

        internal CompoundView(Compound compound, int viewPosition)
            : base(_nextObjectId++)
        {
            Compound = compound;
            ViewPosition = viewPosition;
            CompoundContextCache = new ValueCache<CompoundContext>
                (() => new CompoundContext(this));

            _typeCache = new ValueCache<CompoundType>(() => new CompoundType(this));

            _accessFeaturesCache
                = new FunctionCache<int, AccessFeature>
                    (position => new AccessFeature(this, position));

            _fieldAccessTypeCache
                = new FunctionCache<int, FieldAccessType>
                    (position => new FieldAccessType(this, position));

            _functionBodyTypeCache
                = new FunctionCache<FunctionSyntax, FunctionBodyType>
                    (syntax => new FunctionBodyType(this, syntax));

            StopByObjectIds(-313);
        }

        public string GetCompoundChildDump()
            =>
                Compound.GetCompoundIdentificationDump() + "@"
                    + (IsEndPosition ? "" : ViewPosition.ToString());

        bool IsEndPosition => ViewPosition == Compound.Syntax.EndPosition;

        public string GetCompoundIdentificationDump()
            => Context.GetContextIdentificationDump();

        [DisableDump]
        internal ContextBase Context
            => Compound.Parent.CompoundPositionContext(Compound.Syntax, ViewPosition);

        [DisableDump]
        internal CompoundType Type => _typeCache.Value;

        protected override string GetNodeDump()
            =>
                base.GetNodeDump() + "(" + Context.GetContextIdentificationDump() + ")";

        [DisableDump]
        TypeBase IndexType => Compound.IndexType;

        bool _isObtainCompoundSizeActive;

        [DisableDump]
        internal CompoundContext CompoundContext => CompoundContextCache.Value;

        [DisableDump]
        internal Size CompoundViewSize
        {
            get
            {
                if(_isObtainCompoundSizeActive)
                    throw new RecursionWhileObtainingCompoundSizeException(this);
{'fraction_non_alphanumeric': 0.07777228538474214, 'fraction_numerical': 0.0009886307464162135, 'mean_word_length': 2.34619625137817, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4801943', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1469, 'n_words': 322}