예제 #1
0
        public string Deactivate(bool reset = true)
        {
            string result = "";

            if (reset)
            {
                _target.Text     = _originalText;
                _renameLocations = null;
            }
            else
            {
                result = _target.Text;
            }

            _target = null;

            foreach (var element in _registeredElements)
            {
                element.Deactivate();
            }

            _registeredElements.Clear();

            CodeEditor.TextArea.PopStackedInputHandler(_inputHandler);

            return(result);
        }
예제 #2
0
        public void Activate(RenamingTextElement target)
        {
            _target       = target;
            _originalText = target.Text;

            if (_registeredElements.Count > 0)
            {
                foreach (var element in _registeredElements)
                {
                    element.Activate(target);
                }

                _inputHandler = new RenameInputHandler(this);

                // disable existing snippet input handlers - there can be only 1 active snippet
                foreach (TextAreaStackedInputHandler h in CodeEditor.TextArea.StackedInputHandlers)
                {
                    if (h is RenameInputHandler)
                    {
                        CodeEditor.TextArea.PopStackedInputHandler(h);
                    }
                }
                CodeEditor.TextArea.PushStackedInputHandler(_inputHandler);
            }
            else
            {
                Deactivate();
            }
        }
예제 #3
0
        private RenamingTextElement RegisterElement(CodeEditor editor, int start, int length)
        {
            var result = new RenamingTextElement(editor.TextArea, start, length);

            _registeredElements.Add(result);

            return(result);
        }
예제 #4
0
        public void Start(IEnumerable <SymbolRenameInfo> renameLocations, int offset)
        {
            _renameLocations = renameLocations;
            RenamingTextElement masterElement = null;

            foreach (var location in renameLocations)
            {
                CodeEditor editor = null;

                if (CodeEditor.SourceFile.CompareTo(location.FileName) == 0)
                {
                    editor = CodeEditor;
                }
                else
                {
                    var currentTab = IoC.Get <IShell>().GetDocument(location.FileName);

                    if (currentTab is EditorAdaptor adaptor)
                    {
                        editor = adaptor.EditorImpl;
                    }
                }

                if (editor != null)
                {
                    foreach (var change in location.Changes)
                    {
                        var start = editor.Document.GetOffset(change.StartLine, change.StartColumn);
                        var end   = editor.Document.GetOffset(change.EndLine, change.EndColumn);

                        var currentElement = RegisterElement(editor, start, end - start);

                        if (editor == CodeEditor && masterElement == null && offset >= start && offset <= end)
                        {
                            masterElement = currentElement;
                        }
                    }
                }
            }

            if (masterElement != null)
            {
                Activate(masterElement);
            }
            else
            {
            }
        }