private IRenameStrategy GetStrategy(bool isCaseSensitive) { var strategies = new IRenameStrategy[] { new SimpleRenameStrategy(_threadingService, _userNotificationServices, _environmentOptions, _roslynServices) }; return(strategies.FirstOrDefault(s => s.CanHandleRename(_oldFilePath, _newFilePath, isCaseSensitive))); }
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); } }
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))); }
/// <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); }
/// <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; }
/// <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) { }
/// <summary> /// Initializes a new instance of the <see cref="CodeElementRenameContext"/> class. /// </summary> /// <param name="strategy">The strategy.</param> internal CodeElementRenameContext(IRenameStrategy strategy) { CodeElementRename = strategy; }