Author: dazarov
Date: 2009-04-15 13:19:41 -0400 (Wed, 15 Apr 2009)
New Revision: 14761
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
Log:
property names in seam.properties. E.g. <oldName>.property1 = ... ->
<newName>.property1 = ...
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/RenameComponentProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-04-15
16:59:30 UTC (rev 14760)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-04-15
17:19:41 UTC (rev 14761)
@@ -13,6 +13,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Set;
+import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -357,6 +358,39 @@
private void scanProperties(IFile file, String content){
scanString(file, content, 0);
+ StringTokenizer tokenizer = new StringTokenizer(content, "= \t\r\n\f",
true);
+
+ String lastToken = "\n";
+ int offset = 0;
+ boolean comment = false;
+ boolean key = true;
+
+ while(tokenizer.hasMoreTokens()){
+ String token = tokenizer.nextToken(".#= \t\r\n\f");//$NON-NLS-1$
+ if(token.equals("\r"))
+ token = "\n";
+
+ if(token.equals("#") && lastToken.equals("\n"))
+ comment = true;
+ else if(token.equals("\n") && comment)
+ comment = false;
+
+ if(!comment){
+ if(!token.equals("\n") && lastToken.equals("\n"))
+ key = true;
+ else if(key && (token.equals("=") || token.equals(" ")))
+ key = false;
+
+ if(key && token.equals(component.getName())){
+ checkLastChange(file);
+ TextEdit edit = new ReplaceEdit(offset, token.length(), newName);
+ lastChange.addEdit(edit);
+ }
+ }
+
+ lastToken = token;
+ offset += token.length();
+ }
}
/*