private static void SearchInFile( [NotNull] string searchText, [NotNull] IPsiSourceFile sourceFile, [NotNull] List <IOccurence> consumer, [NotNull] CheckForInterrupt checkCanceled) { var fileText = sourceFile.Document.GetText(); if (fileText == null) { return; } var index = 0; while ((index = fileText.IndexOf(searchText, index, StringComparison.OrdinalIgnoreCase)) >= 0) { var occurrenceRange = TextRange.FromLength(index, searchText.Length); var documentRange = new DocumentRange(sourceFile.Document, occurrenceRange); var occurrence = new RangeOccurence(sourceFile, documentRange); lock (consumer) { consumer.Add(occurrence); } if (checkCanceled()) { break; } index++; } }
private static void SearchInFile( [NotNull] string searchText, [NotNull] IPsiSourceFile sourceFile, [NotNull] List<IOccurence> consumer, [NotNull] CheckForInterrupt checkCancelled) { var fileText = sourceFile.Document.GetText(); if (fileText == null) return; var index = 0; while ((index = fileText.IndexOf(searchText, index, StringComparison.OrdinalIgnoreCase)) >= 0) { var occuranceRange = TextRange.FromLength(index, searchText.Length); var documentRange = new DocumentRange(sourceFile.Document, occuranceRange); var occurence = new RangeOccurence(sourceFile, documentRange); lock (consumer) { consumer.Add(occurence); } if (checkCancelled()) break; index++; } }