Author Topic: Ada : Block indent not fixed by Syntax Expasion?  (Read 2807 times)

rgloden

  • Senior Community Member
  • Posts: 169
  • Hero Points: 5
Ada : Block indent not fixed by Syntax Expasion?
« on: April 06, 2018, 06:43:57 AM »
In a new Ada buffer type the following:

procedure test is
i  : integer;
begin (space char)

When the space char after "begin" is typed, Syntax Expansion recognizes that we are starting a begin block but doesn't fix the indentation which feels really really strange when typing in new code.  "Beautify" fixes the indentation.  However, it is still feels really odd when inserting new code ... so much that my workflow is often interrupted as I have to stop and Beautify to "right the ship" and then context switch back into my workflow ...

Obviously it would be cool if this was hot fixable ... but it would be even incredibly better if SE support Ada "Beautify while typing"  ;D
« Last Edit: April 06, 2018, 06:46:34 AM by rgloden »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6877
  • Hero Points: 530
Re: Ada : Block indent not fixed by Syntax Expasion?
« Reply #1 on: April 11, 2018, 02:15:37 AM »
I just want to clarify what I think you are asking for:

If you type:
Code: [Select]
procedure test is
     i:integer;
     begin<space>

You would like the begin/end block to be indented correctly under the 'p' of procedure? When I type the above code the "i:integer;" gets indented. In your example, it's not indented which is confusing me. Just wondering if you're expecting it to beautify the entire code block (much harder to do).

rgloden

  • Senior Community Member
  • Posts: 169
  • Hero Points: 5
Re: Ada : Block indent not fixed by Syntax Expasion?
« Reply #2 on: April 11, 2018, 05:32:25 AM »
Sorry ... my example more geared as to what to type and let SE do the formatting.

Seems that a space, which currently triggers the Syntax expansion, (or "Return" if used instead of space to skip Syntax expansion) would feel like the most natural time to correct the indentation.  (Eclipse triggers the indentation correction on the "return" but doesn't seem to do Syntax Expansion for the begin block.)

Expected indentation (which is also what the Beautifier does) is "begin" is under the "p".
Code: [Select]
package body example is

   procedure test is
      i : integer;
   begin -- test
     
   end test;

end example;

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6877
  • Hero Points: 530
Re: Ada : Block indent not fixed by Syntax Expasion?
« Reply #3 on: April 11, 2018, 03:56:19 PM »
Thanks for the clarification.

Please try the attached updated ada.e. Its for 22.0.2. It's smarter for Enter and Space handling of begin and end keywords. Since we don't have statement level tagging for Ada, it won't handle all cases.

If it works ok for you, we will add this to the hot fixes for 22.0.2.

rgloden

  • Senior Community Member
  • Posts: 169
  • Hero Points: 5
Re: Ada : Block indent not fixed by Syntax Expasion?
« Reply #4 on: April 14, 2018, 11:03:28 PM »
That does the trick ...

Note: on ada.e line 612 it looks like a space between "begin" and the comment was dropped in the patch which causes GNAT ada compiler to complain (a coding standards thing).

Is:
   replace_line(indent_string(width)strip(line)'-- 'unit_name);
Should be:
   replace_line(indent_string(width)strip(line)' -- 'unit_name);

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6877
  • Hero Points: 530
Re: Ada : Block indent not fixed by Syntax Expasion?
« Reply #5 on: April 14, 2018, 11:05:56 PM »
Thanks. I'll fix it up.