Пример #1
0
        private PredefinedTypeNode ParsePredefinedType(PredefinedTypeSyntax type)
        {
            var keyword         = KSyntaxFactory.Token(KSyntaxKind.LocalKeyword);
            var kPredefinedType = KSyntaxFactory.PredefinedType(keyword);

            return(kPredefinedType);
        }
Пример #2
0
        private FieldDeclarationNode ParseFieldDeclaration(FieldDeclarationSyntax fieldDeclaration)
        {
            var declaration       = ParseDeclaration(fieldDeclaration.Declaration);
            var kFieldDeclaration = KSyntaxFactory.FieldDeclaration()
                                    .WithVariableDeclaration(declaration)
                                    .WithPeriod(KSyntaxFactory.Token(KSyntaxKind.Period));

            return(kFieldDeclaration);
        }
Пример #3
0
        private EqualsValueClauseNode ParseInitializer(EqualsValueClauseSyntax initializer)
        {
            var isToken      = KSyntaxFactory.Token(KSyntaxKind.IsKeyword);
            var value        = ParseExpression(initializer.Value);
            var kInitializer = KSyntaxFactory.EqualsValueClause()
                               .WithIsKeyword(isToken)
                               .WithValue(value);

            return(kInitializer);
        }
Пример #4
0
        private AssignmentExpressionNode ParseSimpleAssignmentExpression(AssignmentExpressionSyntax assignmentExpression)
        {
            var set                   = KSyntaxFactory.Token(KSyntaxKind.SetKeyword);
            var leftExpression        = ParseExpression(assignmentExpression.Left);
            var to                    = KSyntaxFactory.Token(KSyntaxKind.ToKeyword);
            var rightExpression       = ParseExpression(assignmentExpression.Right);
            var kAssignmentExpression = KSyntaxFactory.AssignmentExpression(KSyntaxKind.SimpleAssignmentExpression)
                                        .WithSet(set).WithLeft(leftExpression).WithTo(to).WithRight(rightExpression);

            return(kAssignmentExpression);
        }
Пример #5
0
        private ArgumentListNode ParseArgumentList(ArgumentListSyntax argumentList)
        {
            var kArgumentList        = KSyntaxFactory.ArgumentList();
            var sourceOpenParenSpan  = argumentList.OpenParenToken.Span;
            var sourceCloseParenSpan = argumentList.CloseParenToken.Span;

            kArgumentList.WithOpenParenToken(KSyntaxFactory.Token(KSyntaxKind.OpenParenToken, sourceOpenParenSpan.Start, sourceOpenParenSpan.End));

            foreach (var argument in argumentList.Arguments)
            {
                var kArgument = ParseArgument(argument);
                kArgumentList.AddArguments(kArgument);
            }

            kArgumentList.WithCloseParenToken(KSyntaxFactory.Token(KSyntaxKind.CloseParenToken, sourceCloseParenSpan.Start, sourceCloseParenSpan.End));
            return(kArgumentList);
        }