private static void AddActionsOnSelectedText(ScopeActionsInfo info) { if (txt.ActiveScope != null) { string curText = txt.ActiveScope.Text; string curSel = txt.SelectedText; bool isSelectionSameActiveScope = curSel.Length == 0 || curSel == curText; if (isSelectionSameActiveScope) { ScopeRenameAction rename = new ScopeRenameAction(txt.ActiveScope, txt); info.UserActions.Add(rename); } else { AddDefineNewAreaWithNameAction(info); } } }
// private static void AddGroupheseAction(ScopeActionsInfo info) // { // if(txt.SelectedText.Length>0) // { // int start = txt.SelectionStart; // int length = txt.SelectionLength; // // List<Scope> scopes = txt.RootScope.FindScopesInRange(start, length); // if(scopes.Count>1) // { // DefineEncapsulatingScopeAction define = new DefineEncapsulatingScopeAction(txt, txt.RootScope); // info.UserActions.Add(define); // } // } // } private static void AddRenameAction(ScopeActionsInfo info, Scope target) { ScopeRenameAction rename = new ScopeRenameAction(target, txt); info.UserActions.Add(rename); Scope parent = target.ParentScope; if (target.IsRoot) { return; } string parentLevelPrefix = "-----"; while (parent != null) { ScopeRenameAction renameParentScope = new ScopeRenameAction(parent, txt); renameParentScope.TitlePrefix = parentLevelPrefix + "| Rename Parent"; info.UserActions.Add(renameParentScope); parent = parent.ParentScope; parentLevelPrefix += "-----"; } }