Пример #1
0
        /// <summary>
        /// Before returning a Consume result, we should do a few more checks
        /// </summary>
        /// <param name="xoContext.CurrentNode"></param>
        /// <param name="xoContext.List"></param>
        /// <returns></returns>
        private static CanConsumeResult CheckIfConsumptionIsAllowed(ParsingContext xoContext, Boolean xbIsPreconsumption = false)
        {
            Boolean bIsCompoundNotItem = xoContext.List != null?
                                         xoContext.List.Peek().ExpectedType == SyntaxKind.NotKeyword &&
                                         (xoContext.List.Peek(1).ExpectedType == SyntaxKind.InKeyword ||
                                          xoContext.List.Peek(1).ExpectedType == SyntaxKind.LikeKeyword) : false;

            Boolean bIsBinaryOperator =
                bIsCompoundNotItem ||
                SyntaxKindFacts.IsBinaryConstruct(xoContext.List.Peek().ExpectedType);

            // Only forcibly add a construct after we are full IF it is a binary construct
            if (xoContext.CurrentNode.IsFull() &&
                !bIsBinaryOperator)
            {
                // We also find most of our problematic nodes here
                // And orphaned nodes

                return(CanConsumeResult.Complete);
            }

            return(CanConsumeResult.Consume);
        }