private static bool CanBeMarkedAsConst(
            SeparatedSyntaxList <VariableDeclaratorSyntax> variables,
            SyntaxList <StatementSyntax> statements,
            int startIndex)
        {
            MarkLocalVariableAsConstWalker walker = MarkLocalVariableAsConstWalker.GetInstance();

            foreach (VariableDeclaratorSyntax variable in variables)
            {
                walker.Identifiers.Add(variable.Identifier.ValueText);
            }

            bool result = true;

            for (int i = startIndex; i < statements.Count; i++)
            {
                walker.Visit(statements[i]);

                if (walker.Result)
                {
                    result = false;
                    break;
                }
            }

            MarkLocalVariableAsConstWalker.Free(walker);

            return(result);
        }
Exemplo n.º 2
0
        public static void Free(MarkLocalVariableAsConstWalker walker)
        {
            walker.Identifiers.Clear();
            walker.Result = false;

            _cachedInstance = walker;
        }
        public static MarkLocalVariableAsConstWalker GetInstance()
        {
            MarkLocalVariableAsConstWalker walker = _cachedInstance;

            if (walker != null)
            {
                _cachedInstance = null;
                walker.Reset();
                return(walker);
            }

            return(new MarkLocalVariableAsConstWalker());
        }
Exemplo n.º 4
0
        public static MarkLocalVariableAsConstWalker GetInstance()
        {
            MarkLocalVariableAsConstWalker walker = _cachedInstance;

            if (walker != null)
            {
                Debug.Assert(walker.Identifiers.Count == 0);
                Debug.Assert(!walker.Result);

                _cachedInstance = null;
                return(walker);
            }

            return(new MarkLocalVariableAsConstWalker());
        }
 public static void Free(MarkLocalVariableAsConstWalker walker)
 {
     _cachedInstance = walker;
 }