/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.refactoring;

import org.xwiki.component.annotation.Role;
import org.xwiki.model.reference.AttachmentReference;
import org.xwiki.model.reference.DocumentReference;
import org.xwiki.rendering.block.Block;
import org.xwiki.stability.Unstable;

/**
 * Allow to replace references during rename/move refactoring operations.
 *
 * @version $Id$
 * @since 13.4RC1
 */
@Unstable
@Role
public interface ReferenceRenamer
{
    /**
     * Change references of the given block so that the references pointing to the old target points to the new target.
     *
     * @param block the {@link Block} to modify
     * @param currentDocumentReference the current document reference
     * @param oldTarget the previous reference of the renamed entity (attachment or document)
     * @param newTarget the new reference of the renamed entity (attachment or document)
     * @param relative {@code true} if the link should be serialized relatively to the current document
     *      (see {@link org.xwiki.refactoring.internal.LinkRefactoring#updateRelativeLinks})
     * @return {@code true} if the given {@link Block} was modified
     */
    boolean renameReferences(Block block, DocumentReference currentDocumentReference, DocumentReference oldTarget,
        DocumentReference newTarget, boolean relative);

    /**
     * Change references of the given block so that the references pointing to the old target points to the new target.
     *
     * @param block the {@link Block} to modify
     * @param currentDocumentReference the current document reference
     * @param oldTarget the previous reference of the renamed entity (attachment or document)
     * @param newTarget the new reference of the renamed entity (attachment or document)
     * @param relative {@code true} if the link should be serialized relatively to the current document
     *      (see {@link org.xwiki.refactoring.internal.LinkRefactoring#updateRelativeLinks})
     * @return {@code true} if the given {@link Block} was modified
     * @since 14.2RC1
     */
    @Unstable
    boolean renameReferences(Block block, DocumentReference currentDocumentReference, AttachmentReference oldTarget,
        AttachmentReference newTarget, boolean relative);
    
}

@@ -1061,32 +1061,87 @@
 umentReference;%0A
+import org.xwiki.refactoring.internal.LinkRefactoring;%0A
 import org.xwiki
@@ -1942,39 +1942,8 @@
 ink 
-org.xwiki.refactoring.internal.
 Link
@@ -2755,32 +2755,44 @@
 current document
+ (see %7B@link
 %0A     *      (se
@@ -2791,52 +2791,8 @@
     
- (see %7B@link org.xwiki.refactoring.internal.
 Link
@@ -2937,24 +2937,32 @@
 nstable%0A    
+default 
 boolean rena
@@ -3030,16 +3030,24 @@
 ference,
+%0A       
  Attachm
@@ -3069,24 +3069,16 @@
 dTarget,
-%0A       
  Attachm
@@ -3118,17 +3118,50 @@
 elative)
-;
+%0A    %7B%0A        return false;%0A    %7D
 %0A    %0A%7D%0A

Allow refactoring of references to moved attachments