Пример #1
0
        private void ParseTypeAndVariables(TypeSyntax type, SeparatedSyntaxList <VariableDeclaratorSyntax> variables)
        {
            string typeString     = type.ToString();
            string variableSuffix = String.Empty;

            int index = typeString.IndexOf("[");

            if (index != -1)
            {
                variableSuffix = typeString.Substring(index);
                typeString     = typeString.Substring(0, index);
            }

            _output.HandleLeadingTrivia(type);
            _output.Add(typeString);
            _output.HandleTrailingTrivia(type);

            foreach (var variable in variables)
            {
                _output.HandleLeadingTrivia(variable.Identifier);
                _output.Add(variable.Identifier.ToString() + variableSuffix);
                _output.HandleTrailingTrivia(variable.Identifier);

                if (variable.Initializer != null)
                {
                    HandleTokenAndTrivia(variable.Initializer.EqualsToken);
                    _expression.ParseExpressionSyntax(variable.Initializer.Value);
                }
            }
        }
Пример #2
0
        public static void ParseInvocationExpressionDeclaration(Outputter output, Expression expression, InvocationExpressionSyntax invocationExpressionSyntax)
        {
            output.HandleLeadingTrivia(invocationExpressionSyntax);

            bool handled = false;
            IdentifierNameSyntax identifierNameSyntax = invocationExpressionSyntax.Expression as IdentifierNameSyntax;

            if (identifierNameSyntax != null)
            {
                output.HandleLeadingTrivia(identifierNameSyntax);

                output.Add(identifierNameSyntax.Identifier.Text);

                output.HandleTrailingTrivia(identifierNameSyntax);
                handled = true;
            }

            MemberAccessExpressionSyntax memberAccessExpressionSyntax = invocationExpressionSyntax.Expression as MemberAccessExpressionSyntax;

            if (memberAccessExpressionSyntax != null)
            {
                output.HandleLeadingTrivia(memberAccessExpressionSyntax);

                string expressionString = memberAccessExpressionSyntax.Expression.ToString() + memberAccessExpressionSyntax.OperatorToken + memberAccessExpressionSyntax.Name;
                output.Add(expressionString);
                output.HandleTrailingTrivia(memberAccessExpressionSyntax);
                handled = true;
            }

            if (!handled)
            {
                int k = 15;
            }

            ParseOperatorToken(output, invocationExpressionSyntax.ArgumentList.OpenParenToken);

            bool first = true;

            foreach (ArgumentSyntax argument in invocationExpressionSyntax.ArgumentList.Arguments)
            {
                if (!first)
                {
                    output.Add(", ");
                }
                first = false;

                expression.ParseExpressionSyntax(argument.Expression);
            }

            ParseOperatorToken(output, invocationExpressionSyntax.ArgumentList.CloseParenToken);

            output.HandleTrailingTrivia(invocationExpressionSyntax);
        }
Пример #3
0
 private static void ParseOperatorToken(Outputter output, SyntaxToken operatorToken)
 {
     output.HandleLeadingTrivia(operatorToken);
     output.Add(operatorToken.ValueText);
     output.HandleTrailingTrivia(operatorToken);
 }