public void ReplaceAll(string searchPattern, string replaceValue, RegexSearchReplaceScope scope) { var results = Search(searchPattern, scope); foreach (RegexSearchResult result in results) { string originalLine = result.Module.Lines[result.Selection.StartLine, 1]; var newLine = originalLine.Replace(result.Match.Value, replaceValue); result.Module.ReplaceLine(result.Selection.StartLine, newLine); } }
public void ReplaceAll(string searchPattern, string replaceValue, RegexSearchReplaceScope scope) { var results = Search(searchPattern, scope); foreach (var result in results) { var originalLine = result.Module.GetLines(result.Selection.StartLine, 1); var newLine = originalLine.Replace(result.Match.Value, replaceValue); result.Module.ReplaceLine(result.Selection.StartLine, newLine); } }
public IEnumerable<RegexSearchResult> Search(string searchPattern, RegexSearchReplaceScope scope = RegexSearchReplaceScope.CurrentFile) { Func<string,IEnumerable<RegexSearchResult>> searchFunc; if (_search.TryGetValue(scope, out searchFunc)) { return searchFunc.Invoke(searchPattern); } else { return new List<RegexSearchResult>(); } }
public IEnumerable <RegexSearchResult> Search(string searchPattern, RegexSearchReplaceScope scope = RegexSearchReplaceScope.CurrentFile) { Func <string, IEnumerable <RegexSearchResult> > searchFunc; if (_search.TryGetValue(scope, out searchFunc)) { return(searchFunc.Invoke(searchPattern)); } else { return(new List <RegexSearchResult>()); } }
public void Replace(string searchPattern, string replaceValue, RegexSearchReplaceScope scope) { var results = Search(searchPattern, scope).ToList(); if (results.Count == 0) { return; } RegexSearchResult result = results[0]; string originalLine = result.Module.Lines[results[0].Selection.StartLine, 1]; var newLine = originalLine.Replace(result.Match.Value, replaceValue); result.Module.ReplaceLine(result.Selection.StartLine, newLine); if (results.Count >= 2) { SetSelection(results[1]); } }
public void Replace(string searchPattern, string replaceValue, RegexSearchReplaceScope scope) { var results = Search(searchPattern, scope).ToList(); if (results.Count == 0) { return; } var result = results[0]; var originalLine = result.Module.GetLines(results[0].Selection.StartLine, 1); var newLine = originalLine.Replace(result.Match.Value, replaceValue); result.Module.ReplaceLine(result.Selection.StartLine, newLine); if (results.Count >= 2) { SetSelection(results[1]); } }
public IEnumerable <RegexSearchResult> Search(string searchPattern, RegexSearchReplaceScope scope = RegexSearchReplaceScope.CurrentFile) { return(_search.TryGetValue(scope, out var searchFunc) ? searchFunc.Invoke(searchPattern) : new List <RegexSearchResult>()); }