Permalink
Browse files

Updated copied comments handling to use same pointer and only process…

… them once.
  • Loading branch information...
1 parent b7b92f8 commit 0a7021b0d15a30e6373205ce2cadb2ee1f0f469a @tomaz committed Feb 24, 2011
View
@@ -112,9 +112,19 @@
/** Specifies whether the comment is copied from another object or this is the original comment from source code.
This flag is used to ignore unknown cross references warnings for comments copied from another object.
+
+ @see isProcessed
*/
@property (assign) BOOL isCopied;
+/** Specifies whether the comment is already processed or not.
+
+ This is used mainly for better support of copied comments!
+
+ @see isCopied
+ */
+@property (assign) BOOL isProcessed;
+
/** Specifies whether the comment has short description or not.
@see hasLongDescription
View
@@ -73,6 +73,7 @@ - (BOOL)hasRelatedItems {
}
@synthesize isCopied;
+@synthesize isProcessed;
@synthesize sourceInfo;
@synthesize stringValue;
@@ -131,6 +131,7 @@ - (void)processComment:(GBComment *)comment withStore:(id)store {
- (void)processComment:(GBComment *)comment withContext:(id)context store:(id)store {
NSParameterAssert(comment != nil);
NSParameterAssert(store != nil);
+ if (comment.isProcessed) return;
GBLogDebug(@"Processing %@ found in %@...", comment, comment.sourceInfo.filename);
self.reservedShortDescriptionData = nil;
self.currentComment = comment;
@@ -147,6 +148,7 @@ - (void)processComment:(GBComment *)comment withContext:(id)context store:(id)st
blockRange.location += blockRange.length;
}
[self registerReservedShortDescriptionIfNecessary];
+ self.currentComment.isProcessed = YES;
}
- (BOOL)findCommentBlockInLines:(NSArray *)lines blockRange:(NSRange *)blockRange shortRange:(NSRange *)shortRange {
@@ -224,13 +224,8 @@ - (void)copyKnownDocumentationForMethod:(GBMethodData *)method {
GBMethodData *superMethod = [class.methods methodBySelector:method.methodSelector];
if (superMethod.comment) {
GBLogVerbose(@"Copying documentation for %@ from superclass %@...", method, class);
- GBComment *comment = [GBComment commentWithStringValue:superMethod.comment.stringValue];
- NSString *filename = method.prefferedSourceInfo.filename;
- NSString *superFilename = superMethod.comment.sourceInfo.filename;
- if (![filename isEqualToString:superFilename]) filename = [NSString stringWithFormat:@"%@, %@", superFilename, filename];
- comment.sourceInfo = [GBSourceInfo infoWithFilename:filename lineNumber:method.prefferedSourceInfo.lineNumber];
- comment.isCopied = YES;
- method.comment = comment;
+ superMethod.comment.isCopied = YES;
+ method.comment = superMethod.comment;
return;
}
class = class.superclass;
@@ -243,8 +238,8 @@ - (void)copyKnownDocumentationForMethod:(GBMethodData *)method {
GBMethodData *protocolMethod = [protocol.methods methodBySelector:method.methodSelector];
if (protocolMethod.comment) {
GBLogVerbose(@"Copying documentation for %@ from adopted protocol %@...", method, protocol);
- GBComment *comment = [GBComment commentWithStringValue:protocolMethod.comment.stringValue];
- method.comment = comment;
+ protocolMethod.comment.isCopied = YES;
+ method.comment = protocolMethod.comment;
return;
}
}
@@ -418,6 +418,19 @@ - (void)testProcessCommentWithContextStore_combinations_shouldRegisterWarningAft
[self assertComment:comment3 matchesShortDesc:@"Warning" longDesc:@"@warning Warning", nil];
}
+#pragma mark Miscellaneous handling
+
+- (void)testProcessCommentWithContextStore_misc_shouldSetIsProcessed {
+ // setup
+ GBStore *store = [GBTestObjectsRegistry store];
+ GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:[GBTestObjectsRegistry realSettingsProvider]];
+ GBComment *comment = [GBComment commentWithStringValue:@""];
+ // execute
+ [processor processComment:comment withContext:nil store:store];
+ // verify
+ assertThatBool(comment.isProcessed, equalToBool(YES));
+}
+
#pragma mark Private methods testing
- (void)testFindCommentBlockInLinesBlockRangeShortRange_shouldDetectSingleComponent {
@@ -38,9 +38,7 @@ - (void)testProcessObjectsFromStore_shouldCopyDocumentationFromSuperclassIfFindI
// execute
[processor processObjectsFromStore:store];
// verify
- assertThat(derived.comment, isNot(nil));
- assertThat(derived.comment, isNot(original.comment)); // We actually create a new comment object!
- assertThat([derived.comment stringValue], is([original.comment stringValue]));
+ assertThat(derived.comment, is(original.comment));
}
- (void)testProcessObjectsFromStore_shouldCopyDocumentationFromAnySuperclassIfFindIsYes {
@@ -55,7 +53,7 @@ - (void)testProcessObjectsFromStore_shouldCopyDocumentationFromAnySuperclassIfFi
// execute
[processor processObjectsFromStore:store];
// verify
- assertThat([derived.comment stringValue], is([original.comment stringValue]));
+ assertThat(derived.comment, is(original.comment));
}
- (void)testProcessObjectsFromStore_shouldNotCopyDocumentationFromSuperclassIfFindIsNo {
@@ -83,7 +81,7 @@ - (void)testProcessObjectsFromStore_shouldCopyDocumentationFromSuperclassEvenIfU
// execute
[processor processObjectsFromStore:store];
// verify
- assertThat(derived.comment, isNot(nil));
+ assertThat(derived.comment, is(original.comment));
}
#pragma mark Adopted protocols copying testing
@@ -99,9 +97,7 @@ - (void)testProcessObjectsFromStore_shouldCopyDocumentationFromAdoptedProtocolIf
// execute
[processor processObjectsFromStore:store];
// verify
- assertThat(derived.comment, isNot(nil));
- assertThat(derived.comment, isNot(original.comment)); // We actually create a new comment object!
- assertThat([derived.comment stringValue], is([original.comment stringValue]));
+ assertThat(derived.comment, is(original.comment));
}
- (void)testProcessObjectsFromStore_shouldCopyDocumentationFromAdoptedProtocolEvenIfUndocumentedObjectsShouldBeDeleted {
@@ -115,7 +111,7 @@ - (void)testProcessObjectsFromStore_shouldCopyDocumentationFromAdoptedProtocolEv
// execute
[processor processObjectsFromStore:store];
// verify
- assertThat(derived.comment, isNot(nil));
+ assertThat(derived.comment, is(original.comment));
}
#pragma mark Creation methods

0 comments on commit 0a7021b

Please sign in to comment.