private static bool IsValidContinueKeywordContext(bool isStatementContext, SyntaxToken token)
        {
            if (!isStatementContext)
            {
                return(false);
            }

            foreach (var v in token.Ancestors().Cast <SyntaxNode>())
            {
                if (v.IsContinuableConstruct())
                {
                    return(true);
                }
            }

            return(false);
        }
        private static bool IsValidBreakKeywordContext(bool isStatementContext, SyntaxToken token)
        {
            if (!isStatementContext)
            {
                return(false);
            }

            foreach (var v in token.Ancestors())
            {
                if (v.IsBreakableConstruct())
                {
                    return(true);
                }
            }

            return(false);
        }
        public static SyntaxNode FindCommonAncestor(this SyntaxToken token, SyntaxToken otherToken)
        {
            var otherTokenAncestors = otherToken.Ancestors().ToList();

            return(token.Ancestors().Cast <SyntaxNode>().FirstOrDefault(ancestor => otherTokenAncestors.Contains(ancestor)));
        }
Ejemplo n.º 4
0
        private static bool IsValidContinueKeywordContext(bool isStatementContext, SyntaxToken token)
        {
            if (!isStatementContext)
                return false;

            foreach (var v in token.Ancestors())
                if (v.IsContinuableConstruct())
                    return true;

            return false;
        }
Ejemplo n.º 5
0
 public static SyntaxNode FindCommonAncestor(this SyntaxToken token, SyntaxToken otherToken)
 {
     var otherTokenAncestors = otherToken.Ancestors().ToList();
     return token.Ancestors().FirstOrDefault(ancestor => otherTokenAncestors.Contains(ancestor));
 }