提交 bfc2402b 编写于 作者: C CyrusNajmabadi

Make names clearer.

上级 b9a3e825
......@@ -95,22 +95,24 @@ public override int GetHashCode()
protected async Task<(SyntaxNode, Document)> ReplaceNameNodeAsync(
SyntaxNode contextNode, Document document, CancellationToken cancellationToken)
{
if (this.SearchResult.DesiredNameDiffersFromSourceName())
if (!this.SearchResult.DesiredNameDiffersFromSourceName())
{
var identifier = SearchResult.NameNode.GetFirstToken();
var generator = SyntaxGenerator.GetGenerator(document);
var newIdentifier = generator.IdentifierName(SearchResult.DesiredName).GetFirstToken().WithTriviaFrom(identifier);
var annotation = new SyntaxAnnotation();
return (contextNode, document);
}
var root = contextNode.SyntaxTree.GetRoot(cancellationToken);
root = root.ReplaceToken(identifier, newIdentifier.WithAdditionalAnnotations(annotation));
document = document.WithSyntaxRoot(root);
var identifier = SearchResult.NameNode.GetFirstToken();
var generator = SyntaxGenerator.GetGenerator(document);
var newIdentifier = generator.IdentifierName(SearchResult.DesiredName).GetFirstToken().WithTriviaFrom(identifier);
var annotation = new SyntaxAnnotation();
var currentRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
contextNode = currentRoot.GetAnnotatedTokens(annotation).First().Parent;
}
var root = contextNode.SyntaxTree.GetRoot(cancellationToken);
root = root.ReplaceToken(identifier, newIdentifier.WithAdditionalAnnotations(annotation));
var newDocument = document.WithSyntaxRoot(root);
var newRoot = await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var newContextNode = newRoot.GetAnnotatedTokens(annotation).First().Parent;
return (contextNode, document);
return (newContextNode, newDocument);
}
public abstract Task<CodeAction> CreateCodeActionAsync(Document document, SyntaxNode node, bool placeSystemNamespaceFirst, CancellationToken cancellationToken);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册