Skip to content

Commit

Permalink
Fix accidental edit of string in refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
jblues committed Nov 21, 2015
1 parent 800366f commit 3c34b1c
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .idea/XcodeEditor.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions Source/Utils/XCKeyBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

@implementation XCKeyBuilder

/* ================================================= Class Methods ================================================== */
//-------------------------------------------------------------------------------------------
#pragma mark - Class Methods
//-------------------------------------------------------------------------------------------

+ (XCKeyBuilder*)forItemNamed:(NSString*)name
{
NSData* data = [name dataUsingEncoding:NSUTF8StringEncoding];
Expand All @@ -35,7 +38,10 @@ + (XCKeyBuilder*)createUnique
return [[XCKeyBuilder alloc] initHashValueMD5HashWithBytes:&bytes length:sizeof(bytes)];
}

/* ================================================== Initializers ================================================== */
//-------------------------------------------------------------------------------------------
#pragma mark - Initialization & Destruction
//-------------------------------------------------------------------------------------------

- (id)initHashValueMD5HashWithBytes:(const void*)bytes length:(NSUInteger)length
{
self = [super init];
Expand All @@ -46,7 +52,10 @@ - (id)initHashValueMD5HashWithBytes:(const void*)bytes length:(NSUInteger)length
return self;
}

/* ================================================ Interface Methods =============================================== */
//-------------------------------------------------------------------------------------------
#pragma mark - Interface Methods
//-------------------------------------------------------------------------------------------

- (NSString*)build
{
NSInteger byteLength = sizeof(HashValueMD5Hash);
Expand Down
4 changes: 2 additions & 2 deletions Source/XCGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ - (NSDictionary *)makeFileReferenceWithPath:(NSString *)path name:(NSString *)na
if (path != nil) {
reference[@"path"] = path;
}
reference[@"sourceTree"] = @"<_group>";
reference[@"sourceTree"] = @"<group>";
return reference;
}

Expand All @@ -652,7 +652,7 @@ - (NSDictionary *)asDictionary
{
NSMutableDictionary *groupData = [NSMutableDictionary dictionary];
groupData[@"isa"] = [NSString xce_stringFromMemberType:PBXGroupType];
groupData[@"sourceTree"] = @"<_group>";
groupData[@"sourceTree"] = @"<group>";

if (_alias != nil) {
groupData[@"name"] = _alias;
Expand Down
4 changes: 4 additions & 0 deletions XcodeEditor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
6B2C23301BFFFAFC009F4BA7 /* XcodeEditorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = XcodeEditorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6B2C23341BFFFAFC009F4BA7 /* XcodeEditorTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XcodeEditorTests.m; sourceTree = "<group>"; };
6B2C23361BFFFAFC009F4BA7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BA798001D353245614B3C335 /* ClassCalledJanine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassCalledJanine.h; sourceTree = "<group>"; };
BA79800F190C0CA230C477CF /* XCSubProjectDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCSubProjectDefinition.m; sourceTree = "<group>"; };
BA798057DB461DE7AABC582A /* XCFileOperationQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCFileOperationQueue.m; sourceTree = "<group>"; };
BA7980A38110FB4C766C093E /* XCProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCProject.h; sourceTree = "<group>"; };
Expand All @@ -91,6 +92,7 @@
BA79854A64EF566049A284BD /* XCKeyBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCKeyBuilder.h; sourceTree = "<group>"; };
BA7985D7F0551F6C47143FF4 /* XcodeGroupMember.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XcodeGroupMember.h; sourceTree = "<group>"; };
BA79861E7B26FAE7C1CC88C2 /* XCXibDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCXibDefinition.h; sourceTree = "<group>"; };
BA79863006603FE6EB1FA6F1 /* ClassCalledJanine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClassCalledJanine.m; sourceTree = "<group>"; };
BA79869C1E09F1947AF90301 /* XcodeSourceFileType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XcodeSourceFileType.h; sourceTree = "<group>"; };
BA7986C4CA851EEFC8C6BE18 /* XCTarget.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCTarget.m; sourceTree = "<group>"; };
BA79870FA7C8A49D306D8A38 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = InfoPlist.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -309,6 +311,8 @@
BA798C28A6E87447B6F15C85 /* project.pbxproj */,
BA79836D36F9335915620E13 /* HelloWorldLayer.header */,
BA79813BA8C71435D517BD58 /* ESA_Sales_Foobar_ViewController.impl */,
BA79863006603FE6EB1FA6F1 /* ClassCalledJanine.m */,
BA798001D353245614B3C335 /* ClassCalledJanine.h */,
);
path = Files;
sourceTree = "<group>";
Expand Down
5 changes: 5 additions & 0 deletions XcodeEditorTests/Resources/Files/ClassCalledJanine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>


@interface ClassCalledJanine : NSObject
@end
8 changes: 8 additions & 0 deletions XcodeEditorTests/Resources/Files/ClassCalledJanine.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#import "ClassCalledJanine.h"


@implementation ClassCalledJanine
{

}
@end
36 changes: 30 additions & 6 deletions XcodeEditorTests/XCGroupTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ - (void)setUp

- (void)test_allows_initialization_with
{
XCGroup *aGroup = [XCGroup groupWithProject:_project key:@"abcd1234" alias:@"Main" path:@"Source/Main" children:nil];
XCGroup *aGroup =
[XCGroup groupWithProject:_project key:@"abcd1234" alias:@"Main" path:@"Source/Main" children:nil];

XCTAssertNotNil(aGroup);
XCTAssertEqualObjects([aGroup key], @"abcd1234");
Expand Down Expand Up @@ -456,11 +457,34 @@ - (void)test_allows_deleting_a_group
for (XCGroup *group in project.groups) {
NSLog(@"Group: %@", group.pathRelativeToProjectRoot);
}
// XCGroup *group = [project groupWithPathFromRoot:@"ProjectToEdit/GroupToDelete"];
// XCTAssertNotNil(group);
//
// [group removeFromParentDeletingChildren:YES];
// [project save];
XCGroup *group = [project groupWithPathFromRoot:@"ProjectToEdit/GroupToDelete"];

XCClassDefinition *classDefinition = [XCClassDefinition classDefinitionWithName:@"ClassCalledJanine"];

[classDefinition setHeader:NSStringWithXCTestResource(@"ClassCalledJanine.h")];
[classDefinition setSource:NSStringWithXCTestResource(@"ClassCalledJanine.m")];

NSLog(@"Class definition: %@", classDefinition);

[group addClass:classDefinition];
[project save];

XCSourceFile *fileResource = [project fileWithName:@"ClassCalledJanine.m"];
XCTAssertNotNil(fileResource);

XCTarget *target = [project targetWithName:@"ProjectToEdit"];
XCTAssertNotNil(target);
[target addMember:fileResource];

fileResource = [project fileWithName:@"ClassCalledJanine.m"];
XCTAssertTrue([fileResource isBuildFile]);

[project save];
NSLog(@"Done adding source file.");


// [group removeFromParentDeletingChildren:YES];
[project save];
}


Expand Down

0 comments on commit 3c34b1c

Please sign in to comment.