Whitespace cleanup.

This commit is contained in:
Alexander Ljungberg
2011-07-29 02:01:31 -04:00
parent 408baac91e
commit dd5d7e9979
+73 -73
View File
@@ -19,7 +19,7 @@
#import "AppController.h"
void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t numEvents,
void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t numEvents,
void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[])
{
AppController *ac = (AppController *)userData;
@@ -50,7 +50,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
growlDelegateRef = [[[PRHEmptyGrowlDelegate alloc] init] autorelease];
[GrowlApplicationBridge setGrowlDelegate:growlDelegateRef];
fm = [NSFileManager defaultManager];
modifiedXIBs = [NSMutableArray new];
ignoredFilePaths = [NSMutableArray new];
@@ -73,7 +73,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
_profilePath = @"";
}
}
return self;
}
@@ -88,14 +88,14 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
appStartedTimestamp = [NSDate date];
pathModificationDates = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"pathModificationDates"] mutableCopy];
lastEventId = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastEventId"];
NSBundle *bundle = [NSBundle mainBundle];
_iconInactive = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"xcodecapp-cocoa-icon-inactive" ofType:@"png"]];
_iconActive = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"xcodecapp-cocoa-icon-active" ofType:@"png"]];
[_iconActive setSize:NSMakeSize(14.0, 16.0)];
[_iconInactive setSize:NSMakeSize(14.0, 16.0)];
_statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[_statusItem setMenu:statusMenu];
[_statusItem setImage:_iconInactive];
@@ -147,9 +147,9 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
[defaults setObject:lastEventId forKey:@"lastEventId"];
[defaults setObject:pathModificationDates forKey:@"pathModificationDates"];
[defaults synchronize];
[self stopEventStream];
return NSTerminateNow;
}
@@ -194,18 +194,18 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
//Prepare the shell
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/bash"];
[task setLaunchPath: @"/bin/bash"];
NSArray *arguments;
NSString *successMsg;
if ([self isXIBFile:fullPath] || [self isObjJFile:fullPath])
{
if ([self isXIBFile:fullPath])
{
NSLog(@"running command nib2cib %@", fullPath);
//Create the nib2cib task
//Create the nib2cib task
arguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; nib2cib '%@';) 2>&1", _profilePath, fullPath],@"",nil];
successMsg = @"The XIB file has been converted";
@@ -220,23 +220,23 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
[NSString stringWithFormat:@"(%@; objj '%@' '%@' '%@';) 2>&1", _profilePath, parserPath, fullPath, shadowPath],@"",nil];
successMsg = @"The Objective-J file has been converted";
}
//Run the task and get the response
[task setArguments: arguments];
[task setStandardOutput:[NSPipe pipe]];
[task setStandardOutput:[NSPipe pipe]];
[_statusItem setTitle:@"..."];
[task launch];
[task waitUntilExit];
NSData *stdOut;
stdOut = [[[task standardOutput] fileHandleForReading] availableData];
NSString *response;
response = [[NSString alloc] initWithData:stdOut
encoding:NSUTF8StringEncoding];
NSLog(@"response was\n%@", response);
NSLog(@"response was\n%@", response);
[_statusItem setTitle:@""];
if ([task terminationStatus] == 0)
{
@@ -250,12 +250,12 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
isSticky:NO
clickContext:nil];
}
}
else
{
NSLog(@"Error in conversion: return message is %@", response);
//if (![GrowlApplicationBridge isGrowlRunning])
{
[errorList addObject:response];
@@ -287,39 +287,39 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
XCodeSupportProject = [NSURL URLWithString:XCodeSupportProjectName relativeToURL:XCodeSupportFolder];
XCodeSupportProjectSources = [NSURL URLWithString:@"Sources/" relativeToURL:XCodeSupportFolder];
XCodeSupportPBXPath = [NSString stringWithFormat:@"%@/project.pbxproj", [XCodeSupportProject path]];
//[fm removeItemAtURL:XCodeSupportFolder error:nil];
// create the template project if it doesn't exist
if (![fm fileExistsAtPath:[XCodeSupportFolder path]])
{
NSLog(@"XCode support folder created at: %@", [XCodeSupportProject path]);
[fm createDirectoryAtPath:[XCodeSupportProject path] withIntermediateDirectories:YES attributes:nil error:nil];
NSLog(@"Copying project.pbxproj from %@ to %@", XCodeTemplatePBXPath, [XCodeSupportProject path]);
[fm copyItemAtPath:XCodeTemplatePBXPath toPath:XCodeSupportPBXPath error:nil];
NSLog(@"Reading the content of the project.pbxproj");
NSMutableString *PBXContent = [NSMutableString stringWithContentsOfFile:XCodeSupportPBXPath encoding:NSUTF8StringEncoding error:nil];
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectName}"
withString:currentProjectName
options:NSCaseInsensitiveSearch
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectName}"
withString:currentProjectName
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [PBXContent length])];
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectRelativePath}"
[PBXContent replaceOccurrencesOfString:@"${CappuccinoProjectRelativePath}"
withString:@".."
options:NSCaseInsensitiveSearch
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [PBXContent length])];
[PBXContent writeToFile:XCodeSupportPBXPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
NSLog(@"PBX file adapted to the project");
NSLog(@"Creating source folder");
[fm createDirectoryAtPath:[XCodeSupportProjectSources path] withIntermediateDirectories:YES attributes:nil error:nil];
[NSThread detachNewThreadSelector:@selector(populateXCodeProject:)toTarget:self withObject:nil];
return NO;
}
}
return YES;
}
@@ -332,18 +332,18 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
priority:0
isSticky:NO
clickContext:nil];
[self handleFileModification:[NSString stringWithFormat:@"%@", [currentProjectURL path]] ignoreDate:YES];
NSArray *subdirs = [fm subpathsAtPath:[currentProjectURL path]];
for (NSString *p in subdirs)
[self handleFileModification:[NSString stringWithFormat:@"%@/%@", [currentProjectURL path], p] ignoreDate:YES];
[labelStatus setStringValue:@"XCodeCapp is running"];
[buttonOpenXCode setEnabled:YES];
[buttonStop setEnabled:YES];
[buttonStart setEnabled:NO];
[spinner setHidden:YES];
[GrowlApplicationBridge notifyWithTitle:[[currentProjectURL path] lastPathComponent]
description:@"Your project has been loaded successfully!"
notificationName:@"DefaultNotifications"
@@ -358,20 +358,20 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
{
NSMutableString *flattenedPath = [NSMutableString stringWithString:[aSourceURL path]];
NSLog(@"Flattened path is : %@", flattenedPath);
[flattenedPath replaceOccurrencesOfString:@"/"
[flattenedPath replaceOccurrencesOfString:@"/"
withString:@"_"
options:NSCaseInsensitiveSearch
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [[aSourceURL path] length])];
NSString *basename = [NSString stringWithFormat:@"%@.h", [[flattenedPath stringByDeletingPathExtension] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
return [NSURL URLWithString:basename relativeToURL:XCodeSupportProjectSources];
}
- (void)computeIgnoredPaths
{
NSString *ignorePath = [NSString stringWithFormat:@"%@/.xcodecapp-ignore", [currentProjectURL path]];
if (![fm fileExistsAtPath:ignorePath])
return;
@@ -384,37 +384,37 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
- (BOOL)isPathMatchingIgnoredPaths:(NSString*)aPath
{
BOOL isMatching = NO;
for (NSString *ignoredPath in ignoredFilePaths)
{
{
if ([ignoredPath isEqual:@""])
continue;
NSMutableString *regexp = [NSMutableString stringWithFormat:@"%@/%@", [currentProjectURL path], ignoredPath];
[regexp replaceOccurrencesOfString:@"/"
[regexp replaceOccurrencesOfString:@"/"
withString:@"\\/"
options:NSCaseInsensitiveSearch
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [regexp length])];
[regexp replaceOccurrencesOfString:@"."
[regexp replaceOccurrencesOfString:@"."
withString:@"\\."
options:NSCaseInsensitiveSearch
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [regexp length])];
[regexp replaceOccurrencesOfString:@"*"
[regexp replaceOccurrencesOfString:@"*"
withString:@".*"
options:NSCaseInsensitiveSearch
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [regexp length])];
NSPredicate *regextest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regexp];
if ([regextest evaluateWithObject:aPath])
{
isMatching = YES;
break;
}
}
return isMatching;
}
@@ -423,23 +423,23 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
#pragma mark Actions
- (IBAction)chooseFolder:(id)aSender
{
{
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseDirectories:YES];
[openPanel setCanCreateDirectories:YES];
[openPanel setPrompt:@"Choose Cappuccino project"];
[openPanel setCanChooseFiles:NO];
if ([openPanel runModal] != NSFileHandlingPanelOKButton)
return;
[spinner setHidden:NO];
[spinner startAnimation:nil];
currentProjectURL = [[openPanel URLs] objectAtIndex:0];
NSMutableString *tempName = [NSMutableString stringWithString:[[[openPanel URLs] objectAtIndex:0] lastPathComponent]];
[tempName replaceOccurrencesOfString:@" "
withString:@"_"
options:NSCaseInsensitiveSearch
@@ -448,13 +448,13 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
[self computeIgnoredPaths];
[self initializeEventStreamWithPath:[currentProjectURL path]];
BOOL isProjectReady = [self prepareXCodeSupportProject];
[labelPath setStringValue:[currentProjectURL path]];
[labelCurrentPath setHidden:NO];
[buttonStart setEnabled:NO];
if (isProjectReady)
{
[spinner setHidden:YES];
@@ -462,10 +462,10 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
[buttonOpenXCode setEnabled:YES];
[labelStatus setStringValue:@"XCodeCapp is running"];
}
else
[labelStatus setStringValue:@"XCodeCapp is loading project..."];
[_statusItem setImage:_iconActive];
}
@@ -488,7 +488,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
{
if (!currentProjectURL)
return;
NSLog(@"Open Xcode project at URL : '%@'", [XCodeSupportProject path]);
system([[NSString stringWithFormat:@"open \"%@\"", [XCodeSupportProject path]] UTF8String]);
}
@@ -512,7 +512,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
[mainWindow makeKeyAndOrderFront:nil];
return YES;
}
@@ -522,7 +522,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
return !currentProjectURL;
if ((aMenuItem == menuItemStop) || (aMenuItem == menuItemOpenXCode))
return !!currentProjectURL;
return YES;
}
@@ -555,8 +555,8 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n
if (height <= 0)
height = 16.0; // Ensure miniumum height is 16.0
return height;
}
@end