Menu

#444 Support method alignment in Objective-C declarations

closed-fixed
None
2018-01-25
2017-06-20
No

Currently, method alignment is only supported in Objective-C method calls. It'd be great to have a similar feature for method declarations as well, to get something like:

- (NSDateComponents *) components: (NSUInteger) unitFlags
                                                      fromDate: (NSDate *) startingDate
                                                          toDate: (NSDate *) resultDate
                                                        options: (NSUInteger) opts;

Related

Bugs: #444

Discussion

  • Daniel Ferreira

    Daniel Ferreira - 2017-06-20

    Er, this actually:

     - (NSDateComponents *) components: (NSUInteger) unitFlags
    -                         fromDate: (NSDate *) startingDate
    -                           toDate: (NSDate *) resultDate
    -                          options: (NSUInteger) opts;
    
     

    Last edit: Daniel Ferreira 2017-06-20
  • Jim Pattee

    Jim Pattee - 2017-06-21

    Version 3.0.1 aligns calls and declarations. What version are you using?

     
    • Daniel Ferreira

      Daniel Ferreira - 2017-06-21

      I am using 3.0.1, and I just tested it on a "simple" ObjC file and it
      worked. The issue was, again, due to class definitions being inside an
      extern "C" block, as I point out here[1].

      This time, though, my patch didn't solve the issue. There must be some
      other check somewhere else that causes them not to be aligned properly
      if inside a block.

      -- Daniel.

      On Wed, Jun 21, 2017 at 10:39 AM, Jim Pattee jimp03@users.sf.net wrote:

      Version 3.0.1 aligns calls and declarations. What version are you using?


      [bugs:#444] Support method alignment in Objective-C declarations

      Status: open
      Created: Tue Jun 20, 2017 10:44 PM UTC by Daniel Ferreira
      Last Updated: Tue Jun 20, 2017 10:45 PM UTC
      Owner: nobody

      Currently, method alignment is only supported in Objective-C method calls.
      It'd be great to have a similar feature for method declarations as well, to
      get something like:

      • (NSDateComponents ) components: (NSUInteger) unitFlags
        fromDate: (NSDate
        )
        startingDate
        toDate: (NSDate *)
        resultDate
        options:
        (NSUInteger) opts;

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/astyle/bugs/444/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #444

  • Daniel Ferreira

    Daniel Ferreira - 2017-06-21

    I tried replying to this thread via an e-mail and it did not show up here. I do not know if this is due to a delay or if it's really so (sorry for my cluelessness about SourceForge).

    Regardless, my issue was due to (again) my class definition being inside an extern "C" block, which caused the parser to misidentify it as not-a-method-definition.

    The following patch amends the issue (although probably adds some other issue). Could you think of a solution here?

    Index: ASBeautifier.cpp
    ===================================================================
    --- ASBeautifier.cpp    (revision 592)
    +++ ASBeautifier.cpp    (working copy)
    @@ -2269,6 +2269,7 @@
    
     void ASBeautifier::adjustObjCMethodDefinitionIndentation(const string& line_)
     {
    +   printf("adjust objc method definition indentation!\n");
        // register indent for Objective-C continuation line
        if (line_.length() > 0
                && (line_[0] == '-' || line_[0] == '+'))
    @@ -3551,7 +3552,7 @@
            }
            else if ((ch == '-' || ch == '+')
                     && peekNextChar(line, i) == '('
    -                && headerStack->empty()
    +                //&& headerStack->empty()
                     && line.find_first_not_of(" \t") == i)
            {
                if (isInObjCInterface)
    
     

    Last edit: Daniel Ferreira 2017-06-21
  • Jim Pattee

    Jim Pattee - 2017-06-27
    • status: open --> open-fixed
    • assigned_to: Jim Pattee
     
  • Jim Pattee

    Jim Pattee - 2017-06-27

    Fixed and in Subversion.

     
  • Daniel Ferreira

    Daniel Ferreira - 2017-06-27

    Thanks!

     
  • Jim Pattee

    Jim Pattee - 2018-01-25
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.