public override SyntaxNode VisitGenericName(GenericNameSyntax node)
        {
            INamedTypeSymbol originalSymbol = GetOriginalTypeSymbol(node);

            if (originalSymbol != null)
            {
                // Move first table declaration to a new line and indent it
                if (originalSymbol.InheritsFromOrEqualsGeneric(Context.PXSelectBase) ||
                    originalSymbol.ImplementsInterface(Context.IBqlSelect) ||
                    originalSymbol.ImplementsInterface(Context.IBqlSearch))                    // TODO: could be Coalesce - handle this case in the future
                {
                    var childRewriter = new BqlFirstTableRewriter(this, DefaultLeadingTrivia);
                    node = (GenericNameSyntax)childRewriter.Visit(node);
                }

                // Each time we see one of this statements, increase indent and move statement to new line
                if (originalSymbol.ImplementsInterface(Context.IBqlOrderBy))
                {
                    return(RewriteGenericNode(node, new BqlStatementRewriter(this, IndentedDefaultTrivia)));
                }

                // Each time we see one of this statements, move statement to new line
                if (originalSymbol.ImplementsInterface(Context.IBqlSortColumn))
                {
                    return(RewriteGenericNode(node, new BqlStatementRewriter(this, DefaultLeadingTrivia)));
                }

                if (originalSymbol.ImplementsInterface(Context.IBqlJoin))
                {
                    var rewriter = new BqlJoinRewriter(this, DefaultLeadingTrivia);
                    return(rewriter.Visit(node));
                }

                if (originalSymbol.ImplementsInterface(Context.IBqlWhere))
                {
                    var rewriter = new BqlConditionRewriter(this, DefaultLeadingTrivia);
                    return(rewriter.Visit(node));
                }

                if (originalSymbol.InheritsFromOrEqualsGeneric(Context.Aggregate))
                {
                    return(RewriteGenericNode(node, new BqlAggregateRewriter(this, IndentedDefaultTrivia)));
                }
            }

            return(base.VisitGenericName(node));
        }
Esempio n. 2
0
        public override SyntaxNode VisitGenericName(GenericNameSyntax node)
        {
            bool moveWhereToNextLine = _firstWhereInParenthesis || _externalMode;

            _firstWhereInParenthesis = false;

            INamedTypeSymbol originalSymbol = GetOriginalTypeSymbol(node);

            if (originalSymbol != null)
            {
                if (originalSymbol.InheritsFromOrEqualsGeneric(Context.Where2) ||
                    originalSymbol.InheritsFromOrEqualsGeneric(Context.And2) ||
                    originalSymbol.InheritsFromOrEqualsGeneric(Context.Or2))
                {
                    var childRewriter = new BqlConditionRewriter(this, IndentedDefaultTrivia)
                    {
                        _firstWhereInParenthesis = true
                    };
                    return(RewriteGenericNode(node, childRewriter));
                }

                if (originalSymbol.ImplementsInterface(Context.IBqlWhere))                 // "parenthesis" in BQL statement
                {
                    if (moveWhereToNextLine)
                    {
                        return(RewriteGenericNode(node, new BqlConditionRewriter(this, IndentedDefaultTrivia)));
                    }

                    // Leave Where on the same line, but indent and move all logic operators within the content to a new line
                    var childRewriter = new BqlConditionRewriter(this, IndentedDefaultTrivia);
                    return(node.WithTypeArgumentList((TypeArgumentListSyntax)childRewriter.Visit(node.TypeArgumentList)));
                }

                if (originalSymbol.ImplementsInterface(Context.IBqlPredicateChain))
                {
                    return(RewriteGenericNode(node, new BqlConditionRewriter(this, DefaultLeadingTrivia)));
                }
            }

            return(base.VisitGenericName(node));
        }
Esempio n. 3
0
 private BqlConditionRewriter(BqlConditionRewriter parent, SyntaxTriviaList defaultLeadingTrivia)
     : base(parent, defaultLeadingTrivia)
 {
 }