Skip to content
Browse files

Reverted back to generic comment components regexes.

Though I did this but obviously not...
  • Loading branch information...
1 parent e9a9d63 commit 4295638cfe530a9a0fe5553143d6940d6a657fa2 @tomaz committed Feb 19, 2011
View
8 Application/GBCommentComponentsProvider.m
@@ -81,31 +81,31 @@ - (NSString *)remoteMemberCrossReferenceRegex:(BOOL)templated {
if (templated) {
GBRETURN_ON_DEMAND([self crossReferenceRegexForRegex:[self remoteMemberCrossReferenceRegex:NO]]);
} else {
- GBRETURN_ON_DEMAND(@"([+-]?)\\[(%@)\\s+(%@)\\]");
+ GBRETURN_ON_DEMAND(@"([+-]?)\\[(\\S+)\\s+(\\S+)\\]");
}
}
- (NSString *)localMemberCrossReferenceRegex:(BOOL)templated {
if (templated) {
GBRETURN_ON_DEMAND([self crossReferenceRegexForRegex:[self localMemberCrossReferenceRegex:NO]]);
} else {
- GBRETURN_ON_DEMAND(@"([+-]?)(%@)");
+ GBRETURN_ON_DEMAND(@"([+-]?)([^>,.;!?()\\s]+)");
}
}
- (NSString *)categoryCrossReferenceRegex:(BOOL)templated {
if (templated) {
GBRETURN_ON_DEMAND([self crossReferenceRegexForRegex:[self categoryCrossReferenceRegex:NO]]);
} else {
- GBRETURN_ON_DEMAND(@"(%@\\(%@\\))");
+ GBRETURN_ON_DEMAND(@"([^(][^>,.:;!?)\\s]+\\))");
}
}
- (NSString *)objectCrossReferenceRegex:(BOOL)templated {
if (templated) {
GBRETURN_ON_DEMAND([self crossReferenceRegexForRegex:[self objectCrossReferenceRegex:NO]]);
} else {
- GBRETURN_ON_DEMAND(@"(%@)");
+ GBRETURN_ON_DEMAND(@"([^>,.:;!?()\\s]+)");
}
}
View
60 Model/GBModelBase.h
@@ -107,66 +107,6 @@
@property (readonly) BOOL isTopLevelObject;
///---------------------------------------------------------------------------------------
-/// @name Cross reference detection helpers
-///---------------------------------------------------------------------------------------
-
-/** Returns the regex used for matching local cross references to the object.
-
- This is convenience method that either returns `localSimpleCrossRefRegex` or `localTemplatedCrossRefRegex`, based on the value of the templated parameter.
-
- @param templated If `YES`, `localTemplatedCrossRefRegex`, otherwise `localSimpleCrossRefRegex` is returned.
- @return Returns the regex used for matching the object.
- @see localSimpleCrossRefRegex
- @see localTemplatedCrossRefRegex
- @see remoteCrossRefRegex:
- */
-- (NSString *)localCrossRefRegex:(BOOL)templated;
-
-/** Returns the regex used for matching remote cross references to the object.
-
- This is convenience method that either returns `remoteSimpleCrossRefRegex` or `remoteTemplatedCrossRefRegex`, based on the value of the templated parameter.
-
- @param templated If `YES`, `remoteTemplatedCrossRefRegex`, otherwise `remoteSimpleCrossRefRegex` is returned.
- @return Returns the regex used for matching the object.
- @see remoteSimpleCrossRefRegex
- @see remoteTemplatedCrossRefRegex
- @see localCrossRefRegex:
- */
-- (NSString *)remoteCrossRefRegex:(BOOL)templated;
-
-/** Returns the regex used for matching local cross references to the object.
-
- It's up to client to setup this value!
-
- @see localCrossRefRegex:
- */
-@property (copy) NSString *localSimpleCrossRefRegex;
-
-/** Returns the regex used for matching local cross references to the object.
-
- It's up to client to setup this value!
-
- @see localCrossRefRegex:
- */
-@property (copy) NSString *localTemplatedCrossRefRegex;
-
-/** Returns the regex used for matching remote cross references to the object.
-
- It's up to client to setup this value!
-
- @see remoteCrossRefRegex:
- */
-@property (copy) NSString *remoteSimpleCrossRefRegex;
-
-/** Returns the regex used for matching remote cross references to the object.
-
- It's up to client to setup this value!
-
- @see remoteCrossRefRegex:
- */
-@property (copy) NSString *remoteTemplatedCrossRefRegex;
-
-///---------------------------------------------------------------------------------------
/// @name Output generation helpers
///---------------------------------------------------------------------------------------
View
14 Model/GBModelBase.m
@@ -88,16 +88,6 @@ - (NSArray *)sourceInfosSortedByName {
#pragma Helper methods
-- (NSString *)localCrossRefRegex:(BOOL)templated {
- if (templated) return self.localTemplatedCrossRefRegex;
- return self.localSimpleCrossRefRegex;
-}
-
-- (NSString *)remoteCrossRefRegex:(BOOL)templated {
- if (templated) return self.remoteTemplatedCrossRefRegex;
- return self.remoteSimpleCrossRefRegex;
-}
-
- (BOOL)isStaticDocument {
return NO;
}
@@ -111,10 +101,6 @@ - (BOOL)isTopLevelObject {
@synthesize comment;
@synthesize sourceInfos = _sourceInfos;
@synthesize parentObject;
-@synthesize localSimpleCrossRefRegex;
-@synthesize localTemplatedCrossRefRegex;
-@synthesize remoteSimpleCrossRefRegex;
-@synthesize remoteTemplatedCrossRefRegex;
@synthesize htmlLocalReference;
@synthesize htmlReferenceName;
View
58 Processing/GBProcessor.m
@@ -33,7 +33,6 @@ - (void)setupKnownObjectsFromStore;
- (void)mergeKnownCategoriesFromStore;
- (void)setupSuperclassForClass:(GBClassData *)class;
- (void)setupAdoptedProtocolsFromProvider:(GBAdoptedProtocolsProvider *)provider;
-- (void)setupCrossReferenceRegexForObject:(GBModelBase *)object;
- (void)validateCommentsForObjectAndMembers:(GBModelBase *)object;
- (BOOL)isCommentValid:(GBComment *)comment;
@@ -291,15 +290,12 @@ - (void)setupKnownObjectsFromStore {
for (GBClassData *class in self.store.classes) {
[self setupSuperclassForClass:class];
[self setupAdoptedProtocolsFromProvider:class.adoptedProtocols];
- [self setupCrossReferenceRegexForObject:class];
}
for (GBCategoryData *category in self.store.categories) {
[self setupAdoptedProtocolsFromProvider:category.adoptedProtocols];
- [self setupCrossReferenceRegexForObject:category];
}
for (GBProtocolData *protocol in self.store.protocols) {
[self setupAdoptedProtocolsFromProvider:protocol.adoptedProtocols];
- [self setupCrossReferenceRegexForObject:protocol];
}
}
@@ -327,60 +323,6 @@ - (void)setupAdoptedProtocolsFromProvider:(GBAdoptedProtocolsProvider *)provider
}
}
-- (void)setupCrossReferenceRegexForObject:(GBModelBase *)object {
- // Setups local and remote matching cross reference regexes for the given object and it's members (if the object is top level). These are later going to be used for matching object links within comment text!
- GBLogDebug(@"Assigning cross reference matchers for %@...", object);
- NSString *objectID = nil;
- if ([object isKindOfClass:[GBClassData class]]) {
- GBClassData *class = (GBClassData *)object;
- objectID = class.nameOfClass;
- NSString *simpleRegex = [self.settings.commentComponents objectCrossReferenceRegex:NO];
- NSString *templatedRegex = [self.settings.commentComponents objectCrossReferenceRegex:YES];
- object.localSimpleCrossRefRegex = [NSString stringWithFormat:simpleRegex, class.nameOfClass];
- object.localTemplatedCrossRefRegex = [NSString stringWithFormat:templatedRegex, class.nameOfClass];
- object.remoteSimpleCrossRefRegex = object.localSimpleCrossRefRegex;
- object.remoteTemplatedCrossRefRegex = object.localTemplatedCrossRefRegex;
- } else if ([object isKindOfClass:[GBCategoryData class]]) {
- GBCategoryData *category = (GBCategoryData *)object;
- objectID = category.idOfCategory;
- NSString *simpleRegex = [self.settings.commentComponents categoryCrossReferenceRegex:NO];
- NSString *templatedRegex = [self.settings.commentComponents categoryCrossReferenceRegex:YES];
- object.localSimpleCrossRefRegex = [NSString stringWithFormat:simpleRegex, category.nameOfClass, category.nameOfCategory];
- object.localTemplatedCrossRefRegex = [NSString stringWithFormat:templatedRegex, category.nameOfClass, category.nameOfCategory];
- object.remoteSimpleCrossRefRegex = object.localSimpleCrossRefRegex;
- object.remoteTemplatedCrossRefRegex = object.localTemplatedCrossRefRegex;
- } else if ([object isKindOfClass:[GBProtocolData class]]) {
- GBProtocolData *protocol = (GBProtocolData *)object;
- objectID = protocol.nameOfProtocol;
- NSString *simpleRegex = [self.settings.commentComponents objectCrossReferenceRegex:NO];
- NSString *templatedRegex = [self.settings.commentComponents objectCrossReferenceRegex:YES];
- object.localSimpleCrossRefRegex = [NSString stringWithFormat:simpleRegex, protocol.nameOfProtocol];
- object.localTemplatedCrossRefRegex = [NSString stringWithFormat:templatedRegex, protocol.nameOfProtocol];
- object.remoteSimpleCrossRefRegex = object.localSimpleCrossRefRegex;
- object.remoteTemplatedCrossRefRegex = object.localTemplatedCrossRefRegex;
- }
-
- // A bit of hacking to make sure categories are properly matched by regex... This should really be handled on the level of GBCommentComponentsProvider...
- objectID = [objectID stringByReplacingOccurrencesOfString:@"(" withString:@"\\("];
- objectID = [objectID stringByReplacingOccurrencesOfString:@")" withString:@"\\)"];
-
- // Process all methods.
- GBMethodsProvider *methods = [(id<GBObjectDataProviding>)object methods];
- if (methods) {
- for (GBMethodData *method in methods.methods) {
- GBLogDebug(@"Assigning cross reference matchers for %@...", method);
- NSString *localSimpleRegex = [self.settings.commentComponents localMemberCrossReferenceRegex:NO];
- NSString *localTemplatedRegex = [self.settings.commentComponents localMemberCrossReferenceRegex:YES];
- NSString *remoteSimpleRegex = [self.settings.commentComponents remoteMemberCrossReferenceRegex:NO];
- NSString *remoteTemplatedRegex = [self.settings.commentComponents remoteMemberCrossReferenceRegex:YES];
- method.localSimpleCrossRefRegex = [NSString stringWithFormat:localSimpleRegex, method.methodSelector];
- method.localTemplatedCrossRefRegex = [NSString stringWithFormat:localTemplatedRegex, method.methodSelector];
- method.remoteSimpleCrossRefRegex = [NSString stringWithFormat:remoteSimpleRegex, objectID, method.methodSelector];
- method.remoteTemplatedCrossRefRegex = [NSString stringWithFormat:remoteTemplatedRegex, objectID, method.methodSelector];
- }
- }
-}
-
- (void)mergeKnownCategoriesFromStore {
GBLogInfo(@"Merging known categories to classes...");
if (!self.settings.mergeCategoriesToClasses) return;
View
90 Testing/GBProcessor-CommentsTesting.m
@@ -24,96 +24,6 @@ - (GBStore *)storeWithMethodWithComment:(GBComment *)comment;
@implementation GBProcessorCommentsTesting
-#pragma mark Cross reference matchers processing
-
-- (void)testProcessObjectsFromStore_shouldAssignClassCrossRefsMatchers {
- // setup
- GBApplicationSettingsProvider *settings = [GBTestObjectsRegistry realSettingsProvider];
- GBProcessor *processor = [GBProcessor processorWithSettingsProvider:settings];
- GBMethodData *method1 = [GBTestObjectsRegistry instanceMethodWithNames:@"instMethod", nil];
- GBMethodData *method2 = [GBTestObjectsRegistry classMethodWithNames:@"clsMethod", nil];
- GBMethodData *method3 = [GBTestObjectsRegistry propertyMethodWithArgument:@"propMethod"];
- GBClassData *class = [GBTestObjectsRegistry classWithName:@"Class" methods:method1, method2, method3, nil];
- GBStore *store = [GBTestObjectsRegistry storeWithObjects:class, nil];
- // execute
- [processor processObjectsFromStore:store];
- // verify
- assertThat(class.localSimpleCrossRefRegex, is(@"(Class)"));
- assertThat(class.localTemplatedCrossRefRegex, is(@"<?(Class)>?"));
- assertThat(class.remoteSimpleCrossRefRegex, is(class.localSimpleCrossRefRegex));
- assertThat(class.remoteTemplatedCrossRefRegex, is(class.localTemplatedCrossRefRegex));
- assertThat(method1.localSimpleCrossRefRegex, is(@"([+-]?)(instMethod:)"));
- assertThat(method1.localTemplatedCrossRefRegex, is(@"<?([+-]?)(instMethod:)>?"));
- assertThat(method1.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Class)\\s+(instMethod:)\\]"));
- assertThat(method1.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Class)\\s+(instMethod:)\\]>?"));
- assertThat(method2.localSimpleCrossRefRegex, is(@"([+-]?)(clsMethod:)"));
- assertThat(method2.localTemplatedCrossRefRegex, is(@"<?([+-]?)(clsMethod:)>?"));
- assertThat(method2.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Class)\\s+(clsMethod:)\\]"));
- assertThat(method2.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Class)\\s+(clsMethod:)\\]>?"));
- assertThat(method3.localSimpleCrossRefRegex, is(@"([+-]?)(propMethod)"));
- assertThat(method3.localTemplatedCrossRefRegex, is(@"<?([+-]?)(propMethod)>?"));
- assertThat(method3.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Class)\\s+(propMethod)\\]"));
- assertThat(method3.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Class)\\s+(propMethod)\\]>?"));
-}
-
-- (void)testProcessObjectsFromStore_shouldAssignCategoryCrossRefsMatchers {
- // setup
- GBProcessor *processor = [GBProcessor processorWithSettingsProvider:[GBTestObjectsRegistry mockSettingsProvider]];
- GBMethodData *method1 = [GBTestObjectsRegistry instanceMethodWithNames:@"instMethod", nil];
- GBMethodData *method2 = [GBTestObjectsRegistry classMethodWithNames:@"clsMethod", nil];
- GBMethodData *method3 = [GBTestObjectsRegistry propertyMethodWithArgument:@"propMethod"];
- GBCategoryData *category = [GBTestObjectsRegistry categoryWithName:@"Category" className:@"Class" methods:method1, method2, method3, nil];
- GBStore *store = [GBTestObjectsRegistry storeWithObjects:category, nil];
- // execute
- [processor processObjectsFromStore:store];
- // verify
- assertThat(category.localSimpleCrossRefRegex, is(@"(Class\\(Category\\))"));
- assertThat(category.localTemplatedCrossRefRegex, is(@"<?(Class\\(Category\\))>?"));
- assertThat(category.remoteSimpleCrossRefRegex, is(category.localSimpleCrossRefRegex));
- assertThat(category.remoteTemplatedCrossRefRegex, is(category.localTemplatedCrossRefRegex));
- assertThat(method1.localSimpleCrossRefRegex, is(@"([+-]?)(instMethod:)"));
- assertThat(method1.localTemplatedCrossRefRegex, is(@"<?([+-]?)(instMethod:)>?"));
- assertThat(method1.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Class\\(Category\\))\\s+(instMethod:)\\]"));
- assertThat(method1.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Class\\(Category\\))\\s+(instMethod:)\\]>?"));
- assertThat(method2.localSimpleCrossRefRegex, is(@"([+-]?)(clsMethod:)"));
- assertThat(method2.localTemplatedCrossRefRegex, is(@"<?([+-]?)(clsMethod:)>?"));
- assertThat(method2.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Class\\(Category\\))\\s+(clsMethod:)\\]"));
- assertThat(method2.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Class\\(Category\\))\\s+(clsMethod:)\\]>?"));
- assertThat(method3.localSimpleCrossRefRegex, is(@"([+-]?)(propMethod)"));
- assertThat(method3.localTemplatedCrossRefRegex, is(@"<?([+-]?)(propMethod)>?"));
- assertThat(method3.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Class\\(Category\\))\\s+(propMethod)\\]"));
- assertThat(method3.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Class\\(Category\\))\\s+(propMethod)\\]>?"));
-}
-
-- (void)testProcessObjectsFromStore_shouldAssignProtocolCrossRefsMatchers {
- // setup
- GBProcessor *processor = [GBProcessor processorWithSettingsProvider:[GBTestObjectsRegistry mockSettingsProvider]];
- GBMethodData *method1 = [GBTestObjectsRegistry instanceMethodWithNames:@"instMethod", nil];
- GBMethodData *method2 = [GBTestObjectsRegistry classMethodWithNames:@"clsMethod", nil];
- GBMethodData *method3 = [GBTestObjectsRegistry propertyMethodWithArgument:@"propMethod"];
- GBProtocolData *protocol = [GBTestObjectsRegistry protocolWithName:@"Protocol" methods:method1, method2, method3, nil];
- GBStore *store = [GBTestObjectsRegistry storeWithObjects:protocol, nil];
- // execute
- [processor processObjectsFromStore:store];
- // verify
- assertThat(protocol.localSimpleCrossRefRegex, is(@"(Protocol)"));
- assertThat(protocol.localTemplatedCrossRefRegex, is(@"<?(Protocol)>?"));
- assertThat(protocol.remoteSimpleCrossRefRegex, is(protocol.localSimpleCrossRefRegex));
- assertThat(protocol.remoteTemplatedCrossRefRegex, is(protocol.localTemplatedCrossRefRegex));
- assertThat(method1.localSimpleCrossRefRegex, is(@"([+-]?)(instMethod:)"));
- assertThat(method1.localTemplatedCrossRefRegex, is(@"<?([+-]?)(instMethod:)>?"));
- assertThat(method1.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Protocol)\\s+(instMethod:)\\]"));
- assertThat(method1.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Protocol)\\s+(instMethod:)\\]>?"));
- assertThat(method2.localSimpleCrossRefRegex, is(@"([+-]?)(clsMethod:)"));
- assertThat(method2.localTemplatedCrossRefRegex, is(@"<?([+-]?)(clsMethod:)>?"));
- assertThat(method2.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Protocol)\\s+(clsMethod:)\\]"));
- assertThat(method2.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Protocol)\\s+(clsMethod:)\\]>?"));
- assertThat(method3.localSimpleCrossRefRegex, is(@"([+-]?)(propMethod)"));
- assertThat(method3.localTemplatedCrossRefRegex, is(@"<?([+-]?)(propMethod)>?"));
- assertThat(method3.remoteSimpleCrossRefRegex, is(@"([+-]?)\\[(Protocol)\\s+(propMethod)\\]"));
- assertThat(method3.remoteTemplatedCrossRefRegex, is(@"<?([+-]?)\\[(Protocol)\\s+(propMethod)\\]>?"));
-}
-
#pragma mark Classes comments processing
- (void)testProcessObjectsFromStore_shouldProcessClassComments {

0 comments on commit 4295638

Please sign in to comment.
Something went wrong with that request. Please try again.