// Portions of code from // https://github.com/MellongLau/AMMethod2Implement // MIT license #import "P4XcodeHelper.h" #import <AppKit/AppKit.h> @implementation P4XcodeHelper + (NSURL*)currentProjectURL { for (NSDocument* currentDoc in [NSApp orderedDocuments]) { @try { NSURL* url = [[[currentDoc valueForKeyPath:@"_workspace.representingFilePath.fileURL"] URLByDeletingLastPathComponent] filePathURL]; if (url) { return url; } } @catch (NSException* exception) { NSLog(@"Exception raised while searching for workspace URL: %@", exception); } } return nil; } /* https://github.com/MellongLau/AMMethod2Implement/blob/master/AMMethod2Implement/AMXcodeHelper.m */ + (id)currentEditor { NSWindow* window = [NSApp keyWindow]; NSWindowController *windowController = [window windowController]; if (windowController == nil) { return nil; } if ([windowController isKindOfClass:NSClassFromString(@"IDEWorkspaceWindowController")]) { IDEWorkspaceWindowController *workspaceController = (IDEWorkspaceWindowController *)windowController; IDEEditorArea *editorArea = [workspaceController editorArea]; IDEEditorContext *editorContext = [editorArea lastActiveEditorContext]; return [editorContext editor]; } return nil; } + (NSObject *)currentWorkspaceDocument { NSWindowController *currentWindowController = [[NSApp keyWindow] windowController]; id document = [currentWindowController document]; if (currentWindowController && [document isKindOfClass:NSClassFromString(@"IDEWorkspaceDocument")]) { return (NSObject *)document; } return nil; } + (IDESourceCodeDocument *)currentSourceCodeDocument { id currentEditor = [P4XcodeHelper currentEditor]; if (currentEditor == nil) { return nil; } if ([currentEditor isKindOfClass:NSClassFromString(@"IDESourceCodeEditor")]) { IDESourceCodeEditor *editor = [P4XcodeHelper currentEditor]; return editor.sourceCodeDocument; } if ([currentEditor isKindOfClass:NSClassFromString(@"IDESourceCodeComparisonEditor")]) { IDESourceCodeComparisonEditor *editor = currentEditor; if ([[editor primaryDocument] isKindOfClass:NSClassFromString(@"IDESourceCodeDocument")]) { IDESourceCodeDocument *document = (IDESourceCodeDocument *)editor.primaryDocument; return document; } } #if (0) // not yet implemented if ([currentEditor isKindOfClass:NSClassFromString(@"IDEQuickLookEditor")]) { IDESourceCodeEditor *editor = [P4XcodeHelper currentEditor]; return editor.sourceCodeDocument; } #endif #if defined(_DEBUG) if([currentEditor respondsToSelector:@selector(className)]) { NSLog(@"Class type %@\n", [currentEditor className]); } #endif return nil; } + (NSURL*)currentSourceCodeDocumentURL { NSURL* docURL = nil; IDESourceCodeDocument * doc = [P4XcodeHelper currentSourceCodeDocument]; if (doc != nil) { docURL = [doc fileURL]; } return docURL; } @end //@implementation IDESourceCodeDocument //- (DVTSourceTextStorage *)textStorage //{ // return nil; //} // //- (NSUndoManager *)undoManager //{ // return nil; //} // //@end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 20135 | robc_apple |
Fixed error when spaces in path Added the ability to checkout project files as well as xib and plist files. Added warning before revert happens Added Submit P4 with UI for description of submit |
||
#1 | 20134 | robc_apple |
Populate -o //guest/jaime_rios/XcodePerforcePlugin/... //guest/robc_apple/XcodePerforcePlugin/.... |
||
//guest/jaime_rios/XcodePerforcePlugin/XcodePerforcePlugin/P4XcodeHelper.m | |||||
#6 | 13723 | Jaime Rios | Fixed problem with menu items not being created because mainMenu is not available at startup for Xcode 6.3.2. | ||
#5 | 13687 | Jaime Rios | Added Xcode 6.3.2 support; minor editing changes; fixes for Swift compiler errors. | ||
#4 | 11740 | Jaime Rios | Updated readme text with additional known issues; refactored p4 revert function; added perforce icon to alert message. | ||
#3 | 11733 | Jaime Rios | Refactored code to have more functionality within Swift code; fixed perforce connection bugs. | ||
#2 | 11714 | Jaime Rios | Added unit tests; fixed bugs found during testing; added Jon Reid's XcodeCoverage files http://qualitycoding.org/xcode-code-coverage/ modified project to produce code coverage reports. | ||
#1 | 11694 | Jaime Rios | Initial add of XcodePerforcePlugin project to guest depot. |