Author: dazarov
Date: 2009-06-18 08:09:26 -0400 (Thu, 18 Jun 2009)
New Revision: 16035
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/src/test.properties
Removed:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/WebContent/test.properties
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/SeamComponentRefactoringTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4406
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-06-18
11:30:32 UTC (rev 16034)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-06-18
12:09:26 UTC (rev 16035)
@@ -23,6 +23,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.BadLocationException;
@@ -53,6 +55,7 @@
import org.jboss.tools.common.el.core.parser.ELParser;
import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.model.project.ext.ITextSourceReference;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
@@ -367,10 +370,81 @@
IProject[] projects = projectsSet.getAllProjects();
for (IProject project : projects) {
- if(project != null)
+ if(project == null) continue;
+
+ IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
+
+ // searching java, xml and property files in source folders
+ if(javaProject != null){
+ for(IResource resource : EclipseResourceUtil.getJavaSourceRoots(project)){
+ if(resource instanceof IFolder)
+ scanForJava((IFolder) resource);
+ else if(resource instanceof IFile)
+ scanForJava((IFile) resource);
+ }
+ }
+
+ // searching jsp, xhtml and xml files in WebContent folders
+ if(project.equals(projectsSet.getWarProject()))
+ scan(projectsSet.getDefaultViewsFolder());
+ else if(project.equals(projectsSet.getEarProject()))
+ scan(projectsSet.getDefaultEarViewsFolder());
+ else{
scan(project);
+ }
}
}
+
+ private void scan(IProject project){
+ IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
+ if(javaProject == null)
+ return;
+
+ IResource[] sources = EclipseResourceUtil.getJavaSourceRoots(project);
+ IPath output = null;
+ try{
+ output = javaProject.getOutputLocation();
+ }catch(JavaModelException ex){
+ SeamCorePlugin.getDefault().logError(ex);
+ }
+
+ try{
+ for(IResource resource : project.members()){
+ if(resource instanceof IFolder){
+ if(checkFolder(resource, sources, output))
+ scan((IFolder) resource);
+ }else if(resource instanceof IFile)
+ scan((IFile) resource);
+ }
+ }catch(CoreException ex){
+ SeamCorePlugin.getDefault().logError(ex);
+ }
+ }
+
+ private boolean checkFolder(IResource resource, IResource[] sources, IPath output){
+ for(IResource folder : sources){
+ if(resource.equals(folder))
+ return false;
+ }
+
+ if(resource.getFullPath().equals(output))
+ return false;
+
+ return true;
+ }
+
+ private void scanForJava(IContainer container){
+ try{
+ for(IResource resource : container.members()){
+ if(resource instanceof IFolder)
+ scanForJava((IFolder) resource);
+ else if(resource instanceof IFile)
+ scanForJava((IFile) resource);
+ }
+ }catch(CoreException ex){
+ SeamCorePlugin.getDefault().logError(ex);
+ }
+ }
private void scan(IContainer container){
try{
@@ -384,8 +458,8 @@
SeamCorePlugin.getDefault().logError(ex);
}
}
-
- private void scan(IFile file){
+
+ private void scanForJava(IFile file){
String ext = file.getFileExtension();
String content = null;
try {
@@ -396,11 +470,24 @@
}
if(JAVA_EXT.equalsIgnoreCase(ext)){
scanJava(file, content);
- } else if(XML_EXT.equalsIgnoreCase(ext) || XHTML_EXT.equalsIgnoreCase(ext) ||
JSP_EXT.equalsIgnoreCase(ext))
+ }else if(XML_EXT.equalsIgnoreCase(ext))
scanDOM(file, content);
else if(PROPERTIES_EXT.equalsIgnoreCase(ext))
scanProperties(file, content);
}
+
+ private void scan(IFile file){
+ String ext = file.getFileExtension();
+ String content = null;
+ try {
+ content = FileUtil.readStream(file.getContents());
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return;
+ }
+ if(XML_EXT.equalsIgnoreCase(ext) || XHTML_EXT.equalsIgnoreCase(ext) ||
JSP_EXT.equalsIgnoreCase(ext))
+ scanDOM(file, content);
+ }
private void scanJava(IFile file, String content){
try {
Deleted:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/WebContent/test.properties
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/WebContent/test.properties 2009-06-18
11:30:32 UTC (rev 16034)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/WebContent/test.properties 2009-06-18
12:09:26 UTC (rev 16035)
@@ -1 +0,0 @@
-TEST_VALUE = This value is #{test.value}!
\ No newline at end of file
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/src/test.properties
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/src/test.properties
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/src/test.properties 2009-06-18
12:09:26 UTC (rev 16035)
@@ -0,0 +1 @@
+TEST_VALUE = This value is #{test.value}!
\ No newline at end of file
Property changes on:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/src/test.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamComponentRefactoringTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamComponentRefactoringTest.java 2009-06-18
11:30:32 UTC (rev 16034)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/refactoring/SeamComponentRefactoringTest.java 2009-06-18
12:09:26 UTC (rev 16035)
@@ -113,7 +113,7 @@
structure.addTextChange(change);
list.add(structure);
- structure = new TestChangeStructure(warProject,
"/WebContent/test.properties");
+ structure = new TestChangeStructure(warProject, "/src/test.properties");
change = new TestTextChange(29, 4, "best");
structure.addTextChange(change);
list.add(structure);
@@ -181,7 +181,7 @@
content = FileUtil.readStream(file.getContents());
//System.out.println("File - "+file.getName()+" offset -
"+changeStructure.getOffset()+" expected -
["+changeStructure.getText()+"] actual -
["+content.substring(changeStructure.getOffset(),
changeStructure.getOffset()+changeStructure.getLength())+"]");
for(TestTextChange change : changeStructure.getTextChanges()){
- assertEquals(change.getText(), content.substring(change.getOffset(),
change.getOffset()+change.getLength()));
+ assertEquals("There is unexpected change in resource -
"+file.getName(),change.getText(), content.substring(change.getOffset(),
change.getOffset()+change.getLength()));
}
}
}