mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-27 22:17:03 +00:00
Merge branch 'refs/heads/master' into new-CFError-CPError
This commit is contained in:
+32
-7
@@ -71,6 +71,8 @@ var CPComboBoxTextSubview = @"text",
|
||||
BOOL _forceSelection;
|
||||
BOOL _hasVerticalScroller;
|
||||
CPString _selectedStringValue;
|
||||
CGSize _intercellSpacing;
|
||||
float _itemHeight;
|
||||
BOOL _popUpButtonCausedResign;
|
||||
}
|
||||
|
||||
@@ -140,7 +142,9 @@ var CPComboBoxTextSubview = @"text",
|
||||
return;
|
||||
|
||||
_hasVerticalScroller = flag;
|
||||
[[_listDelegate scrollView] setHasVerticalScroller:flag];
|
||||
|
||||
if (_listDelegate)
|
||||
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
|
||||
}
|
||||
|
||||
- (CGSize)intercellSpacing
|
||||
@@ -150,7 +154,13 @@ var CPComboBoxTextSubview = @"text",
|
||||
|
||||
- (void)setIntercellSpacing:(CGSize)aSize
|
||||
{
|
||||
[[_listDelegate tableView] setIntercellSpacing:aSize];
|
||||
if (_intercellSpacing && CGSizeEqualToSize(aSize, _intercellSpacing))
|
||||
return;
|
||||
|
||||
_intercellSpacing = aSize;
|
||||
|
||||
if (_listDelegate)
|
||||
[[_listDelegate tableView] setIntercellSpacing:_intercellSpacing];
|
||||
}
|
||||
|
||||
- (BOOL)isButtonBordered
|
||||
@@ -173,10 +183,18 @@ var CPComboBoxTextSubview = @"text",
|
||||
|
||||
- (void)setItemHeight:(float)itemHeight
|
||||
{
|
||||
[[_listDelegate tableView] setRowHeight:itemHeight];
|
||||
if (itemHeight === _itemHeight)
|
||||
return;
|
||||
|
||||
// FIXME: This shouldn't be necessary, but CPTableView does not tile after setRowHeight
|
||||
[[_listDelegate tableView] reloadData];
|
||||
_itemHeight = itemHeight;
|
||||
|
||||
if (_listDelegate)
|
||||
{
|
||||
[[_listDelegate tableView] setRowHeight:_itemHeight];
|
||||
|
||||
// FIXME: This shouldn't be necessary, but CPTableView does not tile after setRowHeight
|
||||
[[_listDelegate tableView] reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
- (int)numberOfVisibleItems
|
||||
@@ -451,6 +469,9 @@ var CPComboBoxTextSubview = @"text",
|
||||
// Apply our text style to the list
|
||||
[_listDelegate setFont:[self font]];
|
||||
[_listDelegate setAlignment:[self alignment]];
|
||||
[[_listDelegate scrollView] setHasVerticalScroller:_hasVerticalScroller];
|
||||
[[_listDelegate tableView] setIntercellSpacing:_intercellSpacing];
|
||||
[[_listDelegate tableView] setRowHeight:_itemHeight];
|
||||
}
|
||||
|
||||
- (int)indexOfItemWithObjectValue:(id)anObject
|
||||
@@ -842,13 +863,17 @@ var CPComboBoxTextSubview = @"text",
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
[super setFont:aFont];
|
||||
[_listDelegate setFont:aFont];
|
||||
|
||||
if (_listDelegate)
|
||||
[_listDelegate setFont:aFont];
|
||||
}
|
||||
|
||||
- (void)setAlignment:(CPTextAlignment)alignment
|
||||
{
|
||||
[super setAlignment:alignment];
|
||||
[_listDelegate setAlignment:alignment];
|
||||
|
||||
if (_listDelegate)
|
||||
[_listDelegate setAlignment:alignment];
|
||||
}
|
||||
|
||||
#pragma mark Pop Up Button Layout
|
||||
|
||||
@@ -229,7 +229,7 @@ var ListColumnIdentifier = @"1";
|
||||
|
||||
[self listWillPopUp];
|
||||
|
||||
[_panel orderFront:nil];
|
||||
[[aView window] addChildWindow:_panel ordered:CPWindowAbove];
|
||||
}
|
||||
|
||||
#pragma mark Setting Display Attributes
|
||||
|
||||
@@ -68,6 +68,8 @@ with (window)
|
||||
// runs the objj repl or file provided in args
|
||||
exports.run = function(args)
|
||||
{
|
||||
var multipleFiles = false;
|
||||
|
||||
if (args)
|
||||
{
|
||||
// we expect args to be in the format:
|
||||
@@ -79,27 +81,82 @@ exports.run = function(args)
|
||||
// copy the args since we're going to modify them
|
||||
var argv = args.slice(1);
|
||||
|
||||
if (argv[0] === "--version")
|
||||
if (argv[0] === "--version" || argv[0] === "-v")
|
||||
{
|
||||
print(exports.fullVersionString());
|
||||
return;
|
||||
}
|
||||
|
||||
while (argv.length && argv[0].indexOf('-I') === 0)
|
||||
OBJJ_INCLUDE_PATHS.unshift.apply(OBJJ_INCLUDE_PATHS, argv.shift().substr(2).split(':'));
|
||||
if (argv[0] === "--help" || argv[0] === "-h")
|
||||
{
|
||||
print("Usage (objj): " + args[0] + " [options] [--] files...");
|
||||
print(" -v, --version print the current version of objj");
|
||||
print(" -I, --objj-include-paths include a specific framework paths")
|
||||
print(" -h, --help print this help");
|
||||
print(" -m, --multifiles launch objj on several files")
|
||||
return;
|
||||
}
|
||||
|
||||
while (argv.length && argv[0].indexOf('-') === 0)
|
||||
{
|
||||
switch (argv[0])
|
||||
{
|
||||
case "-I":
|
||||
argv.shift();
|
||||
OBJJ_INCLUDE_PATHS.unshift.apply(OBJJ_INCLUDE_PATHS, argv.shift().split(":"));
|
||||
break;
|
||||
|
||||
case "-m":
|
||||
argv.shift();
|
||||
multipleFiles = true;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argv && argv.length > 0)
|
||||
{
|
||||
var arg0 = argv.shift();
|
||||
var mainFilePath = FILE.canonical(arg0);
|
||||
var endCommand = false;
|
||||
|
||||
exports.make_narwhal_factory(mainFilePath)(require, { }, module, system, print);
|
||||
while (argv.length > 0)
|
||||
{
|
||||
var arg0 = argv.shift();
|
||||
var mainFilePath = FILE.canonical(arg0);
|
||||
|
||||
if (typeof main === "function")
|
||||
main([arg0].concat(argv));
|
||||
if (multipleFiles)
|
||||
{
|
||||
// This is needed to process every files passed in args
|
||||
// Otherwise it would stop when an error is raised or we would like to objj the other given files
|
||||
try
|
||||
{
|
||||
exports.make_narwhal_factory(mainFilePath)(require, { }, module, system, print);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
print("\n" + e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exports.make_narwhal_factory(mainFilePath)(require, { }, module, system, print);
|
||||
}
|
||||
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
if (typeof main === "function")
|
||||
{
|
||||
main([arg0].concat(argv));
|
||||
endCommand = true;
|
||||
}
|
||||
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
|
||||
if (!multipleFiles || endCommand)
|
||||
break;
|
||||
|
||||
ObjectiveJ.Executable.resetCachedFileExecutableSearchers();
|
||||
ObjectiveJ.StaticResource.resetRootResources();
|
||||
ObjectiveJ.FileExecutable.resetFileExecutables();
|
||||
objj_resetRegisterClasses();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -35,7 +35,12 @@ function BundleTask(aName, anApplication)
|
||||
{
|
||||
Task.apply(this, arguments);
|
||||
|
||||
this.setEnvironments([environment.Browser, environment.CommonJS]);
|
||||
var ignoreCommonJS = system.env["CAPP_IGNORE_COMMONJS_ENV"];
|
||||
|
||||
if (ignoreCommonJS && ignoreCommonJS.toLowerCase() == "no" || ignoreCommonJS == "1")
|
||||
this.setEnvironments([environment.Browser]);
|
||||
else
|
||||
this.setEnvironments([environment.Browser, environment.CommonJS]);
|
||||
|
||||
this._author = null;
|
||||
this._email = null;
|
||||
|
||||
@@ -29,6 +29,15 @@ function cleanup() {
|
||||
|
||||
status = OS.system(["flatten", "-f", "ToolsTestApp", "FlattenTestApp"].map(OS.enquote).join(" ") + " > /dev/null");
|
||||
[self assert:0 equals:status message:"flatten failed"];
|
||||
|
||||
status = OS.system(["objj", "ToolsTestApp/AppController.j"]);
|
||||
[self assert:0 equals:status message:"objj failed"];
|
||||
|
||||
status = OS.system(["objj", "-m", "ToolsTestApp/AppController.j", "ToolsTestApp/AppController.j"]);
|
||||
[self assert:0 equals:status message:"objj failed with several files"];
|
||||
|
||||
status = OS.system(["objj", "-I", "ToolsTestApp/Frameworks", "ToolsTestApp/AppController.j"]);
|
||||
[self assert:0 equals:status message:"objj failed with options -I"];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
|
||||
@@ -138,21 +138,23 @@ AppController *SharedAppControllerInstance = nil;
|
||||
- (void)registerDefaultPreferences
|
||||
{
|
||||
NSDictionary *appDefaults = @{
|
||||
kDefaultLastEventId: [NSNumber numberWithUnsignedLongLong:kFSEventStreamEventIdSinceNow],
|
||||
kDefaultFirstLaunch: @YES,
|
||||
kDefaultFirstLaunchVersion: @2.0,
|
||||
kDefaultXCCAPIMode: [NSNumber numberWithInt:kXCCAPIModeAuto],
|
||||
kDefaultXCCReactToInodeMod: @YES,
|
||||
kDefaultXCCReopenLastProject: @YES,
|
||||
kDefaultXCCAutoOpenErrorsPanelOnErrors: @YES,
|
||||
kDefaultXCCAutoOpenErrorsPanelOnCappLint: @YES,
|
||||
kDefaultXCCAutoShowNotificationOnErrors: @YES,
|
||||
kDefaultXCCAutoShowNotificationOnCappLint: @YES,
|
||||
kDefaultXCCProjectHistory: [NSArray new],
|
||||
kDefaultMaxRecentProjects: @20,
|
||||
kDefaultLogLevel: [NSNumber numberWithInt:LOG_LEVEL_WARN],
|
||||
kDefaultAutoOpenXcodeProject: @YES,
|
||||
kDefaultUseSymlinkWhenCreatingProject: @YES
|
||||
kDefaultLastEventId: [NSNumber numberWithUnsignedLongLong:kFSEventStreamEventIdSinceNow],
|
||||
kDefaultFirstLaunch: @YES,
|
||||
kDefaultFirstLaunchVersion: @2.0,
|
||||
kDefaultXCCAPIMode: [NSNumber numberWithInt:kXCCAPIModeAuto],
|
||||
kDefaultXCCReactToInodeMod: @YES,
|
||||
kDefaultXCCReopenLastProject: @YES,
|
||||
kDefaultXCCAutoOpenErrorsPanelOnErrors: @YES,
|
||||
kDefaultXCCAutoOpenErrorsPanelOnCappLint: @YES,
|
||||
kDefaultXCCAutoShowNotificationOnErrors: @YES,
|
||||
kDefaultXCCAutoShowNotificationOnCappLint: @YES,
|
||||
kDefaultXCCProjectHistory: [NSArray new],
|
||||
kDefaultMaxRecentProjects: @20,
|
||||
kDefaultLogLevel: [NSNumber numberWithInt:LOG_LEVEL_WARN],
|
||||
kDefaultAutoOpenXcodeProject: @YES,
|
||||
kDefaultUseSymlinkWhenCreatingProject: @YES,
|
||||
kDefaultXCCUseDebugFrameworkWithObjj: @YES,
|
||||
kDefaultXCCShouldProcessObjj: @YES
|
||||
};
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.1</string>
|
||||
<string>3.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>3.1</string>
|
||||
<string>3.2</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSUIElement</key>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
NSDictionary *info = @{ @"projectId":self.projectId, @"path":self.sourcePath };
|
||||
NSDictionary *info = @{ @"projectId":self.projectId, @"path":self.sourcePath};
|
||||
[center postNotificationName:XCCConversionDidStartNotification object:self userInfo:info];
|
||||
|
||||
DDLogVerbose(@"Conversion started: %@", self.sourcePath);
|
||||
@@ -74,7 +74,7 @@
|
||||
self.xcc.parserPath,
|
||||
self.projectPath,
|
||||
self.sourcePath
|
||||
];
|
||||
];
|
||||
|
||||
notificationTitle = @"Objective-J source processed";
|
||||
}
|
||||
@@ -84,21 +84,21 @@
|
||||
return;
|
||||
|
||||
[self.xcc performSelectorOnMainThread:@selector(computeIgnoredPaths) withObject:nil waitUntilDone:NO];
|
||||
|
||||
|
||||
notificationTitle = @"Parsed .xcodecapp-ignore";
|
||||
notificationMessage = @"Ignored paths updated";
|
||||
}
|
||||
|
||||
// Run the task and get the response if needed
|
||||
NSInteger status = 0;
|
||||
|
||||
|
||||
if (arguments)
|
||||
{
|
||||
if (self.isCancelled)
|
||||
return;
|
||||
|
||||
DDLogVerbose(@"Running processing task: %@", launchPath);
|
||||
|
||||
|
||||
NSDictionary *taskResult = [self.xcc runTaskWithLaunchPath:launchPath
|
||||
arguments:arguments
|
||||
returnType:kTaskReturnTypeAny];
|
||||
@@ -120,7 +120,7 @@
|
||||
|
||||
notificationTitle = @"Error converting xib";
|
||||
NSString *message = [NSString stringWithFormat:@"%@\n%@", self.sourcePath.lastPathComponent, response];
|
||||
|
||||
|
||||
NSDictionary *info =
|
||||
@{
|
||||
@"projectId":self.projectId,
|
||||
@@ -131,7 +131,7 @@
|
||||
|
||||
if (self.isCancelled)
|
||||
return;
|
||||
|
||||
|
||||
[center postNotificationName:XCCConversionDidGenerateErrorNotification object:self userInfo:info];
|
||||
}
|
||||
else
|
||||
@@ -152,22 +152,31 @@
|
||||
[self postErrorNotificationForPath:self.sourcePath line:0 message:response status:status];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([self.xcc shouldShowErrorNotification])
|
||||
[self notifyUserWithTitle:notificationTitle message:notificationMessage];
|
||||
}
|
||||
else if (!self.xcc.isLoadingProject)
|
||||
{
|
||||
BOOL showFinalNotification = YES;
|
||||
BOOL showFinalNotification = NO;
|
||||
|
||||
// At this point, we should only detect warnings
|
||||
if ([self.xcc shouldProcessWithObjjWarnings])
|
||||
{
|
||||
showFinalNotification = [self.xcc checkObjjWarningsForPath:[NSArray arrayWithObject:self.sourcePath]];
|
||||
[self.xcc showObjjWarnings];
|
||||
}
|
||||
else
|
||||
{
|
||||
showFinalNotification = YES;
|
||||
}
|
||||
|
||||
if ([self.xcc shouldProcessWithCappLint])
|
||||
{
|
||||
showFinalNotification = [self.xcc checkCappLintForPath:[NSArray arrayWithObject:self.sourcePath]];
|
||||
|
||||
if (!showFinalNotification)
|
||||
[self.xcc showCappLintErrors];
|
||||
showFinalNotification = [self.xcc checkCappLintForPath:[NSArray arrayWithObject:self.sourcePath]] && showFinalNotification;
|
||||
[self.xcc showCappLintWarnings];
|
||||
}
|
||||
|
||||
|
||||
if (showFinalNotification)
|
||||
[self notifyUserWithTitle:notificationTitle message:notificationMessage];
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ extern NSString * const kDefaultXCCAutoOpenErrorsPanelOnErrors;
|
||||
extern NSString * const kDefaultXCCAutoOpenErrorsPanelOnCappLint;
|
||||
extern NSString * const kDefaultXCCAutoShowNotificationOnErrors;
|
||||
extern NSString * const kDefaultXCCAutoShowNotificationOnCappLint;
|
||||
extern NSString * const kDefaultXCCUseDebugFrameworkWithObjj;
|
||||
extern NSString * const kDefaultXCCShouldProcessObjj;
|
||||
extern NSString * const kDefaultXCCProjectHistory;
|
||||
extern NSString * const kDefaultLastOpenedPath;
|
||||
extern NSString * const kDefaultPathModificationDates;
|
||||
|
||||
@@ -19,6 +19,8 @@ NSString * const kDefaultXCCAutoOpenErrorsPanelOnErrors = @"XCCAutoOpenErrorsPan
|
||||
NSString * const kDefaultXCCAutoOpenErrorsPanelOnCappLint = @"XCCAutoOpenErrorsPanelOnCappLint";
|
||||
NSString * const kDefaultXCCAutoShowNotificationOnErrors = @"XCCAutoOpenShowNotificationErrors";
|
||||
NSString * const kDefaultXCCAutoShowNotificationOnCappLint = @"XCCAutoShowNotificationOnCappLint";
|
||||
NSString * const kDefaultXCCUseDebugFrameworkWithObjj = @"XCCUseDebugFrameworkWithObjj";
|
||||
NSString * const kDefaultXCCShouldProcessObjj = @"XCCShouldProcessObjj";
|
||||
NSString * const kDefaultXCCProjectHistory = @"XCCProjectHistory";
|
||||
NSString * const kDefaultLastOpenedPath = @"LastOpenedPath";
|
||||
NSString * const kDefaultPathModificationDates = @"pathModificationDates";
|
||||
@@ -26,4 +28,4 @@ NSString * const kDefaultMaxRecentProjects = @"maxRecentProjects";
|
||||
NSString * const kDefaultLogLevel = @"logLevel";
|
||||
NSString * const kDefaultAutoOpenXcodeProject = @"autoOpenXcodeProject";
|
||||
NSString * const kDefaultUseSymlinkWhenCreatingProject = @"useSymlinkWhenCreatingProject";
|
||||
NSString * const kDefaultUpdateCappuccinoWithLastVersionOfMasterBranch = @"updateCappuccinoWithLastVersionOfMasterBranch";
|
||||
NSString * const kDefaultUpdateCappuccinoWithLastVersionOfMasterBranch = @"updateCappuccinoWithLastVersionOfMasterBranch";
|
||||
@@ -156,9 +156,14 @@ extern NSString * const XCCCappLintDidEndNotification;
|
||||
|
||||
- (NSDictionary*)createProject:(NSString*)aPath;
|
||||
|
||||
- (void)showCappLintWarnings;
|
||||
- (void)showObjjWarnings;
|
||||
|
||||
- (BOOL)shouldProcessWithCappLint;
|
||||
- (BOOL)checkCappLintForPath:(NSArray*)paths;
|
||||
- (void)showCappLintErrors;
|
||||
|
||||
- (BOOL)shouldProcessWithObjjWarnings;
|
||||
- (BOOL)checkObjjWarningsForPath:(NSArray*)paths;
|
||||
|
||||
- (void)updateCappuccino;
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ static NSArray *XCCDefaultIgnoredPathPredicates = nil;
|
||||
|
||||
NSString * const XCCCappLintDidStartNotification = @"XCCCappLintDidStartNotification";
|
||||
NSString * const XCCCappLintDidEndNotification = @"XCCCappLintDidEndNotification";
|
||||
NSString * const XCCObjjDidStartNotification = @"XCCObjjDidStartNotification";
|
||||
NSString * const XCCObjjDidEndNotification = @"XCCObjjDidEndNotification";
|
||||
|
||||
@interface XcodeCapp ()
|
||||
|
||||
@@ -1694,6 +1696,13 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
|| [defaults boolForKey:kDefaultXCCAutoShowNotificationOnCappLint];
|
||||
}
|
||||
|
||||
- (BOOL)shouldProcessWithObjjWarnings
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
return ([defaults boolForKey:kDefaultXCCAutoOpenErrorsPanelOnErrors] || [defaults boolForKey:kDefaultXCCAutoShowNotificationOnErrors]) && [defaults boolForKey:kDefaultXCCShouldProcessObjj];
|
||||
}
|
||||
|
||||
- (void)showErrors
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
@@ -1704,41 +1713,96 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showCappLintErrors
|
||||
- (void)showCappLintWarnings
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
if ([defaults boolForKey:kDefaultXCCAutoOpenErrorsPanelOnCappLint] && self.errorList.count)
|
||||
NSUInteger numberError = [self.errorList count];
|
||||
NSDictionary *firstError;
|
||||
NSUInteger i = 0;
|
||||
|
||||
for (i = 0; i < numberError; i++)
|
||||
{
|
||||
NSDictionary *dict = [self.errorList objectAtIndex:i];
|
||||
|
||||
if ([[dict valueForKey:@"type"] isEqualToString: @"capp_lint"])
|
||||
{
|
||||
firstError = dict;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ([defaults boolForKey:kDefaultXCCAutoOpenErrorsPanelOnCappLint] && firstError)
|
||||
[self openErrorsPanel:self];
|
||||
|
||||
if ([defaults boolForKey:kDefaultXCCAutoShowNotificationOnCappLint])
|
||||
if ([defaults boolForKey:kDefaultXCCAutoShowNotificationOnCappLint] && firstError)
|
||||
{
|
||||
NSUInteger numberError = [self.errorList count];
|
||||
NSDictionary *error = [self.errorList objectAtIndex:0];
|
||||
NSString *filename = [error objectForKey:@"path"];
|
||||
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInteger:self.projectId] , @"projectId",
|
||||
@"Code Style Issues", @"title",
|
||||
filename.lastPathComponent , @"message",
|
||||
nil];
|
||||
|
||||
[self wantUserNotificationWithInfo:dict];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showObjjWarnings
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
NSUInteger numberError = [self.errorList count];
|
||||
NSDictionary *firstError;
|
||||
NSUInteger i = 0;
|
||||
|
||||
for (i = 0; i < numberError; i++)
|
||||
{
|
||||
NSDictionary *dict = [self.errorList objectAtIndex:i];
|
||||
|
||||
if (numberError)
|
||||
if ([[dict valueForKey:@"type"] isEqualToString: @"objj"])
|
||||
{
|
||||
NSDictionary *error = [self.errorList objectAtIndex:0];
|
||||
NSString *filename = [error objectForKey:@"path"];
|
||||
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInteger:self.projectId] , @"projectId",
|
||||
@"Code Style Issues", @"title",
|
||||
filename.lastPathComponent , @"message",
|
||||
nil];
|
||||
|
||||
[self wantUserNotificationWithInfo:dict];
|
||||
firstError = dict;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ([defaults boolForKey:kDefaultXCCAutoOpenErrorsPanelOnErrors] && firstError)
|
||||
[self openErrorsPanel:self];
|
||||
|
||||
if ([defaults boolForKey:kDefaultXCCAutoShowNotificationOnErrors] && firstError)
|
||||
{
|
||||
NSDictionary *error = [self.errorList objectAtIndex:0];
|
||||
NSString *filename = [error objectForKey:@"path"];
|
||||
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInteger:self.projectId] , @"projectId",
|
||||
@"Compiling Issues", @"title",
|
||||
filename.lastPathComponent , @"message",
|
||||
nil];
|
||||
|
||||
[self wantUserNotificationWithInfo:dict];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pruneProcessingErrorsForProjectPath:(NSString *)path
|
||||
{
|
||||
[self pruneProcessingErrorsForProjectPath:path type:nil];
|
||||
}
|
||||
|
||||
- (void)pruneProcessingErrorsForProjectPath:(NSString *)path type:(NSString*)type
|
||||
{
|
||||
// Remove all errors for the path being processed
|
||||
NSIndexSet *matchingErrors = [self.errorList indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop)
|
||||
{
|
||||
return [[obj valueForKey:@"path"] isEqualToString:path];
|
||||
if (type)
|
||||
return ([[obj valueForKey:@"path"] isEqualToString:path] || [[obj valueForKey:@"realPath"] isEqualToString:path]) && [[obj valueForKey:@"type"] isEqualToString:type];
|
||||
else
|
||||
return [[obj valueForKey:@"path"] isEqualToString:path] || [[obj valueForKey:@"realPath"] isEqualToString:path];
|
||||
}];
|
||||
|
||||
|
||||
[self.errorListController removeObjectsAtArrangedObjectIndexes:matchingErrors];
|
||||
}
|
||||
|
||||
@@ -1758,6 +1822,170 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
return index != NSNotFound;
|
||||
}
|
||||
|
||||
#pragma mark - objjj check
|
||||
|
||||
- (NSString*)_getObjjIncludePaths
|
||||
{
|
||||
NSRegularExpression *regulareExpressionFramework = [NSRegularExpression regularExpressionWithPattern:@"OBJJ_INCLUDE_PATHS ?= ?\\[\"(.*)\"\\," options:0 error:nil];
|
||||
|
||||
NSString *indexPath;
|
||||
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:kDefaultXCCUseDebugFrameworkWithObjj])
|
||||
indexPath = [NSString stringWithFormat:@"%@/index-debug.html", self.projectPath];
|
||||
else
|
||||
indexPath = [NSString stringWithFormat:@"%@/index.html", self.projectPath];
|
||||
|
||||
NSDictionary *taskResult = [self runTaskWithLaunchPath:@"/bin/cat" arguments:[NSMutableArray arrayWithObject:indexPath] returnType:kTaskReturnTypeAny];
|
||||
|
||||
NSString *response = taskResult[@"response"];
|
||||
|
||||
NSArray *matches = [regulareExpressionFramework matchesInString:response options:0 range:NSMakeRange(0, [response length])];
|
||||
|
||||
for (NSTextCheckingResult *match in matches)
|
||||
return [response substringWithRange:[match rangeAtIndex:1]];
|
||||
|
||||
return @"Frameworks/";
|
||||
}
|
||||
|
||||
- (BOOL)checkObjjWarningsForPath:(NSArray*)paths
|
||||
{
|
||||
DDLogVerbose(@"Checking path %@ with objj", paths);
|
||||
|
||||
NSUInteger numberOfFiles = [paths count];
|
||||
|
||||
if (!numberOfFiles)
|
||||
return YES;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:XCCBatchDidStartNotification object:self];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:XCCObjjDidStartNotification object:self];
|
||||
|
||||
NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"-I", [self _getObjjIncludePaths], @"-m", nil];
|
||||
[arguments addObjectsFromArray:paths];
|
||||
|
||||
NSDictionary *taskResult = [self runTaskWithLaunchPath:self.executablePaths[@"objj"]
|
||||
arguments:arguments
|
||||
returnType:kTaskReturnTypeStdOut];
|
||||
|
||||
NSInteger status = [taskResult[@"status"] intValue];
|
||||
NSString *response = taskResult[@"response"];
|
||||
|
||||
if (status == 0 && [response length] == 0)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:XCCObjjDidEndNotification object:self];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:XCCBatchDidEndNotification object:self];
|
||||
return YES;
|
||||
}
|
||||
|
||||
NSMutableArray *errors = [NSMutableArray arrayWithArray:[response componentsSeparatedByString:@"\n\n"]];
|
||||
|
||||
NSInteger numberOfErrors = [errors count];
|
||||
NSInteger i = 0;
|
||||
NSMutableArray *dicts = [NSMutableArray array];
|
||||
|
||||
// When checking of the entire project, we have to be ready to find errors
|
||||
NSRegularExpression *regulareExpressionFramework = [NSRegularExpression regularExpressionWithPattern:@"([\\S\\s]*)(WARNING|ERROR) line ([0-9]*) in file\\:(.*)\\: ([\\S\\s]*)" options:0 error:nil];
|
||||
|
||||
NSString *filePath;
|
||||
|
||||
if ([paths count] == 1)
|
||||
filePath = [paths firstObject];
|
||||
|
||||
for (i = 0; i < numberOfErrors; i++)
|
||||
{
|
||||
NSMutableString *error = (NSMutableString*)[errors objectAtIndex:i];
|
||||
NSString *line;
|
||||
NSString *path;
|
||||
NSString *messageError;
|
||||
|
||||
// We have an extra new line for the first error
|
||||
if (i == 0)
|
||||
error = (NSMutableString*)[error substringFromIndex:1];
|
||||
|
||||
NSArray *matches = [regulareExpressionFramework matchesInString:error options:0 range:NSMakeRange(0, [error length])];
|
||||
NSInteger j = 0;
|
||||
|
||||
if (![matches count])
|
||||
{
|
||||
DDLogVerbose(@"Error %@ has been ignored by xCodeCapp, the error doesn't respect any pattern", error);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (NSTextCheckingResult *match in matches)
|
||||
{
|
||||
for (j = 0; j < [match numberOfRanges]; j++)
|
||||
{
|
||||
switch (j) {
|
||||
case 1:
|
||||
messageError = [error substringWithRange:[match rangeAtIndex:j]];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
line = [error substringWithRange:[match rangeAtIndex:j]];
|
||||
break;
|
||||
|
||||
case 4:
|
||||
path = [error substringWithRange:[match rangeAtIndex:j]];
|
||||
break;
|
||||
|
||||
case 5:
|
||||
messageError = [NSString stringWithFormat:@"Compiling issue at line %@ of file %@:\n%@ \n%@", line, path.lastPathComponent, [error substringWithRange:[match rangeAtIndex:j]], messageError];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure to delete all the compilations issue form the tableView
|
||||
[self pruneProcessingErrorsForProjectPath:path type:@"objj"];
|
||||
|
||||
// Path and realPath are needed, we can get error on ViewController2.j while checking ViewController.j.
|
||||
// When recompiling ViewController.j, realPath is used to know which errors have to be erased form the table
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInt:[line intValue]], @"line",
|
||||
messageError , @"message",
|
||||
(filePath ? filePath:path), @"path",
|
||||
@"objj", @"type",
|
||||
path , @"realPath",
|
||||
nil];
|
||||
|
||||
// Compiler can show several times the same errors
|
||||
if (![dicts containsObject:dict] && ![self.errorList containsObject:dict])
|
||||
[dicts addObject:dict];
|
||||
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(objjCompilerDidGenerateError:) withObject:dicts waitUntilDone:YES];
|
||||
|
||||
self.isProcessing = NO;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:XCCObjjDidEndNotification object:self];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:XCCBatchDidEndNotification object:self];
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (IBAction)checkProjectWithObjj:(id)sender
|
||||
{
|
||||
[self clearErrors:self];
|
||||
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
[center addObserver:self selector:@selector(objjDidEndNotification:) name:XCCObjjDidEndNotification object:nil];
|
||||
|
||||
[self performSelectorInBackground:@selector(checkObjjWarningsForPath:) withObject:self.xCodeCappTargetedFiles];
|
||||
}
|
||||
|
||||
- (void)objjDidEndNotification:(NSNotification*)aNotification
|
||||
{
|
||||
[self showObjjWarnings];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:XCCObjjDidEndNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)objjCompilerDidGenerateError:(NSArray*)errors
|
||||
{
|
||||
[self.errorListController addObjects:errors];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - capp_lint
|
||||
|
||||
@@ -1773,7 +2001,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
|
||||
- (void)cappLintDidEndNotification:(NSNotification*)aNotification
|
||||
{
|
||||
[self showCappLintErrors];
|
||||
[self showCappLintWarnings];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:XCCCappLintDidEndNotification object:nil];
|
||||
}
|
||||
|
||||
@@ -1840,18 +2068,19 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
NSInteger positionOfSecondColon = [errorWithoutPath rangeOfString:@":"].location;
|
||||
line = [errorWithoutPath substringToIndex:positionOfSecondColon];
|
||||
|
||||
NSString *messageError = [NSString stringWithFormat:@"Code style issue: %@ \n%@", path.lastPathComponent, errorWithoutPath];
|
||||
NSString *messageError = [NSString stringWithFormat:@"Code style issue at line %@ of file %@:\n%@", line, path.lastPathComponent, errorWithoutPath];
|
||||
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInt:[line intValue]], @"line",
|
||||
messageError , @"message",
|
||||
path, @"path",
|
||||
@"capp_lint", @"type",
|
||||
nil];
|
||||
|
||||
[dicts addObject:dict];
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread:@selector(cappLintConversionDidGenerateError:) withObject:dicts waitUntilDone:NO];
|
||||
[self performSelectorOnMainThread:@selector(cappLintConversionDidGenerateError:) withObject:dicts waitUntilDone:YES];
|
||||
|
||||
self.isProcessing = NO;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:XCCBatchDidEndNotification object:self];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user