예제 #1
0
        public static void Free(ContainsYieldWalker walker)
        {
            walker.SearchForYieldBreak  = true;
            walker.SearchForYieldReturn = true;
            walker.YieldStatement       = null;

            _cachedInstance = walker;
        }
예제 #2
0
        private static bool ContainsYieldCore(BlockSyntax block, TextSpan?span, bool yieldReturn, bool yieldBreak)
        {
            ContainsYieldWalker walker = Create(span, yieldReturn, yieldBreak);

            walker.VisitBlock(block);

            return(walker._success);
        }
예제 #3
0
        public static ContainsYieldWalker GetInstance()
        {
            ContainsYieldWalker walker = _cachedInstance;

            if (walker != null)
            {
                Debug.Assert(walker.YieldStatement == null);

                _cachedInstance = null;
                return(walker);
            }

            return(new ContainsYieldWalker());
        }
예제 #4
0
            public static ContainsYieldWalker GetInstance()
            {
                ContainsYieldWalker walker = _cachedInstance;

                if (walker != null)
                {
                    _cachedInstance = null;
                }
                else
                {
                    walker = new ContainsYieldWalker();
                }

                return(walker);
            }
예제 #5
0
        public static bool ContainsYield(SyntaxNode node, TextSpan?span = null, bool yieldReturn = true, bool yieldBreak = true)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            if (node.Kind() == SyntaxKind.LocalFunctionStatement)
            {
                return(ContainsYield((LocalFunctionStatementSyntax)node, span, yieldReturn, yieldBreak));
            }

            ContainsYieldWalker walker = Create(span, yieldReturn, yieldBreak);

            walker.Visit(node);

            return(walker._success);
        }
예제 #6
0
        public static bool ContainsYield(StatementSyntax statement, bool searchForYieldReturn = true, bool searchForYieldBreak = true)
        {
            if (statement == null)
            {
                throw new ArgumentNullException(nameof(statement));
            }

            ContainsYieldWalker walker = GetInstance();

            walker.SearchForYieldBreak  = searchForYieldBreak;
            walker.SearchForYieldReturn = searchForYieldReturn;

            walker.VisitStatement(statement);

            bool success = walker.YieldStatement != null;

            Free(walker);

            return(success);
        }
예제 #7
0
 public static void Free(ContainsYieldWalker walker)
 {
     walker.Reset();
     _cachedInstance = walker;
 }