/// <summary>
        /// Rename function in scope of parentElement.
        /// </summary>
        /// <param name="element">Element to rename.</param>
        /// <param name="parentElement">Containing element.</param>
        /// <param name="elementType">Type of element.</param>
        /// <param name="oldName">Old name of element.</param>
        /// <param name="newName">New name of element.</param>
        public override IRenameResult RenameSymbols(CodeElement element, LuaCodeClass parentElement,
                                                    vsCMElement elementType, string oldName, string newName)
        {
            renameResult        = new RenameResult(oldName, newName);
            changedCodeElements = new List <CodeElement>();

            //Function without parent element could not be renamed
            if (element is LuaCodeFunction && parentElement == null)
            {
                var ex = new InvalidCodeElementException(Resources.InvalidFunctionParentMessage, parentElement);
                Trace.WriteLine(ex);
                throw ex;
            }
            //Rename function, function calls or null element by its name
            if (element is LuaCodeFunction || element is LuaCodeElement <FunctionCall> || element == null)
            {
                renameResult = Rename(element, parentElement, oldName, newName);
            }
            else
            {
                throw new InvalidCodeElementException(
                          Resources.InvalidFunctionElementMessage, parentElement);
            }

            //Set RenameReferences flag to indicates that rename is local or not
            renameResult.RenameReferences = !IsLocalDeclaration;
            renameResult.ChangedElements  = changedCodeElements;

            renameResult.Success = true;

            return(renameResult);
        }
Exemple #2
0
        /// <summary>
        /// Rename function in scope of parentElement.
        /// </summary>
        /// <param name="element">Element to rename.</param>
        /// <param name="parentElement">Containing element.</param>
        /// <param name="elementType">Type of element.</param>
        /// <param name="oldName">Old name of element.</param>
        /// <param name="newName">New name of element.</param>
        public override IRenameResult RenameSymbols(CodeElement element, LuaCodeClass parentElement, 
            vsCMElement elementType, string oldName, string newName)
        {
            renameResult = new RenameResult(oldName, newName);
            changedCodeElements = new List<CodeElement>();

            //Function without parent element could not be renamed
            if (element is LuaCodeFunction && parentElement == null)
            {
                var ex = new InvalidCodeElementException(Resources.InvalidFunctionParentMessage, parentElement);
                Trace.WriteLine(ex);
                throw ex;
            }
            //Rename function, function calls or null element by its name
            if (element is LuaCodeFunction || element is LuaCodeElement<FunctionCall> || element == null)
            {
                renameResult = Rename(element, parentElement, oldName, newName);
            }
            else
            {
                throw new InvalidCodeElementException(
                    Resources.InvalidFunctionElementMessage, parentElement);
            }

            //Set RenameReferences flag to indicates that rename is local or not
            renameResult.RenameReferences = !IsLocalDeclaration;
            renameResult.ChangedElements = changedCodeElements;

            renameResult.Success = true;

            return renameResult;
        }