示例#1
0
文件: Frame.cs 项目: hahoyer/reni.cs
 Frame(Syntax target, Frame parent = null, HierachicalFormatter formatter = null)
 {
     Parent = parent;
     Formatter = parent?.Formatter ?? formatter;
     Target = target;
     LeftCache = new ValueCache<Frame>(() => new Frame(Target.Left, this));
     RightCache = new ValueCache<Frame>(() => new Frame(Target.Right, this));
     ItemsWithoutLeadingBreaksCache = new ValueCache<ResultItems>
         (GetItemsWithoutLeadingBreaks);
     LeadingLineBreaksCache = new ValueCache<int>(GetLeadingLineBreaksForCache);
     HasInnerLineBreaksCache = new ValueCache<bool>(GetHasInnerLineBreaksForCache);
 }
示例#2
0
文件: Frame.cs 项目: hahoyer/reni.cs
 internal static Frame Create(Syntax target, HierachicalFormatter formatter)
 {
     var result = new Frame(target, formatter: formatter);
     return result;
 }
示例#3
0
        internal ResultItems Item(Frame target, int leadingLineBreaks = 0)
        {
            var tokenClass = target.Target.TokenClass;
            if(!IsRelevant(tokenClass))
                return new ResultItems();

            var leftNeighbor = target
                .LeftNeighbor?
                .Chain(item => item.LeftNeighbor)
                .FirstOrDefault(item => IsRelevant(item.Target.TokenClass));

            var leftTokenClass = leftNeighbor?.Target.TokenClass;
            var indentLevel = target.IndentLevel;
            var token = target.Target.Token;
            return Item
                (
                    leftTokenClass,
                    leadingLineBreaks,
                    indentLevel,
                    token,
                    tokenClass
                );
        }