예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 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>();
     }
 }
예제 #4
0
        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>());
            }
        }
예제 #5
0
        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]);
            }
        }
예제 #6
0
        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]);
            }
        }
예제 #7
0
 public IEnumerable <RegexSearchResult> Search(string searchPattern, RegexSearchReplaceScope scope = RegexSearchReplaceScope.CurrentFile)
 {
     return(_search.TryGetValue(scope, out var searchFunc)
         ? searchFunc.Invoke(searchPattern)
         : new List <RegexSearchResult>());
 }