public void Suggest_NoSuggestionsWithSpecialMarks_SuggestsExactTextEscaped() { RegexAdvisor s = new RegexAdvisor(); List <Suggestion> suggestions = s.Suggest(@"\a"); Assert.AreEqual(new Suggestion(@"^\\a$", @"Exactly '\a'", 900), suggestions[0]); }
public void Suggest_NoSuggestions_SuggestsExactText2() { RegexAdvisor s = new RegexAdvisor(); List <Suggestion> suggestions = s.Suggest("b"); Assert.AreEqual(new Suggestion("^b$", "Exactly 'b'", 900), suggestions[0]); }
public void Suggest_InputTextLegthExceedsMaxSuggestionLength_SuggestsExactTrimmedText2() { RegexAdvisor s = new RegexAdvisor(); s.MaxSuggestionLength = 2; List <Suggestion> suggestions = s.Suggest("abc"); Assert.AreEqual(new Suggestion("^abc$", "Exactly 'ab...'", 900), suggestions[0]); }
public void Suggest_NoSuggestionsImplicitScope_SuggestsExactText() { RegexAdvisor s = new RegexAdvisor(); Scope scope = new Scope("abc"); scope.DefineInnerScope(1, 1); List <Suggestion> suggestions = s.Suggest(scope.InnerRightScope); Assert.AreEqual(new Suggestion("^c$", "Exactly 'c'", 900), suggestions[0]); }
public void Suggest_CombinedScopes_SuggestsExactWhenPossible() { RegexAdvisor s = new RegexAdvisor(); s.Learn(new Suggestion(@"\w", "any letter or num", 100)); Scope scope = new Scope("abc"); scope.DefineInnerScope(1, 1); List <Suggestion> suggestions = s.Suggest(scope); Assert.AreEqual(new Suggestion("^a$^b$^c$", "Combined"), suggestions[0]); }
public List <Suggestion> GetSuggestionsOLD(Scope target) { RegexAdvisor advisor = new RegexAdvisor(); advisor.Learn(Resources.RulesFile); string selection; if (target != null) { selection = target.Text; } else { selection = txt.SelectedText; } return(advisor.Suggest(selection)); }
public List <Suggestion> GetSuggestions(Scope target) { RegexAdvisor advisor = new RegexAdvisor(); advisor.MaxSuggestionLength = 45; TeachRules(advisor); string selection; if (target != null) { selection = target.Text; } else { selection = txt.SelectedText; } return(advisor.Suggest(selection)); }
private void RefreshResultsOLD(bool makeAutoScopes) { if (DateTime.Now > new DateTime(2006, 12, 11)) { DialogResult result = MessageBox.Show("This limited beta has expired.\n Press OK to go to the product homepage and download a new version.", "Application Expired", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { NavURL("http://regulazy.osherove.com"); } return; } Scope root = txtRegexInput.RootScope; RegexAdvisor advisor = GetAdvisor(); WaitCallback onThreadFinish = new WaitCallback(OnSuggestThreadFinish); string regex = advisor.Suggest(root)[0].RegexText; regex = optimize(regex); regex = decideIfStartOrEndLine(regex); results.RegexText = regex; results.RefreshResults(); results.ShowScopeTree(root); }
private void RefreshResults(bool makeAutoScopes) { // if (DateTime.Now > new DateTime(2006, 12, 12)) // { // DialogResult result = MessageBox.Show("This limited beta has expired.\n Press OK to go to the product homepage and download a new version.", "Application Expired", MessageBoxButtons.OKCancel); // if (result == DialogResult.OK) // { // NavURL("http://regulazy.osherove.com"); // } // return; // } Scope root = txtRegexInput.RootScope; RegexAdvisor advisor = new RegexAdvisor(); UIActionSuggestionProvider.TeachRules(advisor); // if (makeAutoScopes) // { //// ThreadStart start = delegate //// { // advisor.AutoScope(root); //// }; //// //// Thread runner = new Thread(start); //// runner.Start(); // } results.ShowInProgress(); ThreadPool.QueueUserWorkItem(delegate { Application.DoEvents(); string regex = advisor.Suggest(root)[0].RegexText; regex = optimize(regex); regex = decideIfStartOrEndLine(regex); UIShowResultsAfterSuggest(root, regex); }); }
public void Suggest_NoSuggestions_SuggestsExactText2() { RegexAdvisor s = new RegexAdvisor(); List<Suggestion> suggestions = s.Suggest("b"); Assert.AreEqual(new Suggestion("^b$", "Exactly 'b'", 900), suggestions[0]); }
public void Suggest_NoSuggestionsWithSpecialMarks_SuggestsExactTextEscaped() { RegexAdvisor s = new RegexAdvisor(); List<Suggestion> suggestions = s.Suggest(@"\a"); Assert.AreEqual(new Suggestion(@"^\\a$", @"Exactly '\a'", 900), suggestions[0]); }
public void Suggest_NoSuggestionsImplicitScope_SuggestsExactText() { RegexAdvisor s = new RegexAdvisor(); Scope scope = new Scope("abc"); scope.DefineInnerScope(1, 1); List<Suggestion> suggestions = s.Suggest(scope.InnerRightScope); Assert.AreEqual(new Suggestion("^c$", "Exactly 'c'", 900), suggestions[0]); }
public void Suggest_InputTextLegthExceedsMaxSuggestionLength_SuggestsExactTrimmedText2() { RegexAdvisor s = new RegexAdvisor(); s.MaxSuggestionLength = 2; List<Suggestion> suggestions = s.Suggest("abc"); Assert.AreEqual(new Suggestion("^abc$", "Exactly 'ab...'", 900), suggestions[0]); }
public void Suggest_CombinedScopes_SuggestsExactWhenPossible() { RegexAdvisor s = new RegexAdvisor(); s.Learn(new Suggestion(@"\w", "any letter or num", 100)); Scope scope = new Scope("abc"); scope.DefineInnerScope(1, 1); List<Suggestion> suggestions = s.Suggest(scope); Assert.AreEqual(new Suggestion("^a$^b$^c$", "Combined"), suggestions[0]); }
public void Sugggest_NamedScopeWithInnerScopes_ReturnesCombinedInsideGroup() { Scope root = new Scope("abc", "RootName"); root.DefineInnerScope(1, 1); Suggestion suggestion = suggest.Suggest(root)[0]; Assert.AreEqual(@"(?<RootName>^a$^b$^c$)", suggestion.RegexText); }