[298355] [refactoring] When Java class is moved several times in a row JSP refactoring starts to trash JSP regions
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java
index ca168b7..a057ed5 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/BasicRefactorSearchRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -80,14 +80,18 @@
String renameText = getRenameText((JavaSearchDocumentDelegate)searchDoc, javaMatch);
- // add it for the correct document
- addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText));
+ //if rename text is null then don't create an edit for it
+ if(renameText != null) {
+ // add it for the correct document
+ addJavaEdit(searchDoc.getPath(), new ReplaceEdit(javaMatch.getOffset(), javaMatch.getLength(), renameText));
+ }
}
}
/**
* @param searchDoc
- * @return
+ * @return the rename text or <code>null</code> if no edit should be created for the given match.
+ * Such a case would be a match where nothing needs to be edited.
*/
protected String getRenameText(JavaSearchDocumentDelegate searchDoc, SearchMatch javaMatch) {
return getNewName();
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveRequestor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveRequestor.java
index 4953031..bd9c8c0 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveRequestor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/java/refactoring/JSPTypeMoveRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,6 +31,9 @@
super(element, newPackage);
}
+ /**
+ * @see org.eclipse.jst.jsp.ui.internal.java.refactoring.BasicRefactorSearchRequestor#getRenameText(org.eclipse.jst.jsp.core.internal.java.search.JavaSearchDocumentDelegate, org.eclipse.jdt.core.search.SearchMatch)
+ */
protected String getRenameText(JavaSearchDocumentDelegate searchDoc, SearchMatch javaMatch) {
String renameText = getElement().getElementName();
@@ -44,6 +47,12 @@
// getNewName() is the pkg name
renameText = getNewName() + "." + renameText; //$NON-NLS-1$
}
+
+ //if the rename text is the same as the match text then, don't want to bother renaming anything
+ if(renameText.equals(matchText)) {
+ renameText = null;
+ }
+
return renameText;
}