//FIXME: report errors SyncObjcBackJob ReadTypeFromXcode(FilePath hFile, ref NSObjectProjectInfo pinfo) { var parsed = NSObjectInfoService.ParseHeader(hFile); if (pinfo == null) { pinfo = NSObjectInfoService.GetProjectInfo(dnp); } var objcType = pinfo.GetType(hFile.FileNameWithoutExtension); if (objcType == null) { Console.WriteLine("Missing objc type {0}", hFile.FileNameWithoutExtension); return(null); } if (parsed.ObjCName != objcType.ObjCName) { Console.WriteLine("Parsed type name {0} does not match original {1}", parsed.ObjCName, objcType.ObjCName); return(null); } if (!objcType.IsUserType) { Console.WriteLine("Parsed type {0} is not a user type", objcType); return(null); } //FIXME: fix data loss when there are multiple designer types in one designer file, like MT templates var designerFile = objcType.GetDesignerFile(); //FIXME: add a designer file if there are any designer outlets and actions if (designerFile == null) { return(null); } //FIXME: detect unresolved types parsed.MergeCliInfo(objcType); pinfo.ResolveTypes(parsed); return(new SyncObjcBackJob() { HFile = hFile, DesignerFile = designerFile, Type = parsed, }); }
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); } }