async Task <List <DocumentInfo> > GenerateProjections(MonoDevelop.Projects.ProjectFile f, DocumentMap documentMap, MonoDevelop.Projects.Project p, CancellationToken token, ProjectData oldProjectData, HashSet <DocumentId> duplicates) { var mimeType = IdeServices.DesktopService.GetMimeTypeForUri(f.FilePath); var node = IdeApp.TypeSystemService.GetTypeSystemParserNode(mimeType, f.BuildAction); if (node == null || !node.Parser.CanGenerateProjection(mimeType, f.BuildAction, p.SupportedLanguages)) { return(new List <DocumentInfo> ()); } var content = TextFileProvider.Instance.GetReadOnlyTextEditorData(f.FilePath, throwOnFileNotFound: false); if (content == null) { return(new List <DocumentInfo> ()); } var options = new ParseOptions { FileName = f.FilePath, Project = p, Content = content, }; var generatedProjections = await node.Parser.GenerateProjections(options, token); var list = new List <Projection> (); var entry = new ProjectionEntry { File = f, Projections = list, }; var result = new List <DocumentInfo> (generatedProjections.Count); foreach (var projection in generatedProjections) { list.Add(projection); if (duplicates != null && !duplicates.Add(documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData))) { continue; } var plainName = projection.Document.FileName.FileName; var folders = GetFolders(p.Name, f.ProjectVirtualPath); result.Add(DocumentInfo.Create( documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData), plainName, folders, SourceCodeKind.Regular, TextLoader.From(TextAndVersion.Create(new MonoDevelopSourceText(projection.Document), VersionStamp.Create(), projection.Document.FileName)), projection.Document.FileName, false) ); } projections.AddProjectionEntry(entry); return(result); }
IEnumerable <DocumentInfo> GenerateProjections(MonoDevelop.Projects.ProjectFile f, DocumentMap documentMap, MonoDevelop.Projects.Project p, ProjectData oldProjectData, HashSet <DocumentId> duplicates) { var mimeType = DesktopService.GetMimeTypeForUri(f.FilePath); var node = TypeSystemService.GetTypeSystemParserNode(mimeType, f.BuildAction); if (node == null || !node.Parser.CanGenerateProjection(mimeType, f.BuildAction, p.SupportedLanguages)) { yield break; } var options = new ParseOptions { FileName = f.FilePath, Project = p, Content = TextFileProvider.Instance.GetReadOnlyTextEditorData(f.FilePath), }; var generatedProjections = node.Parser.GenerateProjections(options); var list = new List <Projection> (); var entry = new ProjectionEntry { File = f, Projections = list, }; foreach (var projection in generatedProjections.Result) { list.Add(projection); if (duplicates != null && !duplicates.Add(documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData))) { continue; } var plainName = projection.Document.FileName.FileName; var folders = GetFolders(p.Name, f); yield return(DocumentInfo.Create( documentMap.GetOrCreate(projection.Document.FileName, oldProjectData?.DocumentData), plainName, folders, SourceCodeKind.Regular, TextLoader.From(TextAndVersion.Create(new MonoDevelopSourceText(projection.Document), VersionStamp.Create(), projection.Document.FileName)), projection.Document.FileName, false )); } projections.AddProjectionEntry(entry); }