Author: dazarov
Date: 2009-07-02 09:27:49 -0400 (Thu, 02 Jul 2009)
New Revision: 16340
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-07-02
13:18:36 UTC (rev 16339)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-07-02
13:27:49 UTC (rev 16340)
@@ -198,8 +198,7 @@
for(IBijectedAttribute attribute : attributes){
ITextSourceReference location = attribute.getLocationFor(locationPath);
- if(location != null)
- changeAnnotation(location, (IFile)attribute.getResource());
+ changeAnnotation(location, (IFile)attribute.getResource());
}
}
@@ -208,19 +207,22 @@
if(file.getFileExtension().equalsIgnoreCase(JAVA_EXT)){
ITextSourceReference location =
factory.getLocationFor(SeamAnnotations.FACTORY_ANNOTATION_TYPE);
- if(location != null)
- changeAnnotation(location, file);
+ changeAnnotation(location, file);
}else{
ITextSourceReference location =
factory.getLocationFor(ISeamXmlComponentDeclaration.NAME);
- if(location != null)
- changeXMLNode(location, file);
+ changeXMLNode(location, file);
}
}
private boolean isBadLocation(ITextSourceReference location, IFile file){
- boolean flag = location.getStartPosition() == 0 && location.getLength() == 0;
+ boolean flag;
+ if(location == null)
+ flag = true;
+ else
+ flag = location.getStartPosition() == 0 && location.getLength() == 0;
+
if(flag)
status.addFatalError(Messages.format(SeamCoreMessages.SEAM_RENAME_PROCESSOR_LOCATION_NOT_FOUND,
file.getFullPath().toString()));
return flag;
@@ -270,9 +272,10 @@
String text = content.substring(location.getStartPosition(),
location.getStartPosition()+location.getLength());
int openBracket = text.indexOf("("); //$NON-NLS-1$
- if(openBracket > 0){
+ int openQuote = text.indexOf("\""); //$NON-NLS-1$
+ if(openBracket >= 0){
int closeBracket = text.indexOf(")", openBracket); //$NON-NLS-1$
- int openQuote = text.indexOf("\"", openBracket); //$NON-NLS-1$
+
int equals = text.indexOf("=", openBracket); //$NON-NLS-1$
int value = text.indexOf("value", openBracket); //$NON-NLS-1$
@@ -289,6 +292,16 @@
String newText = text.replace(getOldName(), getNewName());
change(file, location.getStartPosition(), location.getLength(), newText);
}
+ }else if(openQuote >= 0){
+ int closeQuota = text.indexOf("\"", openQuote); //$NON-NLS-1$
+
+ if(closeQuota == openQuote+1){ // empty quotas
+ String newText = "\""+getNewName()+"\""; //$NON-NLS-1$
//$NON-NLS-2$
+ change(file, location.getStartPosition()+openQuote+1, 0, newText);
+ }else{ // the other cases
+ String newText = text.replace(getOldName(), getNewName());
+ change(file, location.getStartPosition(), location.getLength(), newText);
+ }
}else{
String newText = "(\""+getNewName()+"\")"; //$NON-NLS-1$
//$NON-NLS-2$
change(file, location.getStartPosition()+location.getLength(), 0, newText);
@@ -700,6 +713,7 @@
}
private void change(IFile file, int offset, int length, String text){
+ //System.out.println("change file - "+file.getFullPath()+" offset -
"+offset+" len - "+length+" text"+text);
String key = file.getFullPath().toString()+" "+offset;
if(!keys.contains(key)){
TextFileChange change = getChange(file);
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java 2009-07-02
13:18:36 UTC (rev 16339)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamContextVariableRefactoringTest.java 2009-07-02
13:27:49 UTC (rev 16340)
@@ -162,7 +162,7 @@
ArrayList<TestChangeStructure> list = new
ArrayList<TestChangeStructure>();
TestChangeStructure structure = new TestChangeStructure(ejbProject.getProject(),
"/ejbModule/org/domain/"+warProjectName+"/session/TestContextVariableOut.java");
- TestTextChange change = new TestTextChange(461, 5, "\"bbb\"");
+ TestTextChange change = new TestTextChange(455, 5, "\"bbb\"");
structure.addTextChange(change);
list.add(structure);
@@ -190,7 +190,7 @@
renameContextVariable(seamEjbProject, "/WebContent/out.jsp", "ddd",
"eee", list);
}
- public void testSeamContextVariable_DataModel_Rename() throws CoreException {
+ public void t_estSeamContextVariable_DataModel_Rename() throws CoreException {
}
}