コード例 #1
0
        internal static void AddToQueue(Rename rename)
        {
            queue.Enqueue(rename);

            if (currentCommand != null) return;
            currentCommand = rename;

            var doc = PluginBase.MainForm.CurrentDocument;
            startState = new StartState
            {
                FileName = doc.FileName,
                CursorPosition = doc.SciControl.CurrentPos,
                Commands = new[] { rename, null, null }
            };

            var target = rename.Target;
            bool outputResults = rename.OutputResults;
            if (HasGetterSetter(target))
            {
                string oldName = rename.OldName;
                string newName = rename.NewName;
                var list = target.Member.Parameters;
                if (list[0].Name == ParamGetter) startState.Commands[1] = RenameMember(target, PrefixGetter + oldName, PrefixGetter + newName, outputResults);
                if (list[1].Name == ParamSetter) startState.Commands[2] = RenameMember(target, PrefixSetter + oldName, PrefixSetter + newName, outputResults);
            }
            else if ((RefactoringHelper.GetRefactoringTarget(target).Flags & (FlagType.Constructor | FlagType.Class)) > 0)
            {
                var ext = Path.GetExtension(startState.FileName);
                startState.FileName = startState.FileName.Replace(rename.OldName + ext, rename.NewName + ext);
            }

            if (outputResults) PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ClearResults");

            ExecuteFirst();
        }
コード例 #2
0
 private static void ExecuteFirst()
 {
     try
     {
         currentCommand = queue.Dequeue();
         currentCommand.OnRefactorComplete += OnRefactorComplete;
         currentCommand.Execute();
     }
     catch (Exception ex)
     {
         queue.Clear();
         currentCommand = null;
         startState = null;
         ErrorManager.ShowError(ex);
     }
 }
コード例 #3
0
 private static void OnRefactorComplete(object sender, RefactorCompleteEventArgs<IDictionary<string, List<SearchMatch>>> e)
 {
     currentCommand.OnRefactorComplete -= OnRefactorComplete;
     if (queue.Count == 0)
     {
         //if (currentCommand.OutputResults)
         //{
         //    PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults");
         //}
         if (startState != null) RestoreStartState();
         currentCommand = null;
         startState = null;
     }
     else ExecuteFirst();
 }