Browse files

Fixed declared property getter and setter formatting.

The problem was that appledoc simple formatted these the same as any other attribute, so resulting property declaration was something like "@property (readonly, getter, =, isName) BOOL name;". This is now properly detected and result is "@property (readonly, getter=isName) BOOL name;".
  • Loading branch information...
1 parent 0c58424 commit c05364a9a4d7681d4b192983e843d94e577c66b2 @tomaz committed Dec 16, 2010
Showing with 41 additions and 0 deletions.
  1. +9 −0 Model/GBMethodData.m
  2. +32 −0 Testing/GBMethodDataTesting.m
View
9 Model/GBMethodData.m
@@ -64,9 +64,18 @@ - (NSArray *)formattedComponents {
[result addObject:[self formattedComponentWithValue:@" "]];
// Add the list of attributes.
+ __block BOOL isSetterOrGetter = NO;
[result addObject:[self formattedComponentWithValue:@"("]];
[self.methodAttributes enumerateObjectsUsingBlock:^(NSString *attribute, NSUInteger idx, BOOL *stop) {
[result addObject:[self formattedComponentWithValue:attribute]];
+ if ([attribute isEqualToString:@"setter"] || [attribute isEqualToString:@"getter"]) {
+ isSetterOrGetter = YES;
+ return;
+ }
+ if (isSetterOrGetter) {
+ if ([attribute isEqualToString:@"="]) return;
+ isSetterOrGetter = NO;
+ }
if (idx < [self.methodAttributes count]-1) {
[result addObject:[self formattedComponentWithValue:@","]];
[result addObject:[self formattedComponentWithValue:@" "]];
View
32 Testing/GBMethodDataTesting.m
@@ -160,6 +160,38 @@ - (void)testFormattedComponents_shouldReturnPointerPropertyComponents {
nil];
}
+- (void)testFormattedComponents_shouldCombineGetterAndSetterAttributes {
+ // setup
+ NSArray *attributes = [NSArray arrayWithObjects:@"readonly", @"getter", @"=", @"isName", @"setter", @"=", @"setName:", nil];
+ NSArray *components = [NSArray arrayWithObjects:@"NSString", @"*", @"name", nil];
+ GBMethodData *method = [GBMethodData propertyDataWithAttributes:attributes components:components];
+ // execute
+ NSArray *result = [method formattedComponents];
+ // verify: {@property}-{ }-{(}-{readonly}-{,}-{ }-{getter}-{=}-{isName}-{,}-{ }-{setter}-{=}-{setName:}-{)}-{ }-{NSString}-{ }-{*}-{name}
+ [self assertFormattedComponents:result match:
+ @"@property", 0, GBNULL,
+ @" ", 0, GBNULL,
+ @"(", 0, GBNULL,
+ @"readonly", 0, GBNULL,
+ @",", 0, GBNULL,
+ @" ", 0, GBNULL,
+ @"getter", 0, GBNULL,
+ @"=", 0, GBNULL,
+ @"isName", 0, GBNULL,
+ @",", 0, GBNULL,
+ @" ", 0, GBNULL,
+ @"setter", 0, GBNULL,
+ @"=", 0, GBNULL,
+ @"setName:", 0, GBNULL,
+ @")", 0, GBNULL,
+ @" ", 0, GBNULL,
+ @"NSString", 0, GBNULL,
+ @" ", 0, GBNULL,
+ @"*", 0, GBNULL,
+ @"name", 0, GBNULL,
+ nil];
+}
+
- (void)testFormattedComponents_shouldReturnSimpleInstanceMethodComponents {
// setup
NSArray *results = [NSArray arrayWithObjects:@"void", nil];

0 comments on commit c05364a

Please sign in to comment.