Bug 129165 [quick fix] 'Change modifier to final' changes order of variable decl fragments
I20060221-1300 Given: int i= 1, j= i + 1, h= j + 1; Serializable ser= new Serializable() { void foo() { System.out.println(j); } }; Then make j final with quick fix 'Change modifier of 'j' to final' Result: int i= 1, h= j + 1; final int j= i + 1; Serializable ser= new Serializable() { void foo() { System.out.println(j); } }; Expected: int i= 1; final int j= i + 1; int h= j + 1; Serializable ser= new Serializable() { void foo() { System.out.println(j); } }; The order of the declarations must be preserved.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierChangeCompletionProposal.java
return rewrite;
					}
				} else if (parent instanceof VariableDeclarationStatement) {
					VariableDeclarationStatement varDecl= (VariableDeclarationStatement) parent;
					if (varDecl.fragments().size() > 1 && (varDecl.getParent() instanceof Block)) { 
						VariableDeclarationFragment placeholder= (VariableDeclarationFragment) rewrite.createMoveTarget(declNode);
						VariableDeclarationStatement newStat= ast.newVariableDeclarationStatement(placeholder);
						newStat.setType((Type) ASTNode.copySubtree(ast, varDecl.getType()));
						newStat.modifiers().addAll(ast.newModifiers((newStat.getModifiers() & ~fExcludedModifiers) | fIncludedModifiers));
						ListRewrite listRewrite= rewrite.getListRewrite(varDecl.getParent(), Block.STATEMENTS_PROPERTY);
						if (varDecl.fragments().indexOf(declNode) == 0) { 
							listRewrite.insertBefore(newStat, parent, null);
						} else {
							listRewrite.insertAfter(newStat, parent, null);
						}
						return rewrite;
					}
				} else if (parent instanceof VariableDeclarationExpression) {
					
				}
				declNode= parent;
			}
			ModifierRewrite listRewrite= ModifierRewrite.create(rewrite, declNode);
			listRewrite.setModifiers(fIncludedModifiers, fExcludedModifiers, selectionDescription);
			return rewrite;
		}
		return null;
	}
}