Exemplo n.º 1
0
        private IRenameStrategy GetStrategy(bool isCaseSensitive)
        {
            var strategies = new IRenameStrategy[] {
                new SimpleRenameStrategy(_threadingService, _userNotificationServices, _environmentOptions, _roslynServices)
            };

            return(strategies.FirstOrDefault(s => s.CanHandleRename(_oldFilePath, _newFilePath, isCaseSensitive)));
        }
Exemplo n.º 2
0
        public async Task RenameAsync(Project project)
        {
            bool isCaseSensitive = await IsCompilationCaseSensitiveAsync(project).ConfigureAwait(false);

            IRenameStrategy renameStrategy = GetStrategy(project, isCaseSensitive);

            if (renameStrategy != null)
            {
                await renameStrategy.RenameAsync(project, _oldFilePath, _newFilePath, isCaseSensitive).ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        private async Task <IRenameStrategy> GetStrategyAsync(Project project)
        {
            IRenameStrategy[] strategies = new IRenameStrategy[] {
                new SimpleRenameStrategy(_threadingService, _userNotificationServices, _environmentOptions, _roslynServices)
            };

            var isCaseSensitive = false;
            var compilation     = await project.GetCompilationAsync().ConfigureAwait(false);

            if (compilation != null)
            {
                isCaseSensitive = compilation.IsCaseSensitive;
            }
            return(strategies.FirstOrDefault(s => s.CanHandleRename(_oldFilePath, _newFilePath, isCaseSensitive)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates IRenameStrategy by elementType.
        /// </summary>
        /// <param name="elementType">Type of CodeElement.</param>
        /// <returns>IRenameStrategy implementation.</returns>
        public static IRenameStrategy Create(vsCMElement elementType)
        {
            IRenameStrategy result = null;

            switch (elementType)
            {
            case vsCMElement.vsCMElementFunctionInvokeStmt:
            case vsCMElement.vsCMElementFunction:
            { result = new FunctionRenameStrategy(); break; }

            case vsCMElement.vsCMElementVariable:
            case vsCMElement.vsCMElementMap:
            case vsCMElement.vsCMElementLocalDeclStmt:
            case vsCMElement.vsCMElementDefineStmt:
            case vsCMElement.vsCMElementDeclareDecl:
            { result = new VariableRenameStrategy(); break; }
            }
            return(result);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidStrategyException"/> class.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="strategy">The strategy.</param>
 internal InvalidStrategyException(string message, IRenameStrategy strategy)
     : base(message)
 {
     this.strategy = strategy;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InvalidStrategyException"/> class.
 /// </summary>
 /// <param name="strategy">The strategy.</param>
 internal InvalidStrategyException(IRenameStrategy strategy)
     : this(String.Empty, strategy)
 {
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeElementRenameContext"/> class.
 /// </summary>
 /// <param name="strategy">The strategy.</param>
 internal CodeElementRenameContext(IRenameStrategy strategy)
 {
     CodeElementRename = strategy;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeElementRenameContext"/> class.
 /// </summary>
 /// <param name="strategy">The strategy.</param>
 internal CodeElementRenameContext(IRenameStrategy strategy)
 {
     CodeElementRename = strategy;
 }