Skip to content

Adds support for sorting @property in obj-c#217

Closed
bslack wants to merge 4 commits intouncrustify:masterfrom
bslack:master
Closed

Adds support for sorting @property in obj-c#217
bslack wants to merge 4 commits intouncrustify:masterfrom
bslack:master

Conversation

@bslack
Copy link
Copy Markdown

@bslack bslack commented Nov 12, 2013

Adds ability to sort property semantics. E.g.

@Property (nonatomic, readonly, assign) NSString *foo;
@Property (readonly, assign, nonatomic) NSString *bar;

can become:

@Property (nonatomic, readonly, assign) NSString *foo;
@Property (nonatomic, readonly, assign) NSString *bar;

The implementation is more convoluted then I had hoped/expected. The setter=foobar and getter=barfoo property specifiers messed up my initial implementation a bit and needed to be modified.

Control over the order that items will appear in is controlled via weights. The heigher the weight, the closer to the front it will be.

Don't expect this code to necessarily be accepted, but figured I would make the pull request so its a bit more public and others might pick it up / use it if they want.

@idpaterson
Copy link
Copy Markdown
Contributor

It would be nice to see this in uncrustify, can you add test cases for it?

Another trick for keeping your @property declarations consistent is to use a snippet in Xcode. I have the following snippet assigned to the shortcut "property".

/// <#description#>
@property (<#non#>atomic<#, strong#><#, weak#><#, copy#><#, assign#><#, readonly#>) <#type and name#>;

Xcode will turn each of those <# #> blocks into a parameter that you can tab through. This may seem like overkill at first but the workflow is pretty quick using just the tab, return, and delete keys. For example, to add a nonatomic assigned readonly property I would

  1. Type prop then press return to insert the snippet
  2. Press tab to move to the non parameter
  3. Press return to accept the parameter, inserting the text non in its place
  4. Press tab to move to the strong parameter
  5. Press delete to remove the strong parameter
  6. Repeat to either accept or remove each of the items
  7. Add the type and name

Of course this isn't nearly as helpful after-the-fact as Brandon's change but it works well for me to keep properties consistent in the first place. The setter=, getter=, and a few other options are not shown above simply because I don't use them often enough. If you wanted to add those, unfortunately it is not possible to nest the placeholders; while <#, getter=<#selector#>#> would be nice you would probably just have to use <#, getter=#>.

@bslack
Copy link
Copy Markdown
Author

bslack commented Nov 13, 2013

I will attempt to add test cases when I have time. I am also making a few other additions and will change the attributes/descriptions slightly.

Brandon Slack and others added 3 commits November 13, 2013 12:31
@bslack
Copy link
Copy Markdown
Author

bslack commented Nov 13, 2013

Will add tests for above this weekend or next week.
This now provides a few enhancements for supporting blocks.

@bengardner
Copy link
Copy Markdown
Collaborator

I just tried this code and I'm getting a bunch of test failures.

MISMATCH: 50077
MISMATCH: 50078
MISMATCH: 50079
MISMATCH: 50080
MISMATCH: 50081
MISMATCH: 50082
MISMATCH: 50083

Is there another change that these changes depend on?
Was too much pulled into the pull request.

Commit c68a89b looks like it has most of the changes.

@bslack
Copy link
Copy Markdown
Author

bslack commented Dec 17, 2013

I have more changeable it have not had time to commit. I am hoping to have
sometime over the Xmas holidays to wrap it up (or maybe this weekend if i
am lucky).

I'll make sure all tests pass before next submit.

Sent from my iPad

On Dec 16, 2013, at 9:35 PM, Ben Gardner notifications@github.com wrote:

I just tried this code and I'm getting a bunch of test failures.

MISMATCH: 50077
MISMATCH: 50078
MISMATCH: 50079
MISMATCH: 50080
MISMATCH: 50081
MISMATCH: 50082
MISMATCH: 50083

Is there another change that these changes depend on?
Was too much pulled into the pull request.

Commit c68a89bhttps://github.com/bengardner/uncrustify/commit/c68a89bfe7562alooks
like it has most of the changes.


Reply to this email directly or view it on
GitHubhttps://github.com/bengardner/uncrustify/pull/217#issuecomment-30721686
.

@gmaurel
Copy link
Copy Markdown
Collaborator

gmaurel commented May 27, 2016

Well, Xmas holidays is over.
Could you complete your work with an actual version against actual git, please with test sources and config files. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants