Skip to content

Various bug fixed and general compatible fixes #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// Copyright (c) 2014 Arnaud Coomans. All rights reserved.
//

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "ACCodeSnippetGitDataStore.h"


@interface ACCodeSnippetGitDataStoreTests : SenTestCase
@interface ACCodeSnippetGitDataStoreTests : XCTestCase
@end

@implementation ACCodeSnippetGitDataStoreTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.acoomans.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
Expand Down
40 changes: 20 additions & 20 deletions ACCodeSnippetRepository Tests/ACCodeSnippetSerializationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright (c) 2014 Arnaud Coomans. All rights reserved.
//

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "ACCodeSnippetSerialization.h"

@interface ACCodeSnippetSerializationTests : SenTestCase
@interface ACCodeSnippetSerializationTests : XCTestCase
@end

@implementation ACCodeSnippetSerializationTests
Expand All @@ -31,14 +31,14 @@ - (void)testSerialize {
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"\n%@", string);

STAssertTrue([string rangeOfString:@"title"].location != NSNotFound, nil);
STAssertTrue([string rangeOfString:@"summary"].location != NSNotFound, nil);
STAssertTrue([string rangeOfString:@"line1\nline2\nline3"].location != NSNotFound, nil);
STAssertTrue([string rangeOfString:@"WhateverKey"].location != NSNotFound, nil);
STAssertTrue([string rangeOfString:@"WhateverValue"].location != NSNotFound, nil);
XCTAssertTrue([string rangeOfString:@"title"].location != NSNotFound);
XCTAssertTrue([string rangeOfString:@"summary"].location != NSNotFound);
XCTAssertTrue([string rangeOfString:@"line1\nline2\nline3"].location != NSNotFound);
XCTAssertTrue([string rangeOfString:@"WhateverKey"].location != NSNotFound);
XCTAssertTrue([string rangeOfString:@"WhateverValue"].location != NSNotFound);

STAssertTrue([string rangeOfString:@"one"].location != NSNotFound, nil);
STAssertTrue([string rangeOfString:@"two"].location != NSNotFound, nil);
XCTAssertTrue([string rangeOfString:@"one"].location != NSNotFound);
XCTAssertTrue([string rangeOfString:@"two"].location != NSNotFound);
}

- (void)testDeserialize {
Expand All @@ -50,13 +50,13 @@ - (void)testDeserialize {
error:nil];
NSLog(@"\n%@", dict);

STAssertTrue([dict[ACCodeSnippetTitleKey] isEqualToString:@"title"], nil);
STAssertTrue([dict[ACCodeSnippetSummaryKey] isEqualToString:@"summary"], nil);
STAssertTrue([dict[ACCodeSnippetContentsKey] isEqualToString:@"line1\nline2\nline3\n"], nil);
STAssertTrue([dict[@"WhateverKey"] isEqualToString:@"WhateverValue"], nil);
XCTAssertTrue([dict[ACCodeSnippetTitleKey] isEqualToString:@"title"]);
XCTAssertTrue([dict[ACCodeSnippetSummaryKey] isEqualToString:@"summary"]);
XCTAssertTrue([dict[ACCodeSnippetContentsKey] isEqualToString:@"line1\nline2\nline3\n"]);
XCTAssertTrue([dict[@"WhateverKey"] isEqualToString:@"WhateverValue"]);

NSArray *a = @[@"one", @"two"];
STAssertTrue([dict[@"Array"] isEqualToArray:a], nil);
XCTAssertTrue([dict[@"Array"] isEqualToArray:a]);
}

- (void)testDeserialize2 {
Expand All @@ -68,13 +68,13 @@ - (void)testDeserialize2 {
error:nil];
NSLog(@"\n%@", dict);

STAssertTrue([dict[ACCodeSnippetTitleKey] isEqualToString:@"title"], nil);
STAssertTrue([dict[ACCodeSnippetSummaryKey] isEqualToString:@"summary"], nil);
STAssertTrue([dict[ACCodeSnippetContentsKey] isEqualToString:@"line1\nline2\nline3\n"], nil);
STAssertTrue([dict[@"WhateverKey"] isEqualToString:@"WhateverValue"], nil);
XCTAssertTrue([dict[ACCodeSnippetTitleKey] isEqualToString:@"title"]);
XCTAssertTrue([dict[ACCodeSnippetSummaryKey] isEqualToString:@"summary"]);
XCTAssertTrue([dict[ACCodeSnippetContentsKey] isEqualToString:@"line1\nline2\nline3\n"]);
XCTAssertTrue([dict[@"WhateverKey"] isEqualToString:@"WhateverValue"]);

NSArray *a = @[@"one", @"two"];
STAssertTrue([dict[@"Array"] isEqualToArray:a], nil);
XCTAssertTrue([dict[@"Array"] isEqualToArray:a]);
}

- (void)testSerializeDeserialize {
Expand All @@ -96,7 +96,7 @@ - (void)testSerializeDeserialize {
options:0
format:ACCodeSnippetSerializationFormatC
error:nil];
STAssertTrue([dict1 isEqualToDictionary:dict2], nil);
XCTAssertTrue([dict1 isEqualToDictionary:dict2]);

}

Expand Down
4 changes: 2 additions & 2 deletions ACCodeSnippetRepository Tests/ACGitRepositoryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright (c) 2014 Arnaud Coomans. All rights reserved.
//

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "ACGitRepository.h"

@interface ACGitRepositoryTests : SenTestCase
@interface ACGitRepositoryTests : XCTestCase
@end

@implementation ACGitRepositoryTests
Expand Down
10 changes: 5 additions & 5 deletions ACCodeSnippetRepository Tests/NSDictionary+MergeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright (c) 2014 Arnaud Coomans. All rights reserved.
//

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "NSDictionary+Merge.h"

@interface NSDictionary_MergeTests : SenTestCase
@interface NSDictionary_MergeTests : XCTestCase
@end

@implementation NSDictionary_MergeTests
Expand All @@ -25,9 +25,9 @@ - (void)testExample {
@"c": @"c"
}];

STAssertTrue([r[@"a"] isEqualToString:@"a"], nil);
STAssertTrue([r[@"b"] isEqualToString:@"b"], nil);
STAssertTrue([r[@"c"] isEqualToString:@"c"], nil);
XCTAssertTrue([r[@"a"] isEqualToString:@"a"]);
XCTAssertTrue([r[@"b"] isEqualToString:@"b"]);
XCTAssertTrue([r[@"c"] isEqualToString:@"c"]);
}

@end
24 changes: 13 additions & 11 deletions ACCodeSnippetRepository.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
5153BAA918B3406D00C1E75B /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = 5153BAA818B3406D00C1E75B /* NSDictionary+Merge.m */; };
5153BAAA18B3406D00C1E75B /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = 5153BAA818B3406D00C1E75B /* NSDictionary+Merge.m */; };
5153BAAC18B3410C00C1E75B /* NSDictionary+MergeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5153BAAB18B3410C00C1E75B /* NSDictionary+MergeTests.m */; };
5154068518AC4B500065CA33 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5154068418AC4B500065CA33 /* SenTestingKit.framework */; };
5154068B18AC4B500065CA33 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5154068918AC4B500065CA33 /* InfoPlist.strings */; };
515CE9DA18B1DCAA000962EA /* GitHub-Mark-120px-plus.png in Resources */ = {isa = PBXBuildFile; fileRef = 515CE9D718B1DCAA000962EA /* GitHub-Mark-120px-plus.png */; };
515CE9DB18B1DCAA000962EA /* GitHub-Mark-32px.png in Resources */ = {isa = PBXBuildFile; fileRef = 515CE9D818B1DCAA000962EA /* GitHub-Mark-32px.png */; };
Expand Down Expand Up @@ -60,8 +59,7 @@
5153BAA718B3406D00C1E75B /* NSDictionary+Merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+Merge.h"; sourceTree = "<group>"; };
5153BAA818B3406D00C1E75B /* NSDictionary+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+Merge.m"; sourceTree = "<group>"; };
5153BAAB18B3410C00C1E75B /* NSDictionary+MergeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+MergeTests.m"; sourceTree = "<group>"; };
5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ACCodeSnippetRepository Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; };
5154068418AC4B500065CA33 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ACCodeSnippetRepository Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
5154068818AC4B500065CA33 /* ACCodeSnippetRepository Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ACCodeSnippetRepository Tests-Info.plist"; sourceTree = "<group>"; };
5154068A18AC4B500065CA33 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
5154068E18AC4B500065CA33 /* ACCodeSnippetRepository Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ACCodeSnippetRepository Tests-Prefix.pch"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -104,7 +102,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
5154068518AC4B500065CA33 /* SenTestingKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -247,7 +244,7 @@
isa = PBXGroup;
children = (
518E699F18AC4A8900C57456 /* ACCodeSnippetRepository.xcplugin */,
5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.octest */,
5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -257,7 +254,6 @@
children = (
518E69A218AC4A8900C57456 /* AppKit.framework */,
518E69A418AC4A8900C57456 /* Foundation.framework */,
5154068418AC4B500065CA33 /* SenTestingKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -318,8 +314,8 @@
);
name = "ACCodeSnippetRepository Tests";
productName = "ACCodeSnippetRepository Tests";
productReference = 5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.octest */;
productType = "com.apple.product-type.bundle";
productReference = 5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
518E699E18AC4A8900C57456 /* ACCodeSnippetRepository */ = {
isa = PBXNativeTarget;
Expand All @@ -344,7 +340,8 @@
518E699718AC4A8900C57456 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
LastTestingUpgradeCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Arnaud Coomans";
TargetAttributes = {
5154068218AC4B500065CA33 = {
Expand Down Expand Up @@ -463,6 +460,7 @@
5154069118AC4B500065CA33 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
Expand All @@ -474,23 +472,24 @@
"$(inherited)",
);
INFOPLIST_FILE = "ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "com.acoomans.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
};
name = Debug;
};
5154069218AC4B500065CA33 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Prefix.pch";
INFOPLIST_FILE = "ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = "com.acoomans.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
};
name = Release;
};
Expand All @@ -510,6 +509,7 @@
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
Expand Down Expand Up @@ -573,6 +573,7 @@
INFOPLIST_FILE = "ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist";
INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins";
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.acoomans.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = xcplugin;
};
Expand All @@ -589,6 +590,7 @@
INFOPLIST_FILE = "ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist";
INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins";
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.acoomans.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = xcplugin;
};
Expand Down
3 changes: 2 additions & 1 deletion ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.acoomans.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand All @@ -31,6 +31,7 @@
<string>FEC992CC-CA4A-4CFD-8881-77300FCB848A</string>
<string>A16FF353-8441-459E-A50C-B071F53F51B7</string>
<string>9F75337B-21B4-4ADC-B558-F9CADF7073A7</string>
<string>AABB7188-E14E-4433-AD3B-5CD791EAD9A3</string>
</array>
<key>NSPrincipalClass</key>
<string>ACCodeSnippetRepositoryPlugin</string>
Expand Down
56 changes: 33 additions & 23 deletions ACCodeSnippetRepository/ACCodeSnippetRepositoryPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ - (id)initWithBundle:(NSBundle *)plugin {

// reference to plugin's bundle, for resource acccess
self.bundle = plugin;


[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(applicationDidFinishLaunching:)
name: NSApplicationDidFinishLaunchingNotification
object: nil];

// add data stores to Xcode's snippet repository
ACCodeSnippetGitDataStore *gitDataStore = [[ACCodeSnippetGitDataStore alloc] init];
[gitDataStore addObserver:self forKeyPath:@"mainQueue.operationCount" options:0 context:NULL];
Expand All @@ -58,29 +63,30 @@ - (id)initWithBundle:(NSBundle *)plugin {
[self startTimer];
}

// Create menu items, initialize UI, etc.
NSMenu *pluginMenu = [self pluginMenu];
pluginMenu.autoenablesItems = NO;

if (pluginMenu) {

NSMenuItem *actionMenuItem = nil;

self.updateMenuItem = actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Update snippets" action:@selector(updateAction:) keyEquivalent:@""];
actionMenuItem.target = self;
[pluginMenu addItem:actionMenuItem];

actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Configure snippets repository" action:@selector(configureAction:) keyEquivalent:@""];
actionMenuItem.target = self;
[pluginMenu addItem:actionMenuItem];

//[pluginMenu addItem:[NSMenuItem separatorItem]];
}

}
return self;
}

- (void) applicationDidFinishLaunching: (NSNotification *) notification
{
// Create menu items, initialize UI, etc.
NSMenu *pluginMenu = [self pluginMenu];
pluginMenu.autoenablesItems = NO;

if (pluginMenu) {

NSMenuItem *actionMenuItem = nil;

self.updateMenuItem = actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Update snippets" action:@selector(updateAction:) keyEquivalent:@""];
actionMenuItem.target = self;
[pluginMenu addItem:actionMenuItem];

actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Configure snippets repository" action:@selector(configureAction:) keyEquivalent:@""];
actionMenuItem.target = self;
[pluginMenu addItem:actionMenuItem];
}
}

- (id)init {
return [self initWithBundle:nil];
}
Expand All @@ -97,10 +103,14 @@ - (NSMenu*)pluginMenu {
if (!pluginMenu) {
pluginMenu = [[NSMenu alloc] initWithTitle:pluginMenuTitle];

NSMenuItem *pluginMenuItem = [[NSMenuItem alloc] initWithTitle:pluginMenuTitle action:nil keyEquivalent:@""];
NSMenuItem *pluginMenuItem = [[NSMenuItem alloc] initWithTitle:pluginMenuTitle action: NULL keyEquivalent:@""];
pluginMenuItem.submenu = pluginMenu;

[[NSApp mainMenu] addItem:pluginMenuItem];

NSMenu *appMenu = [NSApp menu];

NSMenuItem *helpMenuItem = [appMenu itemWithTitle: @"Help"];

[appMenu insertItem: pluginMenuItem atIndex: [appMenu indexOfItem: helpMenuItem]];
}
return pluginMenu;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ - (ACCodeSnippetGitDataStore*)gitDataStore {
- (void)controlTextDidChange:(NSNotification *)notification {
NSTextField *textField = [notification object];

if (![[NSURL URLWithString:textField.stringValue] isEqualTo:self.gitDataStore.remoteRepositoryURL]) {
if (([textField stringValue] &&
[[textField stringValue] length]) &&
![[NSURL URLWithString:textField.stringValue] isEqualTo:self.gitDataStore.remoteRepositoryURL]) {
self.forkRemoteRepositoryButton.enabled = YES;
} else {
self.forkRemoteRepositoryButton.enabled = NO;
Expand Down Expand Up @@ -120,8 +122,10 @@ - (IBAction)forkRemoteRepositoryAction:(id)sender {
[weakSelf.window endSheet:weakSelf.progressPanel];
[weakSelf.progressIndicator stopAnimation:weakSelf];
});

[weakSelf importUserSnippetsAction:weakSelf];

dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf importUserSnippetsAction:weakSelf];
});
});

break;
Expand Down Expand Up @@ -242,7 +246,7 @@ - (IBAction)restoreSystemSnippets:(id)sender {
}

- (IBAction)openSystemSnippetsDirectoryAction:(id)sender {
[[NSWorkspace sharedWorkspace] selectFile:[self systemSnippetsPath] inFileViewerRootedAtPath:nil];
[[NSWorkspace sharedWorkspace] selectFile:[self systemSnippetsPath] inFileViewerRootedAtPath: @""];
}

- (NSString*)systemSnippetsPath {
Expand Down