Ejemplo n.º 1
0
        public override Ust VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node)
        {
            if (node.Declaration.Type is TupleTypeSyntax)
            {
                return(HandleTupleStatement(node.Declaration));
            }
            var type = ConvertType(base.Visit(node.Declaration.Type));

            AssignmentExpression[] variables =
                node.Declaration.Variables.Select(v => (AssignmentExpression)VisitAndReturnNullIfError(v))
                .Select(v =>
            {
                //here we set the type text if it is hidden on the right
                if (v is AssignmentExpression assignment &&
                    assignment.Right is ArrayCreationExpression arrayCreation)
                {
                    if (string.IsNullOrEmpty(arrayCreation.Type.TypeText))
                    {
                        arrayCreation.Type.TypeText = type.TypeText;
                    }
                }
                return(v);
            })
                .ToArray();

            var resultExpression = new VariableDeclarationExpression(type, variables, node.Declaration.GetTextSpan());
            var result           = new ExpressionStatement(resultExpression, node.GetTextSpan());

            return(result);
        }
Ejemplo n.º 2
0
        public override Ust VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node)
        {
            var type = ConvertType(base.Visit(node.Declaration.Type));

            AssignmentExpression[] variables =
                node.Declaration.Variables.Select(v => (AssignmentExpression)VisitAndReturnNullIfError(v))
                .ToArray();

            var resultExpression = new VariableDeclarationExpression(type, variables, node.Declaration.GetTextSpan());
            var result           = new ExpressionStatement(resultExpression, node.GetTextSpan());

            return(result);
        }