int insertIndex= findFieldInsertIndex(decls, node.getStartPosition());
int maxOffset= isInDifferentCU ? -1 : node.getStartPosition();  int insertIndex= findFieldInsertIndex(decls, newDecl, maxOffset);
	private ASTRewrite doAddField(CompilationUnit astRoot) throws CoreException {		SimpleName node= fOriginalNode;		boolean isInDifferentCU= false;		ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding);		if (newTypeDecl == null) {			ASTParser astParser= ASTParser.newParser(ASTProvider.AST_LEVEL);			astParser.setSource(getCompilationUnit());			astParser.setResolveBindings(true);			astRoot= (CompilationUnit) astParser.createAST(null);			newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey());			isInDifferentCU= true;		}		if (newTypeDecl != null) {			AST ast= newTypeDecl.getAST();			ASTRewrite rewrite= ASTRewrite.create(ast);			VariableDeclarationFragment fragment= ast.newVariableDeclarationFragment();			fragment.setName(ast.newSimpleName(node.getIdentifier()));			Type type= evaluateVariableType(ast, fSenderBinding);			FieldDeclaration newDecl= ast.newFieldDeclaration(fragment);			newDecl.setType(type);			newDecl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, evaluateFieldModifiers(newTypeDecl)));			if (fSenderBinding.isInterface() || fVariableKind == CONST_FIELD) {				fragment.setInitializer(ASTNodeFactory.newDefaultExpression(ast, type, 0));			}			ChildListPropertyDescriptor property= ASTNodes.getBodyDeclarationsProperty(newTypeDecl);			List decls= (List) newTypeDecl.getStructuralProperty(property);			int insertIndex= findFieldInsertIndex(decls, node.getStartPosition());			ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, property);			listRewriter.insertAt(newDecl, insertIndex, null);			addLinkedPosition(rewrite.track(newDecl.getType()), false, KEY_TYPE);			if (!isInDifferentCU) {				addLinkedPosition(rewrite.track(node), true, KEY_NAME);			}			addLinkedPosition(rewrite.track(fragment.getName()), false, KEY_NAME);			if (fragment.getInitializer() != null) {				addLinkedPosition(rewrite.track(fragment.getInitializer()), false, KEY_INITIALIZER);			}			return rewrite;		}		return null;	}