public void InhaleScopesInsideSelection(int length, int startPosInParent, Scope inhaleTo) { ScopeSplitter splitter = new ScopeSplitter(); splitter.AutoSplit(this, startPosInParent, length, true); List <Scope> scopesToInhale = FindScopesInRange(startPosInParent, length); if (scopesToInhale.Count > 0) { inhaleTo.innerLeftScope = scopesToInhale[0]; if (scopesToInhale.Count == 3) { inhaleTo.innerMiddleScope = scopesToInhale[1]; inhaleTo.innerMiddleScope.parentScope = inhaleTo; inhaleTo.innerRightScope = scopesToInhale[2]; } else { inhaleTo.innerRightScope = scopesToInhale[1]; } inhaleTo.innerLeftScope.parentScope = inhaleTo; inhaleTo.innerRightScope.parentScope = inhaleTo; } }
public void DefineInnerScope_WithleftMiddleandRightScopesasInner() { Scope root = new Scope("012345"); root.DefineInnerScope(3, 1);//012|3|45 ScopeSplitter splitter = new ScopeSplitter(); splitter.AutoSplit(root, 2, 3, true);//01|(2|3|4)|5 Scope encapsulator = root.DefineInnerScope(2, 3); Assert.AreEqual("2", encapsulator.InnerLeftScope.Text); Assert.AreEqual("3", encapsulator.InnerMiddleScope.Text); Assert.AreEqual("4", encapsulator.InnerRightScope.Text); }
public void AutoScope(Scope root) { if (autoAdvisor == null) { return; } foreach (Suggestion possibility in autoAdvisor.possibleMatches) { Match match = Regex.Match(root.Text, possibility.RegexText); if (match.Success) { Scope innerScope = root.FindInnerScope(match.Index, match.Length); if (innerScope == null || innerScope.Length != match.Length) { List <SplitPoint> points = new ScopeSplitter().GetSplitPoints(root, match.Index, match.Length); bool willNewScopeBeInsdeAScopeWithSuggestions = false; if (points.Count > 0) { foreach (SplitPoint point in points) { Scope target = root.FindInnerScope(point.StartIndex, point.Length); if (target != null && target.Suggestions.Count > 0) { willNewScopeBeInsdeAScopeWithSuggestions = true; break; } } } if (!willNewScopeBeInsdeAScopeWithSuggestions) { innerScope = root.DefineInnerScope(match.Index, match.Length); } } if (innerScope != null) { innerScope.Suggestions.Add(possibility); innerScope.IsExplicit = true; } } } }
public void AutoScope(Scope root) { if(autoAdvisor==null) { return; } foreach (Suggestion possibility in autoAdvisor.possibleMatches) { Match match = Regex.Match(root.Text, possibility.RegexText); if (match.Success) { Scope innerScope = root.FindInnerScope(match.Index, match.Length); if (innerScope == null || innerScope.Length!=match.Length) { List<SplitPoint> points = new ScopeSplitter().GetSplitPoints(root, match.Index, match.Length); bool willNewScopeBeInsdeAScopeWithSuggestions = false; if (points.Count>0) { foreach (SplitPoint point in points) { Scope target = root.FindInnerScope(point.StartIndex, point.Length); if(target!=null && target.Suggestions.Count>0) { willNewScopeBeInsdeAScopeWithSuggestions = true; break; } } } if(!willNewScopeBeInsdeAScopeWithSuggestions) innerScope = root.DefineInnerScope(match.Index, match.Length); } if (innerScope!=null) { innerScope.Suggestions.Add(possibility); innerScope.IsExplicit = true; } } } }
public void InhaleScopesInsideSelection(int length, int startPosInParent, Scope inhaleTo) { ScopeSplitter splitter = new ScopeSplitter(); splitter.AutoSplit(this, startPosInParent, length,true); List<Scope> scopesToInhale = FindScopesInRange(startPosInParent, length); if (scopesToInhale.Count > 0) { inhaleTo.innerLeftScope = scopesToInhale[0]; if (scopesToInhale.Count == 3) { inhaleTo.innerMiddleScope = scopesToInhale[1]; inhaleTo.innerMiddleScope.parentScope = inhaleTo; inhaleTo.innerRightScope = scopesToInhale[2]; } else { inhaleTo.innerRightScope = scopesToInhale[1]; } inhaleTo.innerLeftScope.parentScope = inhaleTo; inhaleTo.innerRightScope.parentScope = inhaleTo; } }