MethodDeclaration methodDecl= ASTResolving.findParentMethodDeclaration(fNodeToAssign);  ASTNode newTypeDecl= ASTResolving.findParentType(methodDecl);
	private ASTRewrite doAddField() throws CoreException {		boolean isParamToField= fNodeToAssign.getNodeType() == ASTNode.SINGLE_VARIABLE_DECLARATION;				MethodDeclaration methodDecl= ASTResolving.findParentMethodDeclaration(fNodeToAssign);				ASTNode newTypeDecl= ASTResolving.findParentType(methodDecl);		Expression expression= isParamToField ? ((SingleVariableDeclaration) fNodeToAssign).getName() : ((ExpressionStatement) fNodeToAssign).getExpression();				boolean isAnonymous= newTypeDecl.getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION;		List decls= isAnonymous ?  ((AnonymousClassDeclaration) newTypeDecl).bodyDeclarations() :  ((TypeDeclaration) newTypeDecl).bodyDeclarations();				ASTRewrite rewrite= new ASTRewrite(newTypeDecl);		AST ast= newTypeDecl.getAST();				boolean isStatic= Modifier.isStatic(methodDecl.getModifiers()) && !isAnonymous;		int modifiers= Modifier.PRIVATE;		if (isStatic) {			modifiers |= Modifier.STATIC;		}				String varName= suggestFieldNames(fTypeBinding, expression, modifiers);		VariableDeclarationFragment newDeclFrag= ast.newVariableDeclarationFragment();		newDeclFrag.setName(ast.newSimpleName(varName));						FieldDeclaration newDecl= ast.newFieldDeclaration(newDeclFrag);				Type type= evaluateType(ast);		newDecl.setType(type);		newDecl.setModifiers(modifiers);				Assignment assignment= ast.newAssignment();		assignment.setRightHandSide((Expression) rewrite.createCopy(expression));		boolean needsThis= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CODEGEN_KEYWORD_THIS);		if (isParamToField) {			needsThis |= varName.equals(((SimpleName) expression).getIdentifier());		}		SimpleName accessName= ast.newSimpleName(varName);		if (needsThis) {			FieldAccess fieldAccess= ast.newFieldAccess();			fieldAccess.setName(accessName);			if (isStatic) {				String typeName= ((TypeDeclaration) newTypeDecl).getName().getIdentifier();				fieldAccess.setExpression(ast.newSimpleName(typeName));			} else {				fieldAccess.setExpression(ast.newThisExpression());			}			assignment.setLeftHandSide(fieldAccess);		} else {			assignment.setLeftHandSide(accessName);		}				int insertIndex= findFieldInsertIndex(decls, fNodeToAssign.getStartPosition());		rewrite.markAsInsertInOriginal(newTypeDecl, ASTNodeConstants.BODY_DECLARATIONS, newDecl, insertIndex, null);		ASTNode selectionNode;		if (isParamToField) {			// assign parameter to field			Block body= methodDecl.getBody();			ExpressionStatement statement= ast.newExpressionStatement(assignment);			int insertIdx=  findAssignmentInsertIndex(body.statements());			rewrite.markAsInsertInOriginal(body, ASTNodeConstants.STATEMENTS, statement, insertIdx, null);			selectionNode= statement;					} else {						rewrite.markAsReplaced(expression, assignment);			selectionNode= fNodeToAssign;		} 				markAsLinked(rewrite, newDeclFrag.getName(), false, KEY_NAME);		markAsLinked(rewrite, newDecl.getType(), false, KEY_TYPE);		markAsLinked(rewrite, accessName, true, KEY_NAME);		markAsSelection(rewrite, selectionNode);				return rewrite;			}