Skip to content
Browse files

Fixed Xcode integration warnings and errors full paths handling. Fixes

…#105.

To allow Xcode properly open the file after selecting the warning in build list, it requires full path to it in the output, so I had to add full path to GBSourceInfo and use that when generating Xcode compatible log.

Note that I had appledoc crashed inside `[GBLog logFormatterForLogFormat]` when using standard log formats. The problem was with sending the given format instance `lowercaseString` however in case numerical value was used, the actual instance was `NSNumber`. To compensate, additional check was added to make sure the instance is indeed a `NSString`. Strange no one reported this as I didn't touch this code since last pushing to GitHub (or everyone was hardly waiting for Xcode compatibility and are now using that mode :).

Also added `xcode` log format option to help output and increased build number to 701.
  • Loading branch information...
1 parent a63d7b5 commit f26d1324c43ee5aa6e151988147956bb9830ae5f @tomaz tomaz committed
View
2 AppledocTests-Info.plist
@@ -17,6 +17,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>698</string>
+ <string>701</string>
</dict>
</plist>
View
2 Application/GBAppledocApplication.m
@@ -878,7 +878,7 @@ - (void)printHelp {
ddprintf(@"\n");
ddprintf(@"MISCELLANEOUS\n");
PRINT_USAGE(@" ", kGBArgLogFormat, @"<number>", @"Log format [0-3]");
- PRINT_USAGE(@" ", kGBArgVerbose, @"<number>", @"Log verbosity level [0-6]");
+ PRINT_USAGE(@" ", kGBArgVerbose, @"<value>", @"Log verbosity level [0-6,xcode]");
PRINT_USAGE(@" ", kGBArgVersion, @"", @"Display version and exit");
PRINT_USAGE(@" ", kGBArgHelp, @"", @"Display this help and exit");
ddprintf(@"\n");
View
2 Application/GBApplicationStringsProvider.m
@@ -138,7 +138,7 @@ - (NSDictionary *)appledocData {
result = [[NSMutableDictionary alloc] init];
[result setObject:@"appledoc" forKey:@"tool"];
[result setObject:@"2.0.4" forKey:@"version"];
- [result setObject:@"698" forKey:@"build"];
+ [result setObject:@"701" forKey:@"build"];
[result setObject:@"http://appledoc.gentlebytes.com" forKey:@"homepage"];
}
return result;
View
4 Common/GBLog.h
@@ -74,8 +74,8 @@ void GBLogUpdateResult(NSInteger result);
#define GBLogIsEnabled(level) ((kGBLogLevel & level) > 0)
// Macros that store given file/line info. Mostly used for better Xcode integration!
-#define GBLogXError(source,frmt,...) { [DDLog storeFilename:[source filename] line:[source lineNumber]]; GBLogError(frmt, ##__VA_ARGS__); }
-#define GBLogXWarn(source,frmt,...) { [DDLog storeFilename:[source filename] line:[source lineNumber]]; GBLogWarn(frmt, ##__VA_ARGS__); }
+#define GBLogXError(source,frmt,...) { [DDLog storeFilename:[source fullpath] line:[source lineNumber]]; GBLogError(frmt, ##__VA_ARGS__); }
+#define GBLogXWarn(source,frmt,...) { [DDLog storeFilename:[source fullpath] line:[source lineNumber]]; GBLogWarn(frmt, ##__VA_ARGS__); }
// Helper macros for logging exceptions. Note that we don't use formatting here as it would make the output unreadable
// in higher level log formats. The information is already verbose enough!
View
22 Common/GBLog.m
@@ -54,8 +54,10 @@ + (void)setLogLevelFromVerbose:(NSString *)verbosity {
}
+ (id<DDLogFormatter>)logFormatterForLogFormat:(NSString *)level {
- level = [level lowercaseString];
- if ([level isEqualToString:@"xcode"]) return [[[GBLogFormatXcodeFormatter alloc] init] autorelease];
+ if ([level isKindOfClass:[NSString class]]) {
+ level = [level lowercaseString];
+ if ([level isEqualToString:@"xcode"]) return [[[GBLogFormatXcodeFormatter alloc] init] autorelease];
+ }
NSInteger value = [level integerValue];
if (value < 0) value = 0;
@@ -163,14 +165,14 @@ - (NSString *)formatLogMessage:(DDLogMessage *)m {
if (m->originalFilename) {
NSString *level = nil;
switch (m->logFlag) {
- case LOG_FLAG_FATAL: level = @"fatal";
- case LOG_FLAG_ERROR: level = @"error";
- case LOG_FLAG_WARN: level = @"warning";
- case LOG_FLAG_NORMAL: level = @"normal";
- case LOG_FLAG_INFO: level = @"info";
- case LOG_FLAG_VERBOSE: level = @"verbose";
- case LOG_FLAG_DEBUG: level = @"debug";
- default: level = @"unknown";
+ case LOG_FLAG_FATAL: level = @"fatal"; break;
+ case LOG_FLAG_ERROR: level = @"error"; break;
+ case LOG_FLAG_WARN: level = @"warning"; break;
+ case LOG_FLAG_NORMAL: level = @"normal"; break;
+ case LOG_FLAG_INFO: level = @"info"; break;
+ case LOG_FLAG_VERBOSE: level = @"verbose"; break;
+ case LOG_FLAG_DEBUG: level = @"debug"; break;
+ default: level = @"unknown"; break;
}
return [NSString stringWithFormat:@"%@:%u: %@: %@", m->originalFilename, m->originalLine, level, GBLogMessage(m)];
}
View
2 Model/GBDocumentData.m
@@ -29,7 +29,7 @@ - (id)initWithContents:(NSString *)contents path:(NSString *)path {
GBLogDebug(@"Initializing document with contents %@...", [contents normalizedDescription]);
self = [super init];
if (self) {
- GBSourceInfo *info = [GBSourceInfo infoWithFilename:[path lastPathComponent] lineNumber:1];
+ GBSourceInfo *info = [GBSourceInfo infoWithFilename:path lineNumber:1];
[self registerSourceInfo:info];
self.nameOfDocument = [path lastPathComponent];
self.pathOfDocument = path;
View
8 Model/GBSourceInfo.h
@@ -20,7 +20,7 @@
/** Returns a new autoreleased `GBSourceInfo` with the given values.
- @param filename The name of the file without path.
+ @param filename The name of the file including full path.
@param lineNumber Line number within the file.
@return Returns autoreleased object.
@exception NSException Thrown if the given filename is `nil` or empty string.
@@ -42,6 +42,12 @@
*/
- (NSComparisonResult)compare:(GBSourceInfo *)data;
+/** Full path to the file name.
+
+ @see filename
+ */
+@property (readonly, copy) NSString *fullpath;
+
/** The name of the file, without path.
@see lineNumber
View
5 Model/GBSourceInfo.m
@@ -10,6 +10,7 @@
@interface GBSourceInfo ()
+@property (readwrite, copy) NSString *fullpath;
@property (readwrite, copy) NSString *filename;
@property (readwrite, assign) NSUInteger lineNumber;
@@ -25,7 +26,8 @@ + (id)infoWithFilename:(NSString *)filename lineNumber:(NSUInteger)lineNumber {
NSParameterAssert(filename != nil);
NSParameterAssert([filename length] > 0);
GBSourceInfo *result = [[[GBSourceInfo alloc] init] autorelease];
- result.filename = filename;
+ result.fullpath = [filename stringByStandardizingPath];
+ result.filename = [filename lastPathComponent];
result.lineNumber = lineNumber;
return result;
}
@@ -49,6 +51,7 @@ - (NSString *)description {
#pragma mark Properties
+@synthesize fullpath;
@synthesize filename;
@synthesize lineNumber;
View
2 Parsing/GBParser.m
@@ -71,7 +71,7 @@ - (void)parseObjectsFromPaths:(NSArray *)paths toStore:(id)store {
return;
}
- [self.objectiveCParser parseObjectsFromString:contents sourceFile:[path lastPathComponent] toStore:self.store];
+ [self.objectiveCParser parseObjectsFromString:contents sourceFile:path toStore:self.store];
self.numberOfParsedFiles++;
}];
}
View
2 Parsing/GBTokenizer.m
@@ -61,7 +61,7 @@ - (id)initWithSourceTokenizer:(PKTokenizer *)tokenizer filename:(NSString *)file
self.tokenIndex = 0;
self.lastCommentBuilder = [NSMutableString string];
self.previousCommentBuilder = [NSMutableString string];
- self.filename = [filename lastPathComponent];
+ self.filename = filename;
self.input = tokenizer.string;
self.tokens = [self allTokensFromTokenizer:tokenizer];
[self consumeComments];
View
2 Processing/GBCommentsProcessor.m
@@ -182,7 +182,7 @@ - (BOOL)findCommentBlockInLines:(NSArray *)lines blockRange:(NSRange *)blockRang
- (void)processCommentBlockInLines:(NSArray *)lines blockRange:(NSRange)blockRange shortRange:(NSRange)shortRange {
// The given range is guaranteed to point to actual block within the lines array, so we only need to determine the kind of block and how to handle it. We only need to handle short description based on settings if this is first block within the comment.
- NSString *filename = self.currentComment.sourceInfo.filename;
+ NSString *filename = self.currentComment.sourceInfo.fullpath;
NSUInteger lineNumber = self.currentComment.sourceInfo.lineNumber + blockRange.location;
self.currentSourceInfo = [GBSourceInfo infoWithFilename:filename ? filename : @"unknownfile" lineNumber:lineNumber];

0 comments on commit f26d132

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