Skip to content

Commit

Permalink
Merge branch 'master' of github.com:expanz/xcode-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperblues committed May 11, 2012
2 parents 419dd42 + 5f1ec64 commit 5150237
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 26 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ JetBrains is not yet supported.
### With contributions from:

* Chris Ross of Hidden Memory (http://www.hiddenmemory.co.uk/)
* Paul Taykalo
* Vladislav Alekseev

Thanks!
Expand Down
37 changes: 22 additions & 15 deletions Source/Main/XcodeMemberType.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,29 @@

@implementation NSDictionary (XcodeMemberType)

static NSDictionary * _projectNodeTypesAsStrings;

+ (NSDictionary*) dictionaryWithProjectNodeTypesAsStrings {
return [NSDictionary dictionaryWithObjectsAndKeys:boxEnum(PBXNilType), @"PBXNilType",
boxEnum(PBXBuildFile), @"PBXBuildFile",
boxEnum(PBXContainerItemProxy), @"PBXContainerItemProxy",
boxEnum(PBXCopyFilesBuildPhase), @"PBXCopyFilesBuildPhase",
boxEnum(PBXFileReference), @"PBXFileReference",
boxEnum(PBXFrameworksBuildPhase), @"PBXFrameworksBuildPhase",
boxEnum(PBXGroup), @"PBXGroup",
boxEnum(PBXNativeTarget), @"PBXNativeTarget",
boxEnum(PBXProject), @"PBXProject",
boxEnum(PBXResourcesBuildPhase), @"PBXResourcesBuildPhase",
boxEnum(PBXSourcesBuildPhase), @"PBXSourcesBuildPhase",
boxEnum(PBXTargetDependency), @"PBXTargetDependency",
boxEnum(PBXVariantGroup), @"PBXVariantGroup",
boxEnum(XCBuildConfiguration), @"XCBuildConfiguration",
boxEnum(XCConfigurationList), @"XCConfigurationList", nil];
// This is the most vital operation on adding 500+ files
// So, we caching this dictionary
if (!_projectNodeTypesAsStrings) {
_projectNodeTypesAsStrings = [NSDictionary dictionaryWithObjectsAndKeys:boxEnum(PBXNilType), @"PBXNilType",
boxEnum(PBXBuildFile), @"PBXBuildFile",
boxEnum(PBXContainerItemProxy), @"PBXContainerItemProxy",
boxEnum(PBXCopyFilesBuildPhase), @"PBXCopyFilesBuildPhase",
boxEnum(PBXFileReference), @"PBXFileReference",
boxEnum(PBXFrameworksBuildPhase), @"PBXFrameworksBuildPhase",
boxEnum(PBXGroup), @"PBXGroup",
boxEnum(PBXNativeTarget), @"PBXNativeTarget",
boxEnum(PBXProject), @"PBXProject",
boxEnum(PBXResourcesBuildPhase), @"PBXResourcesBuildPhase",
boxEnum(PBXSourcesBuildPhase), @"PBXSourcesBuildPhase",
boxEnum(PBXTargetDependency), @"PBXTargetDependency",
boxEnum(PBXVariantGroup), @"PBXVariantGroup",
boxEnum(XCBuildConfiguration), @"XCBuildConfiguration",
boxEnum(XCConfigurationList), @"XCConfigurationList", nil];
}
return _projectNodeTypesAsStrings;
}

@end
Expand Down
20 changes: 12 additions & 8 deletions Source/Main/XcodeSourceFileType.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
////////////////////////////////////////////////////////////////////////////////

typedef enum {
FileTypeNil,
Framework,
PropertyList,
SourceCodeHeader,
SourceCodeObjC,
SourceCodeObjCPlusPlus,
XibFile,
ImageResourcePNG
FileTypeNil, // Unknown filetype
Framework, // .framework
PropertyList, // .plist
SourceCodeHeader, // .h
SourceCodeObjC, // .m
SourceCodeObjCPlusPlus, // .mm
XibFile, // .xib
ImageResourcePNG, // .png
Bundle, // .bundle .octet
Archive, // .a files
HTML, // HTML file
TEXT // Some text file
} XcodeSourceFileType;

@interface NSString (XCodeFileType)
Expand Down
9 changes: 7 additions & 2 deletions Source/Main/XcodeSourceFileType.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
@implementation NSDictionary (XcodeFileType)

+ (NSDictionary*) dictionaryWithFileReferenceTypesAsStrings {
return [NSDictionary dictionaryWithObjectsAndKeys:boxEnum(SourceCodeHeader), @"sourcecode.c.h",
return [NSDictionary dictionaryWithObjectsAndKeys:
boxEnum(SourceCodeHeader), @"sourcecode.c.h",
boxEnum(SourceCodeObjC), @"sourcecode.c.objc",
boxEnum(Framework), @"wrapper.framework",
boxEnum(PropertyList), @"text.plist.strings",
boxEnum(SourceCodeObjCPlusPlus), @"sourcecode.cpp.objcpp",
boxEnum(XibFile), @"file.xib",
boxEnum(ImageResourcePNG), @"image.png",
boxEnum(Bundle), @"wrapper.cfbundle",
boxEnum(Archive), @"archive.ar",
boxEnum(HTML), @"text.html",
boxEnum(TEXT), @"text",
nil];
}

Expand All @@ -37,7 +42,7 @@ + (NSString*) stringFromSourceFileType:(XcodeSourceFileType)type {

- (XcodeSourceFileType) asSourceFileType {
NSDictionary* typeStrings = [NSDictionary dictionaryWithFileReferenceTypesAsStrings];

if ([typeStrings objectForKey:self]) {
return (XcodeSourceFileType) [[typeStrings objectForKey:self] intValue];
}
Expand Down
6 changes: 6 additions & 0 deletions Source/Main/xcode_Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
*/
- (xcode_Group*) groupWithPathRelativeToParent:(NSString*)path;

/**
* Returns the group with the specified display name path - the directory relative to the root group. Eg Source/Main
*/
- (xcode_Group*) groupWithDisplayNamePathRelativeToParent:(NSString*)path;


/**
* Returns the parent group for the group or file with the given key;
*/
Expand Down
15 changes: 15 additions & 0 deletions Source/Main/xcode_Project.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,21 @@ - (Group*) groupWithPathRelativeToParent:(NSString*)path {
return nil;
}

- (Group*) groupWithDisplayNamePathRelativeToParent:(NSString*)path {
NSArray * pathItems = [path componentsSeparatedByString:@"/"];
Group * currentGroup = [self rootGroup];
for (NSString * pathItem in pathItems) {
id<XcodeGroupMember> group = [currentGroup memberWithDisplayName:pathItem];
if ([group isKindOfClass:[Group class]]) {
currentGroup = group;
} else {
return nil;
}
}
return currentGroup;
}


/* ================================================================================================================== */
#pragma mark Targets

Expand Down
2 changes: 1 addition & 1 deletion Source/Main/xcode_SourceFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ - (BOOL) isBuildFile {
}

- (BOOL) canBecomeBuildFile {
return _type == SourceCodeObjC || _type == SourceCodeObjCPlusPlus || _type == XibFile || _type == Framework;
return _type == SourceCodeObjC || _type == SourceCodeObjCPlusPlus || _type == XibFile || _type == Framework || _type == ImageResourcePNG || _type == HTML || _type == Bundle || _type == Archive;
}


Expand Down
7 changes: 7 additions & 0 deletions Source/Main/xcode_Target.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ - (XcodeMemberType) buildPhaseFor:(SourceFile*)sourceFile {
else if (sourceFile.type == Framework) {
return PBXFrameworksBuildPhase;
}
else if (sourceFile.type == ImageResourcePNG || sourceFile.type == HTML || sourceFile.type == Bundle) {
return PBXResourcesBuildPhase;
}
else if (sourceFile.type == Archive) {
return PBXFrameworksBuildPhase;
}

else {
NSString* type = [NSString stringFromSourceFileType:[sourceFile type]];
[NSException raise:NSInternalInconsistencyException format:@"Type %@ cannot be added to a target.", type];
Expand Down

0 comments on commit 5150237

Please sign in to comment.