Ejemplo n.º 1
0
        /// <summary>
        /// Rewrites a variable declaration.
        /// </summary>
        /// <param name="node">The variable declaration to rewrite.</param>
        /// <returns>The rewritten variable declaration.</returns>
        protected virtual BoundStatement RewriteVariableDeclaration(BoundVariableDeclaration node)
        {
            var initializer = RewriteExpression(node.Initializer);

            if (initializer == node.Initializer)
            {
                return(node);
            }

            return(new BoundVariableDeclaration(node.Variable, initializer));
        }
Ejemplo n.º 2
0
        private static void WriteVariableDeclaration(BoundVariableDeclaration node, IndentedTextWriter writer)
        {
            if (node.Variable.IsReadOnly)
            {
                writer.WriteKeyword(SyntaxKind.ConstKeyword);
                writer.WriteSpace();
            }

            writer.WriteIdentifier(node.Variable.Name);
            writer.WriteSpace();
            if (node.Variable.IsReadOnly)
            {
                writer.WritePunctuation(SyntaxKind.EqualsToken);
            }
            else
            {
                writer.WritePunctuation(SyntaxKind.ColonEqualsToken);
            }

            writer.WriteSpace();
            node.Initializer.WriteTo(writer);
            writer.WriteLine();
        }