public static ParsedDocument Parse(string fileName, string mimeType, ContentDelegate getContent) { List <Project> projects = new List <Project> (); lock (databases) { foreach (ProjectDom db in databases.Values) { if (db.Project != null) { if (db.Project.IsFileInProject(fileName)) { projects.Add(db.Project); } } } } if (projects.Count > 0) { return(UpdateFile(projects.ToArray(), fileName, mimeType, getContent)); } else { return(ParseFile(null, fileName, getContent)); } }
// Parses a file. It does not update the parser database public static ParsedDocument ParseFile(ProjectDom dom, string fileName, ContentDelegate getContent) { string fileContent = getContent != null?getContent() : null; return(DoParseFile(dom, fileName, fileContent)); }
public static ParsedDocument Parse(Project project, string fileName, string mimeType, ContentDelegate getContent) { Project[] projects = project != null ? new Project[] { project } : null; return(UpdateFile(projects, fileName, mimeType, getContent)); }
static ParsedDocument UpdateFile(Project[] projects, string fileName, string mimeType, ContentDelegate getContent) { try { if (GetParser(fileName, mimeType) == null) { return(null); } ParsedDocument parseInformation = null; string fileContent; if (getContent == null) { StreamReader sr = new StreamReader(fileName); fileContent = sr.ReadToEnd(); sr.Close(); } else { fileContent = getContent(); } // Remove any pending jobs for this file RemoveParseJob(fileName); ProjectDom dom = projects != null && projects.Length > 0 ? GetProjectDom(projects [0]) : null; parseInformation = DoParseFile(dom, fileName, fileContent); if (parseInformation == null) { return(null); } // don't update project dom with incorrect parse informations, they may not contain all // information. if (projects != null && projects.Length > 0 && parseInformation.CompilationUnit != null) { SetSourceProject(parseInformation.CompilationUnit, dom); } if (parseInformation.CompilationUnit != null && (parseInformation.Flags & ParsedDocumentFlags.NonSerializable) == 0) { if (projects != null && projects.Length > 0) { foreach (Project project in projects) { ProjectDom db = GetProjectDom(project); if (db != null) { try { if (parseInformation.HasErrors) { db.UpdateTemporaryCompilationUnit(parseInformation.CompilationUnit); } else { db.UpdateTagComments(fileName, parseInformation.TagComments); db.RemoveTemporaryCompilationUnit(parseInformation.CompilationUnit); TypeUpdateInformation res = db.UpdateFromParseInfo(parseInformation.CompilationUnit); if (res != null) { NotifyTypeUpdate(project, fileName, res); } UpdatedCommentTasks(fileName, parseInformation.TagComments, project); } } catch (Exception e) { LoggingService.LogError(e.ToString()); } } } } else { ProjectDom db = GetFileDom(fileName); db.UpdateFromParseInfo(parseInformation.CompilationUnit); } } return(parseInformation); } catch (Exception e) { LoggingService.LogError(e.ToString()); return(null); } }
static ParsedDocument UpdateFile (Project[] projects, string fileName, string mimeType, ContentDelegate getContent) { try { if (GetParser (fileName, mimeType) == null) return null; ParsedDocument parseInformation = null; string fileContent; if (getContent == null) { StreamReader sr = new StreamReader (fileName); fileContent = sr.ReadToEnd (); sr.Close (); } else fileContent = getContent (); // Remove any pending jobs for this file RemoveParseJob (fileName); ProjectDom dom = projects != null && projects.Length > 0 ? GetProjectDom (projects [0]) : null; parseInformation = DoParseFile (dom, fileName, fileContent); if (parseInformation == null) return null; // don't update project dom with incorrect parse informations, they may not contain all // information. if (projects != null && projects.Length > 0 && parseInformation.CompilationUnit != null) SetSourceProject (parseInformation.CompilationUnit, dom); if (parseInformation.CompilationUnit != null && (parseInformation.Flags & ParsedDocumentFlags.NonSerializable) == 0) { if (projects != null && projects.Length > 0) { foreach (Project project in projects) { ProjectDom db = GetProjectDom (project); if (db != null) { try { if (parseInformation.HasErrors) { db.UpdateTemporaryCompilationUnit (parseInformation.CompilationUnit); } else { db.UpdateTagComments (fileName, parseInformation.TagComments); db.RemoveTemporaryCompilationUnit (parseInformation.CompilationUnit); TypeUpdateInformation res = db.UpdateFromParseInfo (parseInformation.CompilationUnit); if (res != null) NotifyTypeUpdate (project, fileName, res); UpdatedCommentTasks (fileName, parseInformation.TagComments, project); } } catch (Exception e) { LoggingService.LogError (e.ToString ()); } } } } else { ProjectDom db = GetFileDom (fileName); db.UpdateFromParseInfo (parseInformation.CompilationUnit); } } return parseInformation; } catch (Exception e) { LoggingService.LogError (e.ToString ()); return null; } }
// Parses a file. It does not update the parser database public static ParsedDocument ParseFile (ProjectDom dom, string fileName, ContentDelegate getContent) { string fileContent = getContent != null ? getContent () : null; return DoParseFile (dom, fileName, fileContent); }
public static ParsedDocument Parse (Project project, string fileName, string mimeType, ContentDelegate getContent) { Project[] projects = project != null ? new Project[] { project } : null; return UpdateFile (projects, fileName, mimeType, getContent); }
public static ParsedDocument Parse (string fileName, string mimeType, ContentDelegate getContent) { List<Project> projects = new List<Project> (); lock (databases) { foreach (ProjectDom db in databases.Values) { if (db.Project != null) { if (db.Project.IsFileInProject (fileName)) projects.Add (db.Project); } } } if (projects.Count > 0) return UpdateFile (projects.ToArray (), fileName, mimeType, getContent); else return ParseFile (null, fileName, getContent); }