Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jan 04, 2013
@nerdsRob nerdsRob should fix issue #299 c89c984
Commits on Jan 05, 2013
@tomaz Merge pull request #300 from nerdsRob/feature/shared-property-method-…
…names

Fix for issue #299
ed85973
Showing with 23 additions and 2 deletions.
  1. +11 −0 Model/GBMethodData.h
  2. +12 −2 Model/GBMethodData.m
View
11 Model/GBMethodData.h
@@ -107,6 +107,9 @@ typedef NSUInteger GBMethodType;
*/
@property (readonly) NSString *methodSelector;
+/** Method return type that can be used for shared property/method names. */
+@property (readonly) NSString *methodReturnType;
+
/** Method selector including prefix.
@see methodSelector
@@ -188,4 +191,12 @@ typedef NSUInteger GBMethodType;
*/
- (NSArray *)formattedComponents;
+/** Returns the data type of the property.
+
+ This searches the `methodResultTypes` array and returns the property data type. This only applies to properties, returns `nil` otherwise!
+
+ @see methodResultTypes
+ */
+- (NSString *)propertyType;
+
@end
View
14 Model/GBMethodData.m
@@ -116,6 +116,7 @@ - (id)initWithType:(GBMethodType)type attributes:(NSArray *)attributes result:(N
_methodPrefix = [[self prefixFromAssignedData] retain];
_methodSelectorDelimiter = [[self selectorDelimiterFromAssignedData] retain];
_methodSelector = [[self selectorFromAssignedData] retain];
+ _methodReturnType = (NSString *)self.methodResultTypes.firstObject;
_prefixedMethodSelector = [[self prefixedSelectorFromAssignedData] retain];
}
return self;
@@ -279,6 +280,13 @@ - (NSString *)propertySetterSelector {
return result;
}
+- (NSString *)propertyType {
+ if (self.methodType != GBMethodTypeProperty) return nil;
+ NSString *result = (NSString *)self.methodResultTypes.firstObject;
+ if (!result) result = self.methodReturnType;
+ return result;
+}
+
- (NSString *)attributeValueForKey:(NSString *)key {
// Returns the value after equal sign for the given key (i.e. for attributes "getter", "=", "value", this would return "value"). Returns nil if either key isn't found or isn't followed by equal sign and/or a value.
__block NSString *result = nil;
@@ -317,10 +325,11 @@ - (BOOL)validateMergeWith:(GBMethodData *)source {
[NSException raise:@"Failed merging %@ to %@; method type doesn't match!", source, self];
}
- // We should allow if the getter or setter matches.
+ // We should allow if the getter or setter matches and if the getter name is shared to an instance method.
if ([propertyData.propertyGetterSelector isEqualToString:manualData.methodSelector]) return YES;
if ([propertyData.propertySetterSelector isEqualToString:manualData.methodSelector]) return YES;
- [NSException raise:@"Failed merging %@ to %@; getter or setter doesn't match", source, self];
+ if (![propertyData.propertyType isEqualToString:manualData.methodReturnType]) return YES;
+ [NSException raise:@"Failed merging %@ to %@; getter or setter doesn't match", source, self];
} else {
// If assertion from code below is present, it breaks cases where category declares a property which is also getter for a property from class declaration. See #184 https://github.com/tomaz/appledoc/issues/184 for details. I'm leaving the code commented for the moment to see if it also affects some other user (don't think so, but just in case).
//NSParameterAssert([source.methodSelector isEqualToString:self.methodSelector]);
@@ -386,6 +395,7 @@ - (BOOL)isProperty {
@synthesize methodResultTypes = _methodResultTypes;
@synthesize methodArguments = _methodArguments;
@synthesize methodSelector = _methodSelector;
+@synthesize methodReturnType = _methodReturnType;
@synthesize methodSelectorDelimiter = _methodSelectorDelimiter;
@synthesize methodPrefix = _methodPrefix;
@synthesize prefixedMethodSelector = _prefixedMethodSelector;

No commit comments for this range

Something went wrong with that request. Please try again.