Sarcasm.Unparsing.FormatYielder.YieldBefore C# (CSharp) Méthode

YieldBefore() private méthode

This method needs to be fully executed before UnparseRawMiddle because this method modifies the state of Unparser and, which state is used by UnparseRawMiddle. Thus, always call this method prior to UnparseRawMiddle.
private YieldBefore ( UnparsableAst self, Params &@params ) : IEnumerable
self UnparsableAst
@params Params
Résultat IEnumerable
        internal IEnumerable<UtokenBase> YieldBefore(UnparsableAst self, out Params @params)
        {
            /*
             * To achieve fully execution before UnparseRawMiddle, this method is not an iterator block rather populates a list.
             * Returning IReadOnlyList instead of IEnumerable is just an explicit guarantee to the caller to ensure that
             * the returned utokens does not need to be iterated through e.g. by converting it to a list in order to achieve full execution.
             * */

            Unparser.tsUnparse.Debug("YieldBefore");

            UpdateCacheOnTheFly(self, State.Before);

            var utokens = new List<UtokenBase>();
            BlockIndentation blockIndentation = BlockIndentation.ToBeSet;

            if (direction == Unparser.Direction.LeftToRight)
            {
                utokens.AddRange(YieldBetween(self));
                utokens.AddRange(YieldIndentationLeft(self, ref blockIndentation));
            }
            else
            {
                utokens.AddRange(YieldIndentationRight(self, ref blockIndentation));
            }

            InsertedUtokens leftInsertedUtokens;
            InsertedUtokens rightInsertedUtokens;

            _GetUtokensAround(self, out leftInsertedUtokens, out rightInsertedUtokens);

            InsertedUtokens insertedUtokensBefore;
            InsertedUtokens insertedUtokensAfter;

            if (direction == Unparser.Direction.LeftToRight)
            {
                insertedUtokensBefore = leftInsertedUtokens;
                insertedUtokensAfter = rightInsertedUtokens;
            }
            else
            {
                insertedUtokensBefore = rightInsertedUtokens;
                insertedUtokensAfter = leftInsertedUtokens;
            }

            if (insertedUtokensBefore != InsertedUtokens.None)
            {
                Unparser.tsUnparse.Debug("inserted utokens: {0}", insertedUtokensBefore);
                utokens.Add(insertedUtokensBefore);
            }

            @params = new Params(blockIndentation, insertedUtokensAfter);

            return utokens;
        }