Permalink
Browse files

Merge pull request #7 from alistra/master

App code code fixes and grammar naziism
  • Loading branch information...
2 parents 0fa0672 + f7fccfd commit 4ac585b4d90032a718f8488d1de1c022f11ec5fe @beelsebob committed Mar 30, 2013
Showing with 52 additions and 40 deletions.
  1. +1 −0 .gitignore
  2. +2 −7 Stash/STAAppDelegate.m
  3. +13 −9 Stash/STADocSet.m
  4. +9 −7 Stash/STAMainWindowController.m
  5. +20 −10 Stash/STAPreferencesController.m
  6. +1 −0 Stash/STASymbol.h
  7. +6 −5 Stash/STASymbol.m
  8. +0 −2 Stash/main.m
View
@@ -13,3 +13,4 @@ build/*
xcuserdata
profile
*.moved-aside
+.idea
View
@@ -8,11 +8,6 @@
#import "STAAppDelegate.h"
-#import "STADocSet.h"
-#import "STADocSetStore.h"
-
-#import "STASymbolTableViewCell.h"
-
@interface STAAppDelegate () <NSWindowDelegate>
@property (strong, nonatomic) STADocSetStore *docsetStore;
@@ -378,8 +373,8 @@ - (void)requestAccessToDirectory:(NSString *)directory continuation:(void(^)(NSU
alternateButton:nil
otherButton:@"Quit"
informativeTextWithFormat:@"Stash can not function without access to Xcode's documentation. Please select the DocSets directory."];
- NSInteger result = [alert runModal];
- switch (result)
+ NSInteger alertResult = [alert runModal];
+ switch (alertResult)
{
case NSAlertDefaultReturn:
[self requestAccessToDirectory:directory continuation:cont];
View
@@ -8,8 +8,6 @@
#import "STADocSet.h"
-#import "STASymbol.h"
-
#import "HTMLParser.h"
@interface STADocSet ()
@@ -78,7 +76,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder
[self setSymbols:[aDecoder decodeObjectForKey:kDocSetSymbolsKey]];
[self setName:[aDecoder decodeObjectForKey:kDocSetNameKey]];
[self setVersion:[aDecoder decodeObjectForKey:kDocSetVersionKey]];
- [self setPlatform:[aDecoder decodeIntForKey:kDocSetPlatformKey]];
+ [self setPlatform:(STAPlatform) [aDecoder decodeIntForKey:kDocSetPlatformKey]];
[self setLoaded:YES];
}
@@ -93,15 +91,21 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
[aCoder encodeInt:[self platform] forKey:kDocSetPlatformKey];
}
-- (void)processURL:(NSURL *)url
+- (void)processURL:(NSURL *)aUrl
{
NSFileManager *fm = [NSFileManager defaultManager];
- NSDirectoryEnumerator *enumerator = [fm enumeratorAtURL:url includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLNameKey, NSURLIsRegularFileKey, NSURLIsDirectoryKey, nil] options:0 errorHandler:^ BOOL (NSURL *url, NSError *err)
- {
- return YES;
- }];
+ NSDirectoryEnumerator *enumerator = [fm enumeratorAtURL:aUrl
+ includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLNameKey,
+ NSURLIsRegularFileKey,
+ NSURLIsDirectoryKey,
+ nil]
+ options:0
+ errorHandler:^BOOL(NSURL *url, NSError *err)
+ {
+ return YES;
+ }];
NSURL *subUrl;
- while (subUrl = [enumerator nextObject])
+ while ((subUrl = [enumerator nextObject]))
{
@autoreleasepool
{
@@ -8,14 +8,12 @@
#import "STAMainWindowController.h"
-#import "STADocSet.h"
-
#import "STASymbolTableViewCell.h"
NSImage *NSImageFromSTASymbolType(STASymbolType t);
NSImage *NSImageFromSTAPlatform(STAPlatform p);
-@interface STAMainWindowController ()
+@interface STAMainWindowController () <NSTableViewDelegate, NSTableViewDataSource>
@property (copy) NSString *currentSearchString;
@property (strong) NSMutableArray *results;
@@ -214,7 +212,7 @@ - (void)setResultNeedsDisplay:(STASymbol *)symbol forSearchString:(NSString *)se
NSUInteger insertionIndex = [[self sortedResults] indexOfObject:symbol
inSortedRange:NSMakeRange(0, [[self sortedResults] count])
options:NSBinarySearchingInsertionIndex
- usingComparator:^ NSComparisonResult (id a, id b)
+ usingComparator:^ NSComparisonResult (STASymbol *a, STASymbol *b)
{
return [a compare:b];
}];
@@ -267,14 +265,19 @@ - (void)tableViewSelectionDidChange:(NSNotification *)notification
NSInteger row = [[self resultsTable] selectedRow];
if (row < [[self sortedResults] count] && row != -1)
{
- STASymbol *symbol = [[self sortedResults] objectAtIndex:row];
+ STASymbol *symbol = [[self sortedResults] objectAtIndex:(NSUInteger) row];
NSURLRequest *request = [NSURLRequest requestWithURL:[symbol url]];
[[[self resultWebView] mainFrame] loadRequest:request];
}
}
-- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
+- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)aRow
{
+ if (aRow < 0) {
+ return nil;
+ }
+ NSUInteger row = (NSUInteger) aRow;
+
if (tableView == [self resultsTable])
{
STASymbolTableViewCell *view = [[STASymbolTableViewCell alloc] initWithFrame:NSZeroRect];
@@ -316,7 +319,6 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
return tick;
}
}
- return nil;
}
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
@@ -8,8 +8,6 @@
#import "STAPreferencesController.h"
-#import "STASymbolTableViewCell.h"
-
#import "STAAppDelegate.h"
#define kModifierFlagsKey @"Modifier Flags"
@@ -258,7 +256,7 @@ - (NSArray *)enabledDocsets
- (unichar)keyboardShortcutCharacter
{
- return [[[NSUserDefaults standardUserDefaults] objectForKey:kKeyboardShortcutKey] intValue];
+ return (unichar) [[[NSUserDefaults standardUserDefaults] objectForKey:kKeyboardShortcutKey] intValue];
}
- (NSUInteger)keyboardShortcutModifierFlags
@@ -274,10 +272,16 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
+ if (row < 0)
+ {
+ return nil;
+ }
+
STADocSet *docSet = [[[self registeredDocsets] sortedArrayUsingComparator:^ NSComparisonResult (STADocSet *ds1, STADocSet *ds2)
- {
- return [[ds1 name] compare:[ds2 name]];
- }] objectAtIndex:row];
+ {
+ return [[ds1 name] compare:[ds2 name]];
+ }] objectAtIndex:(NSUInteger) row];
+
if ([[tableColumn identifier] isEqualToString:@"name"])
{
return [docSet name];
@@ -290,10 +294,16 @@ - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColum
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
- STADocSet *docSet = [[[self registeredDocsets] sortedArrayUsingComparator:^ NSComparisonResult (STADocSet *ds1, STADocSet *ds2)
- {
- return [[ds1 name] compare:[ds2 name]];
- }] objectAtIndex:row];
+ if (row < 0)
+ {
+ return;
+ }
+
+ STADocSet *docSet = [[[self registeredDocsets] sortedArrayUsingComparator:^NSComparisonResult(STADocSet *ds1, STADocSet *ds2)
+ {
+ return [[ds1 name] compare:[ds2 name]];
+ }] objectAtIndex:(NSUInteger) row];
+
if (![[tableColumn identifier] isEqualToString:@"name"])
{
NSMutableArray *enabledDocsetNames = [[[NSUserDefaults standardUserDefaults] objectForKey:kEnabledDocsetsKey] mutableCopy];
View
@@ -66,4 +66,5 @@ STASymbolType STASymbolTypeFromNSString(NSString *symbolTypeString);
- (BOOL)matches:(NSString *)searchString method:(STASearchMethod)method;
+- (NSComparisonResult)compare:(id)other;
@end
View
@@ -47,8 +47,8 @@ - (id)initWithCoder:(NSCoder *)aDecoder
if (nil != self)
{
- [self setLanguage:[aDecoder decodeIntForKey:kSymbolLanguageKey]];
- [self setSymbolType:[aDecoder decodeIntForKey:kSymbolSymbolTypeKey]];
+ [self setLanguage:(STALanguage) [aDecoder decodeIntForKey:kSymbolLanguageKey]];
+ [self setSymbolType:(STASymbolType) [aDecoder decodeIntForKey:kSymbolSymbolTypeKey]];
[self setSymbolName:[aDecoder decodeObjectForKey:kSymbolSymbolNameKey]];
// [self setParentName:[aDecoder decodeObjectForKey:kSymbolParentNameKey]];
[self setUrl:[aDecoder decodeObjectForKey:kSymbolURLKey]];
@@ -99,7 +99,6 @@ - (NSString *)description
default:
return [NSString stringWithFormat:@"C: %d (%@)", _symbolType, _symbolName];
}
- break;
}
case STALanguageObjectiveC:
{
@@ -141,6 +140,8 @@ - (BOOL)matches:(NSString *)searchString method:(STASearchMethod)method
case STASearchMethodContains:
return [[_symbolName lowercaseString] rangeOfString:searchString].location != NSNotFound;
}
+
+ return NO;
}
- (NSComparisonResult)compare:(id)other
@@ -172,7 +173,7 @@ STALanguage STALanguageFromNSString(NSString *languageString)
});
NSNumber *language = languageStrings[languageString];
- return language == nil ? STALanguageUnknown : [language intValue];
+ return (language == nil ? STALanguageUnknown : (STALanguage)[language intValue]);
}
STASymbolType STASymbolTypeFromNSString(NSString *symbolTypeString)
@@ -203,5 +204,5 @@ STASymbolType STASymbolTypeFromNSString(NSString *symbolTypeString)
});
NSNumber *symbolType = symbolTypeStrings[symbolTypeString];
- return symbolType == nil ? STASymbolTypeUnknown : [symbolType intValue];
+ return symbolType == nil ? STASymbolTypeUnknown : (STASymbolType)[symbolType intValue];
}
View
@@ -6,8 +6,6 @@
// Copyright (c) 2012 Thomas Davie. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
-
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);

0 comments on commit 4ac585b

Please sign in to comment.