positionGroups.addAll(getAllPositionGroups()); return null;
	public ITrackedNodePosition rewriteAST(CompilationUnitRewrite cuRewrite, List textEditGroups, List positionGroups) throws CoreException {		final TextEditGroup group= createTextEditGroup(FixMessages.Java50Fix_ConvertToEnhancedForLoop_description);		textEditGroups.add(group);		clearPositionGroups();				final AST ast= cuRewrite.getAST();		final ASTRewrite astRewrite= cuRewrite.getASTRewrite();		final ImportRewrite importRewrite= cuRewrite.getImportRewrite();			final ImportRemover remover= new ImportRemover(fCompilationUnit.getJavaProject(), (CompilationUnit) fStatement.getRoot());				fEnhancedForLoop= ast.newEnhancedForStatement();		final List names= computeElementNames();		String name= fIdentifierName;		if (fElement != null) {			name= fElement.getName();			if (!names.contains(name))				names.add(0, name);		} else {			if (!names.isEmpty())				name= (String) names.get(0);		}		for (final Iterator iterator= names.iterator(); iterator.hasNext();)			getPositionGroup(fIdentifierName).addProposal((String) iterator.next(), null);				final Statement body= fStatement.getBody();		if (body != null) {			final ListRewrite list;			if (body instanceof Block) {				list= astRewrite.getListRewrite(body, Block.STATEMENTS_PROPERTY);				for (final Iterator iterator= fOccurrences.iterator(); iterator.hasNext();) {					final Statement parent= (Statement) ASTNodes.getParent((ASTNode) iterator.next(), Statement.class);					if (parent != null && list.getRewrittenList().contains(parent)) {						list.remove(parent, null);						remover.registerRemovedNode(parent);					}				}			} else {				list= null;			}			final String text= name;			body.accept(new ASTVisitor() {				private boolean replace(final Expression expression) {					final SimpleName node= ast.newSimpleName(text);					astRewrite.replace(expression, node, group);					remover.registerRemovedNode(expression);					getPositionGroup(fIdentifierName).addPosition(astRewrite.track(node));					return false;				}				public final boolean visit(final MethodInvocation node) {					final IMethodBinding binding= node.resolveMethodBinding();					if (binding != null && (binding.getName().equals("next") || binding.getName().equals("nextElement"))) { //$NON-NLS-1$ //$NON-NLS-2$						final Expression expression= node.getExpression();						if (expression instanceof Name) {							final IBinding result= ((Name) expression).resolveBinding();							if (result != null && result.equals(fIterator))								return replace(node);						} else if (expression instanceof FieldAccess) {							final IBinding result= ((FieldAccess) expression).resolveFieldBinding();							if (result != null && result.equals(fIterator))								return replace(node);						}					}					return super.visit(node);				}				public final boolean visit(final SimpleName node) {					if (fElement != null) {						final IBinding binding= node.resolveBinding();						if (binding != null && binding.equals(fElement)) {							final Statement parent= (Statement) ASTNodes.getParent(node, Statement.class);							if (parent != null && (list == null || list.getRewrittenList().contains(parent)))								getPositionGroup(fIdentifierName).addPosition(astRewrite.track(node));						}					}					return false;				}			});						if (fAddBlocks && !(body instanceof Block)) {				Statement theBody= (Statement)astRewrite.createMoveTarget(body);				Block newBody= ast.newBlock();				ListRewrite listRewrite= astRewrite.getListRewrite(newBody, Block.STATEMENTS_PROPERTY);				listRewrite.insertFirst(theBody, group);				fEnhancedForLoop.setBody(newBody);			} else if (fRemoveUnnecessaryBlocks && body instanceof Block && ((Block)body).statements().size() == 1) {				Statement moveTarget;								if (fOperation == null) {					moveTarget= (Statement)astRewrite.createMoveTarget(getSingleStatement());				} else {					if (fOperation instanceof ConvertForLoopOperation) {						ConvertForLoopOperation convertForLoopOperation= ((ConvertForLoopOperation)fOperation);						convertForLoopOperation.makePassive();						fOperation.rewriteAST(cuRewrite, textEditGroups);						moveTarget= convertForLoopOperation.getEnhancedForStatement();					} else  {						ConvertIterableLoopOperation convertIterableLoopOperation= ((ConvertIterableLoopOperation)fOperation);						convertIterableLoopOperation.makePassive();						fOperation.rewriteAST(cuRewrite, textEditGroups);						moveTarget= convertIterableLoopOperation.getEnhancedForStatement();					}				}								fEnhancedForLoop.setBody(moveTarget);			} else {				fEnhancedForLoop.setBody((Statement)astRewrite.createMoveTarget(body));			}		}		final SingleVariableDeclaration declaration= ast.newSingleVariableDeclaration();		final SimpleName simple= ast.newSimpleName(name);		getPositionGroup(fIdentifierName).addFirstPosition(astRewrite.track(simple));		declaration.setName(simple);		final ITypeBinding iterable= getIterableType(fIterator.getType());		final ImportRewrite imports= importRewrite;		declaration.setType(importType(iterable, fStatement, importRewrite, fRoot));		remover.registerAddedImport(iterable.getQualifiedName());		fEnhancedForLoop.setParameter(declaration);		fEnhancedForLoop.setExpression(getExpression(astRewrite));		if (!fPassive)			astRewrite.replace(fStatement, fEnhancedForLoop, group);				remover.registerRemovedNode(fStatement);		remover.applyRemoves(imports);				positionGroups.addAll(getAllPositionGroups());		return null;	}