Bug 120389 [quick fix] replace conditional with if-else removes + from +=
Using Build I20051102-1600. I create a class [snip] package bla; class Bla { void bla() { boolean cond = true; int i = 42; i += ( cond ) ? 1 : 2; } } [snap] Now I move the cursor over the second cond and trigger the Quickfix 'Replace conditional with if-else'. This results in [snip] int i = 42; if (cond) i = 1; else i = 2; [snap] i.e. replaces the '+=' with '='. (Credit to Jordi Boehme for finding this.)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/AdvancedQuickAssistProcessor.java
CastExpression castExpression= ast.newCastExpression();
		castExpression.setExpression((Expression) rewrite.createCopyTarget(expression.getLeftOperand()));
		castExpression.setType((Type) ASTNode.copySubtree(ast, originalType));
		
		VariableDeclarationFragment vdf= ast.newVariableDeclarationFragment();
		vdf.setName(ast.newSimpleName(varNames[0]));
		vdf.setInitializer(castExpression);
		
		VariableDeclarationStatement vds= ast.newVariableDeclarationStatement(vdf);
		vds.setType((Type) ASTNode.copySubtree(ast, originalType));
		
		if (body instanceof Block) {
			ListRewrite listRewriter= rewrite.getListRewrite(body, Block.STATEMENTS_PROPERTY);
			listRewriter.insertAt(vds, 0, null);
		} else {
			Block newBlock= ast.newBlock();
			List statements= newBlock.statements();
			statements.add(vds);
			statements.add(rewrite.createMoveTarget(body));
			rewrite.replace(body, newBlock, null);
		}
		
		proposal.addLinkedPosition(rewrite.track(vdf.getName()), true, KEY_NAME);
		proposal.addLinkedPosition(rewrite.track(vds.getType()), false, KEY_TYPE);
		proposal.addLinkedPosition(rewrite.track(castExpression.getType()), false, KEY_TYPE);
		proposal.setEndPosition(rewrite.track(vds)); 
		
		resultingCollections.add(proposal);
		return true;
	}