Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Fixed inconsistent naming tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Krüger committed Mar 27, 2012
1 parent 74e365b commit a14ed3b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,52 @@ public override void InsertWithCursor (string operation, AstNode node, ITypeDefi
InsertText (startOffset, output.Text);
output.RegisterTrackedSegments (this, startOffset);
}

void Rename (AstNode node, string newName)
{
if (node is ObjectCreateExpression)
node = ((ObjectCreateExpression)node).Type;

if (node is InvocationExpression)
node = ((InvocationExpression)node).Target;

if (node is MemberReferenceExpression)
node = ((MemberReferenceExpression)node).MemberNameToken;

if (node is MemberType)
node = ((MemberType)node).MemberNameToken;

if (node is EntityDeclaration)
node = ((EntityDeclaration)node).NameToken;

if (node is ParameterDeclaration)
node = ((ParameterDeclaration)node).NameToken;
if (node is ConstructorDeclaration)
node = ((ConstructorDeclaration)node).NameToken;
if (node is DestructorDeclaration)
node = ((DestructorDeclaration)node).NameToken;
Replace (node, new IdentifierExpression (newName));
}

public override void Rename (IEntity entity, string name)
{
FindReferences refFinder = new FindReferences ();
refFinder.FindReferencesInFile (refFinder.GetSearchScopes (entity),
context.ParsedFile,
context.RootNode as CompilationUnit,
context.Compilation, (n, r) => Rename (n, name),
context.CancellationToken);
}

public override void Rename (IVariable variable, string name)
{
FindReferences refFinder = new FindReferences ();
refFinder.FindLocalReferences (variable,
context.ParsedFile,
context.RootNode as CompilationUnit,
context.Compilation, (n, r) => Rename (n, name),
context.CancellationToken);
}
}

#region Text stuff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

namespace ICSharpCode.NRefactory.CSharp.CodeIssues
{
[Ignore("Implement Rename in TestContext")]
[TestFixture]
public class InconsistentNamingTests : InspectionActionTestBase
{
Expand Down

0 comments on commit a14ed3b

Please sign in to comment.