public override Task GetResults(ISearchResultCallback searchResultCallback, SearchPopupSearchPattern pattern, CancellationToken token) { return(Task.Run(delegate { var files = AllFiles.ToList(); var matcher = StringMatcher.GetMatcher(pattern.Pattern, false); var savedMatches = new Dictionary <string, MatchResult> (); foreach (ProjectFile file in files) { if (token.IsCancellationRequested) { break; } int rank; string matchString = System.IO.Path.GetFileName(file.FilePath); if (MatchName(savedMatches, matcher, matchString, out rank)) { searchResultCallback.ReportResult(new FileSearchResult(pattern.Pattern, matchString, rank, file, true)); } matchString = FileSearchResult.GetRelProjectPath(file); if (MatchName(savedMatches, matcher, matchString, out rank)) { searchResultCallback.ReportResult(new FileSearchResult(pattern.Pattern, matchString, rank, file, true)); } } }, token)); }
internal SearchResult CheckFile(ProjectFile file) { int rank; string matchString = System.IO.Path.GetFileName(file.FilePath); if (MatchName(matchString, out rank)) { return(new FileSearchResult(pattern, matchString, rank, file, true)); } if (!FullSearch) { return(null); } matchString = FileSearchResult.GetRelProjectPath(file); if (MatchName(matchString, out rank)) { return(new FileSearchResult(pattern, matchString, rank, file, false)); } return(null); }
List <Tuple <string, string, ProjectFile> > GenerateAllFiles() { //Slowest thing here is GetRelProjectPath, hence Tuple<,,> needs to be cached var list = new List <Tuple <string, string, ProjectFile> > (); foreach (var doc in IdeApp.Workbench.Documents) { // We only want to check it here if it's not part // of the open combine. Otherwise, it will get // checked down below. if (doc.Owner == null && doc.IsFile) { var pf = new ProjectFile(doc.Name); list.Add(new Tuple <string, string, ProjectFile> (System.IO.Path.GetFileName(pf.FilePath), FileSearchResult.GetRelProjectPath(pf), pf)); } } var projects = IdeApp.Workspace.GetAllProjects(); foreach (var p in projects) { foreach (ProjectFile pf in p.Files) { if (pf.Subtype != Subtype.Directory && (pf.Flags & ProjectItemFlags.Hidden) != ProjectItemFlags.Hidden) { list.Add(new Tuple <string, string, ProjectFile> (System.IO.Path.GetFileName(pf.FilePath), FileSearchResult.GetRelProjectPath(pf), pf)); } } } return(list); }