This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Add ability to align Objective-C property declarations
Needs ReviewPublic

Authored by matto1990 on May 1 2015, 6:59 AM.

Details

Reviewers
djasper
Summary

In Objective-C some style guides use a style where property declarations are aligned, to help with code readability. I've added an option which enable this functionality. It is disabled by default.

The option will align code so

@property(nonatomic, weak) NSNumber *text;
@property(nonatomic) BOOL trueOrFalse;

becomes

@property(nonatomic, weak) NSNumber *text;
@property(nonatomic)       BOOL     trueOrFalse;

Diff Detail

Event Timeline

matto1990 updated this revision to Diff 24800.May 1 2015, 6:59 AM
matto1990 retitled this revision from to [clang-format] Add ability to align Objective-C property declarations.
matto1990 updated this object.
matto1990 edited the test plan for this revision. (Show Details)
matto1990 added a subscriber: Unknown Object (MLST).
djasper edited edge metadata.

Generally, you need to assign a reviewer (me for clang-format changes). Otherwise, these might just get lost on the list.

lib/Format/WhitespaceManager.cpp
32

Manuel, what was the original reason why we don't just store a pointer to the token?

239

"all of the changed"?

324–344

I am actually quite strongly against this. This essentially introduce some additional (mini-)parser in WhitespaceManager. We have so many steps doing parsing already that I think we really should be doing some of this there.

(This might actually also be the right thing to do for assignments, although "parsing" those is much simple).

I think we should extend TokenAnnotator. I just looked at it and it already has the LineType ObjCProperty. I think we should probably just re-use that in some fashion. So the question is how do we carry information about (unwrapped) lines to the WhitespaceManager.

Not quite sure yet how to do that. I'll take a look next week if you don't beat me to it.

Also, if we preserved more of the token information, we would already know, where the name of the property starts (I think).

klimek resigned from this revision.Jul 3 2015, 6:49 AM
klimek removed a reviewer: klimek.