static IEnumerable <SearchResult> FindReferences( AbstractDProject project, INode member, ISearchProgressMonitor monitor = null) { var searchResults = new List <SearchResult>(); var parseCache = project != null ? project.ParseCache : DCompilerService.Instance.GetDefaultCompiler().GenParseCacheView(); var modules = new List <DModule>(); if (project != null) { foreach (var p in project.GetSourcePaths(IdeApp.Workspace.ActiveConfiguration)) { modules.AddRange(GlobalParseCache.EnumModulesRecursively(p, null)); } } else { modules.Add((IdeApp.Workbench.ActiveDocument.ParsedDocument as MonoDevelop.D.Parser.ParsedDModule).DDom); } if (monitor != null) { monitor.BeginStepTask("Scan for references", modules.Count, 1); } List <ISyntaxRegion> references = null; var ctxt = ResolutionContext.Create(parseCache, null); foreach (var mod in modules) { if (mod == null) { continue; } try { references = ReferencesFinder.Scan(mod, member, ctxt).ToList(); if (references.Count < 1) { if (monitor != null) { monitor.Step(1); } continue; } // Sort the references by code location references.Sort(new IdLocationComparer()); // Get actual document code var targetDoc = TextFileProvider.Instance.GetTextEditorData(new FilePath(mod.FileName)); foreach (var reference in references) { CodeLocation loc; if (reference is AbstractTypeDeclaration) { loc = ((AbstractTypeDeclaration)reference).NonInnerTypeDependendLocation; } else if (reference is IExpression) { loc = reference.Location; } else { continue; } searchResults.Add(new SearchResult(new FileProvider(mod.FileName, project), targetDoc.LocationToOffset(loc.Line, loc.Column), member.Name.Length)); } } catch (Exception ex) { LoggingService.LogWarning("Error during reference search", ex); } if (monitor != null) { monitor.Step(1); } } if (monitor != null) { monitor.EndTask(); } return(searchResults); }