ProjectFile CreateDesignerFile(XcodeSyncObjcBackJob job) { FilePath designerFile = null; FilePath f = job.Type.DefinedIn[0]; string name = f.FileNameWithoutExtension + ".designer" + f.Extension; designerFile = f.ParentDirectory.Combine(name); var dependsOn = ((FilePath)job.Type.DefinedIn[0]).FileName; return(new ProjectFile(designerFile, BuildAction.Compile) { DependsOn = dependsOn }); }
public override void SyncBack(IProgressMonitor monitor, XcodeSyncBackContext context) { monitor.Log.WriteLine("Queueing sync-back of changes made to the {0} class from Xcode.", Type.CliName); var objcType = context.ProjectInfo.GetType(Type.ObjCName); var hFile = GetObjCHeaderPath(context); if (objcType == null) { context.ReportError("Missing Objective-C type: {0}", Type.ObjCName); return; } if (!objcType.IsUserType) { context.ReportError("Parsed Objective-C type '{0}' is not a user type", objcType); return; } var parsed = NSObjectInfoService.ParseHeader(hFile); if (parsed == null) { context.ReportError("Error parsing Objective-C type: {0}", Type.ObjCName); return; } if (parsed.ObjCName != objcType.ObjCName) { context.ReportError("Parsed type name '{0}' does not match original: {1}", parsed.ObjCName, objcType.ObjCName); return; } parsed.MergeCliInfo(objcType); context.TypeSyncJobs.Add(XcodeSyncObjcBackJob.UpdateType(parsed, objcType.GetDesignerFile())); }
public override void SyncBack(XcodeSyncBackContext context) { var hFile = context.ProjectDir.Combine(Type.ObjCName + ".h"); var objcType = context.ProjectInfo.GetType(Type.ObjCName); if (objcType == null) { context.ReportError("Missing objc type {0}", Type.ObjCName); return; } if (!objcType.IsUserType) { context.ReportError("Parsed type {0} is not a user type", objcType); return; } var parsed = NSObjectInfoService.ParseHeader(hFile); if (parsed == null) { context.ReportError("Error parsing objc type {0}", Type.ObjCName); return; } if (parsed.ObjCName != objcType.ObjCName) { context.ReportError("Parsed type name {0} does not match original {1}", parsed.ObjCName, objcType.ObjCName); return; } parsed.MergeCliInfo(objcType); context.TypeSyncJobs.Add(XcodeSyncObjcBackJob.UpdateType(parsed, objcType.GetDesignerFile())); }
void ScanForAddedFiles(XcodeSyncBackContext ctx, HashSet <string> knownFiles, string directory, string relativePath) { foreach (var file in Directory.EnumerateFiles(directory)) { if (file.EndsWith("~") || file.EndsWith(".m")) { continue; } if (knownFiles.Contains(file)) { continue; } if (file.EndsWith(".h")) { NSObjectTypeInfo parsed = NSObjectInfoService.ParseHeader(file); ctx.TypeSyncJobs.Add(XcodeSyncObjcBackJob.NewType(parsed, relativePath)); } else { FilePath original, relative; if (relativePath != null) { relative = new FilePath(Path.Combine(relativePath, Path.GetFileName(file))); } else { relative = new FilePath(Path.GetFileName(file)); } original = ctx.Project.BaseDirectory.Combine(relative); ctx.FileSyncJobs.Add(new XcodeSyncFileBackJob(original, relative, true)); } } foreach (var dir in Directory.EnumerateDirectories(directory)) { string relative; // Ignore *.xcodeproj directories and any directories named DerivedData at the toplevel if (dir.EndsWith(".xcodeproj") || (relativePath == null && Path.GetFileName(dir) == "DerivedData")) { continue; } if (relativePath != null) { relative = Path.Combine(relativePath, Path.GetFileName(dir)); } else { relative = Path.GetFileName(dir); } ScanForAddedFiles(ctx, knownFiles, dir, relative); } }
ProjectFile CreateDesignerFile (XcodeSyncObjcBackJob job) { FilePath designerFile = null; FilePath f = job.Type.DefinedIn[0]; string name = f.FileNameWithoutExtension + ".designer" + f.Extension; designerFile = f.ParentDirectory.Combine (name); var dependsOn = ((FilePath) job.Type.DefinedIn[0]).FileName; return new ProjectFile (designerFile, BuildAction.Compile) { DependsOn = dependsOn }; }
//FIXME: is this overkill? ProjectFile CreateDesignerFile (XcodeSyncObjcBackJob job) { int i = 0; FilePath designerFile = null; do { FilePath f = job.Type.DefinedIn[0]; string suffix = (i > 0? i.ToString () : ""); string name = f.FileNameWithoutExtension + suffix + ".designer" + f.Extension; designerFile = f.ParentDirectory.Combine (name); } while (project.Files.GetFileWithVirtualPath (designerFile.ToRelative (project.BaseDirectory)) != null); var dependsOn = ((FilePath)job.Type.DefinedIn[0]).FileName; return new ProjectFile (designerFile, BuildAction.Compile) { DependsOn = dependsOn }; }