String typeString= getImportRewrite().addImport(fNewType); Type type= ASTNodeFactory.newType(ast, typeString);
Type type= getImportRewrite().addImport(fNewType, ast);
	protected ASTRewrite getRewrite() throws CoreException {		ASTNode boundNode= fAstRoot.findDeclaringNode(fBinding);		ASTNode declNode= null;						if (boundNode != null) {			declNode= boundNode; // is same CU		} else {			ASTParser astParser= ASTParser.newParser(ASTProvider.AST_LEVEL);			astParser.setSource(getCompilationUnit());			astParser.setResolveBindings(true);			CompilationUnit newRoot= (CompilationUnit) astParser.createAST(null);			declNode= newRoot.findDeclaringNode(fBinding.getKey());		}		if (declNode != null) {			AST ast= declNode.getAST();			ASTRewrite rewrite= ASTRewrite.create(ast);						String typeString= getImportRewrite().addImport(fNewType);			Type type= ASTNodeFactory.newType(ast, typeString);						if (declNode instanceof MethodDeclaration) {				MethodDeclaration methodDecl= (MethodDeclaration) declNode;				rewrite.set(methodDecl, MethodDeclaration.RETURN_TYPE2_PROPERTY, type, null);				rewrite.set(methodDecl, MethodDeclaration.EXTRA_DIMENSIONS_PROPERTY, new Integer(0), null);			} else if (declNode instanceof VariableDeclarationFragment) {				ASTNode parent= declNode.getParent();				if (parent instanceof FieldDeclaration) {					FieldDeclaration fieldDecl= (FieldDeclaration) parent;					if (fieldDecl.fragments().size() > 1 && (fieldDecl.getParent() instanceof TypeDeclaration)) { // split						VariableDeclarationFragment placeholder= (VariableDeclarationFragment) rewrite.createMoveTarget(declNode);						FieldDeclaration newField= ast.newFieldDeclaration(placeholder);						newField.setType(type);						rewrite.getListRewrite(fieldDecl.getParent(), TypeDeclaration.BODY_DECLARATIONS_PROPERTY).insertAfter(newField, parent, null);					} else {						rewrite.set(fieldDecl, FieldDeclaration.TYPE_PROPERTY, type, null);						rewrite.set(declNode, VariableDeclarationFragment.EXTRA_DIMENSIONS_PROPERTY, new Integer(0), null);					}				} else if (parent instanceof VariableDeclarationStatement) {					VariableDeclarationStatement varDecl= (VariableDeclarationStatement) parent;					if (varDecl.fragments().size() > 1 && (varDecl.getParent() instanceof Block)) { // split						VariableDeclarationFragment placeholder= (VariableDeclarationFragment) rewrite.createMoveTarget(declNode);						VariableDeclarationStatement newStat= ast.newVariableDeclarationStatement(placeholder);						newStat.setType(type);						rewrite.getListRewrite(varDecl.getParent(), Block.STATEMENTS_PROPERTY).insertAfter(newStat, parent, null);					} else {						rewrite.set(varDecl, VariableDeclarationStatement.TYPE_PROPERTY, type, null);						rewrite.set(declNode, VariableDeclarationFragment.EXTRA_DIMENSIONS_PROPERTY, new Integer(0), null);					}				} else if (parent instanceof VariableDeclarationExpression) {					VariableDeclarationExpression varDecl= (VariableDeclarationExpression) parent;										rewrite.set(varDecl, VariableDeclarationExpression.TYPE_PROPERTY, type, null);					rewrite.set(declNode, VariableDeclarationFragment.EXTRA_DIMENSIONS_PROPERTY, new Integer(0), null);				}			} else if (declNode instanceof SingleVariableDeclaration) {				SingleVariableDeclaration variableDeclaration= (SingleVariableDeclaration) declNode;				rewrite.set(variableDeclaration, SingleVariableDeclaration.TYPE_PROPERTY, type, null);				rewrite.set(variableDeclaration, SingleVariableDeclaration.EXTRA_DIMENSIONS_PROPERTY, new Integer(0), null);			}						// set up linked mode			final String KEY_TYPE= "type"; //$NON-NLS-1$			addLinkedPosition(rewrite.track(type), true, KEY_TYPE);			if (fOfferSuperTypeProposals) {				ITypeBinding[] typeProposals= ASTResolving.getRelaxingTypes(ast, fNewType);				for (int i= 0; i < typeProposals.length; i++) {					addLinkedPositionProposal(KEY_TYPE, typeProposals[i]);				}			}			return rewrite;		}		return null;	}