public RenameReferencesInFile ( IList |
||
searchScopes | IList |
|
newName | string | |
resolver | ICSharpCode.NRefactory.CSharp.Resolver.CSharpAstResolver | |
callback | Action |
|
errorCallback | Action |
|
cancellationToken | ||
return | void |
public void RenameReferencesInFile(IList<IFindReferenceSearchScope> searchScopes, string newName, CSharpAstResolver resolver,
Action<RenameCallbackArguments> callback, Action<Error> errorCallback, CancellationToken cancellationToken = default (CancellationToken))
{
FindReferencesInFile(
searchScopes,
resolver,
delegate(AstNode astNode, ResolveResult result) {
var nodeToReplace = GetNodeToReplace(astNode);
if (nodeToReplace == null) {
errorCallback (new Error (ErrorType.Error, "no node to replace found."));
return;
}
callback (new RenameCallbackArguments(nodeToReplace, Identifier.Create(newName)));
},
cancellationToken);
}
#endregion
IList <AstNode> Rename(string fullyQualifiedName, string newName, bool includeOverloads) { var sym = GetSymbol(compilation, fullyQualifiedName); Assert.NotNull(sym); var graph = new TypeGraph(compilation.Assemblies); var col = new SymbolCollector(); col.IncludeOverloads = includeOverloads; col.GroupForRenaming = true; var scopes = findReferences.GetSearchScopes(col.GetRelatedSymbols(graph, sym)); List <AstNode> result = new List <AstNode>(); findReferences.RenameReferencesInFile( scopes, newName, new CSharpAstResolver(compilation, syntaxTree, unresolvedFile), delegate(RenameCallbackArguments obj) { result.Add(obj.NodeToReplace); }, delegate(Error obj) { }); return(result); }