6 Replies Latest reply on Feb 5, 2020 5:31 PM by Vadim Tropashko-Oracle

    19.4 Procedure Conditional Formatting

    LeeG-BBY

      In 19.1, I was able to conditionally format procedures that used named notation to use line breaks, but procedures that did not use named notation to not use line breaks with a fix provided in this thread https://community.oracle.com/thread/4270289

       

      I re-applied the fix to 19.4, but it does not work like it used to in 19.1.

       

      Current formatting settings:

       

      Formatting results BEFORE applying fix:

      BEGIN  
        -- With named notation  
        proc1(
          param_1  => val_1
        , param_2  => val_2
        , param_3  => val_3
        );  
        -- Without named notation  
        proc1(
          param_1
        , param_2
        , param_3
        );
      END;
      

       

       

      Formatting results AFTER applying fix:

      BEGIN  
        -- With named notation  
        proc1(
          param_1  => val_1
        , param_2  => val_2
        , param_3  => val_3
        );  
        -- Without named notation  
        proc1(param_1
            , param_2
            , param_3);
      END;
      

       

       

      Expected results:

      BEGIN  
        -- With named notation  
        proc1(
          param_1  => val_1
        , param_2  => val_2
        , param_3  => val_3
        );  
        -- Without named notation  
        proc1(param_1, param_2, param_3);
      END;
      

       

       

       

      Is there a way to get this to work again in 19.4?

       

       

      Thanks,

      Lee

        • 1. Re: 19.4 Procedure Conditional Formatting
          Vadim Tropashko-Oracle

          Tested in 19.4:

           

          | .breaksProcArgs & [node) assoc_arg & [node^) paren_expr_list & [node+1) arg_list

          | .breaksProcArgs & [node) arg_list & [node^) paren_expr_list & [node-1) assoc_arg

          --| .breaksProcArgs & [node) ',' & [node^) arg_list & [node+1) arg

           

          commasInProc: [node) ',' & [node+1) assoc_arg

           

          Output:

           

          BEGIN   

            -- With named notation   

              proc1(

                  param_1  => val_1

                , param_2  => val_2

                , param_3  => val_3

              );   

            -- Without named notation   

              proc1(param_1, param_2, param_3);

          END;

           

           

          P.S. For version 20.1 I have added additional parameter in the prelude section of the arbori rules:

           

              function breaksProcArgs() { return struct.getCommasPerLine() == 1 }

              function breaksAssocArgs() { return false }   -- break function calls with associate arguments regardless

           

          If you flip it to true, while keeping commas-per-line reasonably large (not 1), then it is the only modification to satisfy your specs.

          • 2. Re: 19.4 Procedure Conditional Formatting
            LeeG-BBY

            Thanks Vadim,

             

            That worked for procedures in PL/SQL, but can functions in SQL follow the same rules?

             

            BEGIN    
              -- With named notation    
              proc1(
                param_1  => l_val_1
              , param_2  => l_val_2
              , param_3  => l_val_3
              );    
              
              -- Without named notation    
              l_var := proc1(l_val_1, l_val_2, l_val_3);
              
              -- Function in SQL without named notation
              SELECT
                func1(
                  val_1
                , val_2
                , val_3
                ) tst
              INTO l_val_4
              FROM
                t;
            
            
            END;
            

             

             

            Thanks,

            Lee

            • 3. Re: 19.4 Procedure Conditional Formatting
              Vadim Tropashko-Oracle

              Scratch my previous solution (Custom Format -> reset).

               

              Advanced Format->Commas per line in procedures = 10

               

              | /*.breaksProcArgs &*/ [node) assoc_arg & [node^) paren_expr_list & [node+1) arg_list

              | /*.breaksProcArgs &*/ [node) arg_list & [node^) paren_expr_list & [node-1) assoc_arg

              | /*.breaksProcArgs &*/ [node) ',' & [node^) arg_list & [node+1) assoc_arg

               

              Output:

               

              BEGIN    

                -- With named notation    

                  proc1(

                      param_1 => l_val_1

                    , param_2 => l_val_2

                    , param_3 => l_val_3

                  );    

                

                -- Without named notation    

                  l_var := proc1(l_val_1, l_val_2, l_val_3);

                

                -- Function in SQL without named notation

                  SELECT

                      func1(val_1, val_2, val_3) tst

                  INTO l_val_4

                  FROM

                      t;

               

               

              END;

              • 4. Re: 19.4 Procedure Conditional Formatting
                LeeG-BBY

                Thanks, that worked!

                 

                -Lee

                • 5. Re: 19.4 Procedure Conditional Formatting
                  Ümit ŞAMLI

                  Hi Vadim,

                  Your suggestions helped me a lot. Thank you.

                  I lost alignment after applying them. Can you suggest an arrangement for this?

                   

                  Current :

                  BEGIN     
                    -- With named notation    
                      proc1(
                          param_111111 => l_val_1,
                          param_222 => l_val_2,
                          param_3 => l_val_3 );
                  END;
                  

                   

                  Expected :

                  BEGIN     
                    -- With named notation    
                      proc1(
                          param_111111 => l_val_1,
                          param_222    => l_val_2,
                          param_3      => l_val_3 );
                  END;
                  

                   

                  • 6. Re: 19.4 Procedure Conditional Formatting
                    Vadim Tropashko-Oracle

                    _paddedIdsInScope1: (

                    ...

                    | /*.breaksProcArgs &*/ :alignNamedArgs & [id) sim_expr & [id+1) '=' & [id+2) '>' & [scope) paren_expr_list