Browse files

Fixed @name handling when followed by uncommented method. Closes #76.

The problem was in the way comments were being processed. If any comment contained @name, it was always used for creating a new task section, even if followed by uncommented method. However delimited comments:

	/// @name Something

Were not correctly detected as @name comments. The reason was in the regex being used for matching @name: it expected the @name at the start of the comment string. By changing the regex to match in any line, this works correctly. The downside is that section names spanning multiple lines are now ignored (you can delimit @name and first word by new line though). On the other hand, I don't think anybody uses section names in such a way, so it'll probably work just fine.

Proper solution would require using two regexes: one for matching @name before stripping delimiters and one for matching afterwards. Or alternatively strip delimiters immediately after recognizing a comment (at present this is all delayed until needed to make the tool as efficient as possible).
  • Loading branch information...
1 parent f5bdcab commit 90e35537cb20a95d57bdde8cdec284a79aafd1c1 @tomaz committed Mar 3, 2011
2 Application/GBCommentComponentsProvider.m
@@ -55,7 +55,7 @@ - (NSString *)bugSectionRegex {
#pragma mark Method specific detection
- (NSString *)methodGroupRegex {
- GBRETURN_ON_DEMAND(@"(?s:^\\s*\\Sname\\s+(.*))");
+ GBRETURN_ON_DEMAND(@"(?m:^\\s*\\Sname\\s+(.*))");
- (NSString *)parameterDescriptionRegex {
6 Testing/GBObjectiveCParser-SectionsParsingTesting.m
@@ -33,7 +33,7 @@ - (void)testParseObjectsFromString_shouldRegisterMethodsToLastSection {
[self assertMethod:[[section methods] objectAtIndex:1] matchesInstanceComponents:@"id", @"method2", nil];
-- (void)testParseObjectsFromString_shouldRegisterCommentedMethodsToLastSection {
+- (void)testParseObjectsFromString_shouldRegisterUncommentedMethodsToLastSection {
// setup
GBObjectiveCParser *parser = [GBObjectiveCParser parserWithSettingsProvider:[GBTestObjectsRegistry mockSettingsProvider]];
GBStore *store = [[GBStore alloc] init];
@@ -73,7 +73,7 @@ - (void)testParseObjectsFromString_shouldDetectSectionNameOnlyIfAtStartOfComment
assertThat([[sections objectAtIndex:0] sectionName], is(nil));
-- (void)testParseObjectsFromString_shouldIgnoreWhitespaceWithinSectionName {
+- (void)testParseObjectsFromString_shouldOnlyTakeSectionNameFromTheFirstLineString {
// setup
GBObjectiveCParser *parser = [GBObjectiveCParser parserWithSettingsProvider:[GBTestObjectsRegistry mockSettingsProvider]];
GBStore *store = [[GBStore alloc] init];
@@ -82,7 +82,7 @@ - (void)testParseObjectsFromString_shouldIgnoreWhitespaceWithinSectionName {
// verify
NSArray *sections = [[[[store classes] anyObject] methods] sections];
assertThatInteger([sections count], equalToInteger(1));
- assertThat([[sections objectAtIndex:0] sectionName], is(@"Section spanning multiple lines whoa!"));
+ assertThat([[sections objectAtIndex:0] sectionName], is(@"Section"));
- (void)testParseObjectsFromString_requiresDetectsSectionEvenIfFollowedByUncommentedMethod {

0 comments on commit 90e3553

Please sign in to comment.