Community
Participate
Working Groups
public class X { int int1, int2, int3; } Call ISourceManipulation#rename for field int2. Field int1 will get renamed instead of int2. This is broken in both 3.1.1 and 3.2 The following test case (org.eclipse.jdt.core.tests.model.RenameTests) would not pass: public void testBugWrongFieldGetsRenamed() throws Exception { this.createJavaProject("P1", new String[] {"src"}, "bin"); this.createFile( "/P1/src/X.java", "public class X {\n" + " int int1, int2, int3;\n" + "}" ); ICompilationUnit c = getCompilationUnit("/P1/src/X.java"); IType type = c.getType("X"); IField field = type.getField("int2"); renamePositive(field, "int2_renamed", false); field = type.getField("int1"); assertTrue("int1 should exist", field != null && field.exists()); field = type.getField("int2_renamed"); assertTrue("int2_renamed should exist", field != null && field.exists()); field = type.getField("int3"); assertTrue("int3 should exist", field != null && field.exists()); }
Thanks for the test case. It helped a lot. Changed CreateFieldOperation#rename(ASTNode, SimpleName) to find the right fragment first. Added regression test RenameTests#testRenameFieldFragment().
Verified with for 3.2 M5 using build I20060214-0010.