Author: dazarov
Date: 2009-12-07 13:49:25 -0500 (Mon, 07 Dec 2009)
New Revision: 19082
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.classpath
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.project
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/.jsdtscope
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.component
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.container
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.name
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/Messages.properties
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/User.java
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/META-INF/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/classes/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/common-annotations.jar
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-beanutils.jar
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-collections.jar
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-digester.jar
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-logging.jar
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/jsf-tlds.jar
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/jstl.jar
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/standard.jar
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/web.xml
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/index.jsp
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/hello.jsp
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.properties
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.xml
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java
trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5232
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java 2009-12-07
16:40:49 UTC (rev 19081)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java 2009-12-07
18:49:25 UTC (rev 19082)
@@ -24,6 +24,7 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
import org.eclipse.jdt.ui.text.IJavaPartitions;
@@ -418,6 +419,15 @@
return methodName;
}
+ public static String getPropertyName(IType method, String className){
+ StringBuffer name = new StringBuffer(className);
+ if(name.length()<2 || Character.isLowerCase(name.charAt(1))) {
+ name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+ }
+ String propertyName = name.toString();
+ return propertyName;
+ }
+
private boolean containsInSearchScope(IProject project){
if(searchScope == null)
return true;
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-12-07
16:40:49 UTC (rev 19081)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-12-07
18:49:25 UTC (rev 19082)
@@ -5,7 +5,8 @@
Bundle-Name: %Bundle-Name.0
Bundle-SymbolicName: org.jboss.tools.common.el.ui;singleton:=true
Bundle-Version: 1.0.0
-Export-Package: org.jboss.tools.common.el.ui
+Export-Package: org.jboss.tools.common.el.ui,
+ org.jboss.tools.common.el.ui.refactoring
Bundle-Activator: org.jboss.tools.common.el.ui.ElUiPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-12-07
16:40:49 UTC (rev 19081)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-12-07
18:49:25 UTC (rev 19082)
@@ -20,7 +20,9 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -38,7 +40,7 @@
import org.jboss.tools.common.model.project.ProjectHome;
public class RenameMethodParticipant extends RenameParticipant{
- private IMethod method;
+ private IJavaElement element;
private String oldName;
private String newName;
private SeamRenameMethodSearcher searcher;
@@ -55,13 +57,15 @@
CheckConditionsContext context) throws OperationCanceledException {
if(searcher == null)
return status;
-
- if(method != null && !added){
- if(searcher.isGetter(method))
- status.addWarning(ElUIMessages.RENAME_METHOD_PARTICIPANT_GETTER_WARNING);
- else if(searcher.isSetter(method))
- status.addWarning(ElUIMessages.RENAME_METHOD_PARTICIPANT_SETTER_WARNING);
- added = true;
+ if(element instanceof IMethod){
+ IMethod method = (IMethod)element;
+ if(method != null && !added){
+ if(searcher.isGetter(method))
+ status.addWarning(ElUIMessages.RENAME_METHOD_PARTICIPANT_GETTER_WARNING);
+ else if(searcher.isSetter(method))
+ status.addWarning(ElUIMessages.RENAME_METHOD_PARTICIPANT_SETTER_WARNING);
+ added = true;
+ }
}
searcher.findELReferences();
@@ -83,21 +87,71 @@
@Override
protected boolean initialize(Object element) {
if(element instanceof IMethod){
+ IMethod method = (IMethod)element;
status = new RefactoringStatus();
rootChange = new
CompositeChange(ElUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
- method = (IMethod)element;
+ this.element = method;
+
oldName = method.getElementName();
newName = RefactorSearcher.getPropertyName(method, getArguments().getNewName());
searcher = new SeamRenameMethodSearcher((IFile)method.getResource(), oldName);
added = false;
return true;
+ }else if(element instanceof IType){
+ IType type = (IType)element;
+ status = new RefactoringStatus();
+
+ rootChange = new
CompositeChange(ElUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
+
+ this.element = type;
+
+ oldName = type.getElementName();
+
+ newName = RefactorSearcher.getPropertyName(type, getArguments().getNewName());
+ searcher = new SeamRenameMethodSearcher((IFile)type.getResource(), oldName);
+ added = false;
+ return true;
}
return false;
}
+ // for test only
+ public boolean initialize(Object element, String newName) {
+ if(element instanceof IMethod){
+ IMethod method = (IMethod)element;
+ status = new RefactoringStatus();
+
+ rootChange = new
CompositeChange(ElUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
+
+ this.element = method;
+
+ oldName = method.getElementName();
+
+ this.newName = newName;
+ searcher = new SeamRenameMethodSearcher((IFile)method.getResource(), oldName);
+ added = false;
+ return true;
+ }else if(element instanceof IType){
+ IType type = (IType)element;
+ status = new RefactoringStatus();
+
+ rootChange = new
CompositeChange(ElUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
+
+ this.element = type;
+
+ oldName = type.getElementName();
+
+ this.newName = newName;
+ searcher = new SeamRenameMethodSearcher((IFile)type.getResource(), oldName);
+ added = false;
+ return true;
+ }
+ return false;
+ }
+
protected TextFileChange getChange(IFile file){
if(lastChange != null && lastChange.getFile().equals(file))
return lastChange;
@@ -130,7 +184,7 @@
class SeamRenameMethodSearcher extends RefactorSearcher{
ProjectsSet projectSet=null;
public SeamRenameMethodSearcher(IFile file, String name){
- super(file, name, method);
+ super(file, name, element);
ELProjectSetExtension[] extensions = ELProjectSetExtension.getInstances();
if(extensions.length > 0){
projectSet = extensions[0].getProjectSet();
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF 2009-12-07
16:40:49 UTC (rev 19081)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/META-INF/MANIFEST.MF 2009-12-07
18:49:25 UTC (rev 19082)
@@ -13,7 +13,12 @@
org.eclipse.jface.text,
org.jboss.tools.common.el.core,
org.jboss.tools.common.test,
- org.jboss.tools.tests
+ org.jboss.tools.tests,
+ org.eclipse.jst.j2ee;bundle-version="1.1.300",
+ org.jboss.tools.common.el.ui;bundle-version="1.0.0",
+ org.eclipse.jdt.core;bundle-version="3.5.0",
+ org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
+ org.jboss.tools.common;bundle-version="2.0.0"
Export-Package: org.jboss.tools.common.el.core.test
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.classpath
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.classpath
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.classpath 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="JavaSource"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss
4.2 Runtime">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.web"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.5.0_10">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output"
path="WebContent/WEB-INF/classes"/>
+</classpath>
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.project
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.project
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.project 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>testJSFProject</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.common.verification.verifybuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.jboss.tools.jsf.jsfnature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.jboss.tools.jst.web.kb.kbnature</nature>
+ </natures>
+</projectDescription>
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/.jsdtscope
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/.jsdtscope
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/.jsdtscope 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,7 @@
+#Mon Dec 07 18:26:41 MSK 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.component
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.component
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.component 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="testJSFProject">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes"
source-path="/JavaSource"/>
+<property name="context-root" value="testJSFProject"/>
+<property name="java-output-path"/>
+</wb-module>
+</project-modules>
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <runtime name="JBoss 4.2 Runtime"/>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.web"/>
+ <installed facet="jst.java" version="5.0"/>
+ <installed facet="jst.web" version="2.5"/>
+</faceted-project>
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.container
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.container
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.container 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.name
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.name
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.name 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1 @@
+Window
\ No newline at end of file
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/Messages.properties
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/Messages.properties
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/Messages.properties 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,3 @@
+header=Hello Demo Application
+prompt_message=Name:
+hello_message=Hello
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/Messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/User.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/User.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/User.java 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package demo;
+
+/**
+ * Created by JBoss Developer Studio
+ */
+public class User {
+
+ private String name;
+
+ /**
+ * @return User Name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param User Name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/JavaSource/demo/User.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xi="http://www.w3.org/2001/XInclude"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+ <managed-bean>
+ <description>User Name Bean</description>
+ <managed-bean-name>user</managed-bean-name>
+ <managed-bean-class>demo.User</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>name</property-name>
+ <property-class>java.lang.String</property-class>
+ <value/>
+ </managed-property>
+ </managed-bean>
+ <navigation-rule>
+ <from-view-id>/pages/inputUserName.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>hello</from-outcome>
+ <to-view-id>/pages/hello.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ <application>
+ <locale-config/>
+ </application>
+ <factory/>
+ <lifecycle/>
+</faces-config>
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/common-annotations.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/common-annotations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-beanutils.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-beanutils.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-collections.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-collections.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-digester.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-digester.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-logging.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-logging.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/jsf-tlds.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/jsf-tlds.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/jstl.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/jstl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/standard.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/lib/standard.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/web.xml
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/web.xml
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/web.xml 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>testJSFProject</display-name>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <listener>
+ <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
+ </listener>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/WEB-INF/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/index.jsp
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/index.jsp
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/index.jsp 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,7 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+
+<html>
+ <body>
+ <jsp:forward page="/pages/inputUserName.jsf" />
+ </body>
+</html>
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/index.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/hello.jsp
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/hello.jsp
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/hello.jsp 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,20 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages" />
+
+<html>
+ <head>
+ <title>Hello!</title>
+ </head>
+
+ <body>
+ <f:view>
+ <h3>
+ <h:outputText value="#{Message.hello_message}" />,
+ <h:outputText value="#{user.name}" />!
+ </h3>
+ </f:view>
+ </body>
+
+</html>
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/hello.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,28 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+ <head>
+ <title>Input User Name Page</title>
+ </head>
+ <body>
+
+ <f:view>
+ <h1><h:outputText value="#{Message.header}"/></h1>
+
+ <h:messages style="color: red"/>
+
+ <h:form id="greetingForm">
+ <h:outputText value="#{Message.prompt_message}"/>
+ <h:inputText value="#{user.name}" required="true">
+ <f:validateLength maximum="30" minimum="3"/>
+ </h:inputText>
+
+ <h:commandButton action="hello" value="Say Hello!" />
+
+ </h:form>
+ </f:view>
+ </body>
+</html>
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.properties
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.properties
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.properties 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,3 @@
+#
+#Mon Dec 07 18:26:39 MSK 2009
+classpath.external=
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.xml
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.xml
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.xml 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,74 @@
+<project name="KickStart" default="deploy"
basedir="../">
+
+ <!-- Project settings -->
+ <property file="${basedir}/ant/build.properties" />
+
+ <property name="project.name" value="KickStart" />
+ <property name="web.content.dir" value="${basedir}/WebContent"
/>
+ <property name="web-inf.dir" value="${web.content.dir}/WEB-INF"
/>
+ <property name="build.dir" value="build" />
+ <property name="war.name"
value="${build.dir}/${project.name}.war" />
+
+ <!-- Define a folder for deployment -->
+ <property name="deploy.dir" value="deploy" />
+
+ <!-- Compile classpath -->
+ <path id="compile.classpath">
+ <fileset dir="${webinf.dir}/lib">
+ <include name="**/*.jar" />
+ </fileset>
+ <pathelement path="${classpath}" />
+ <pathelement path="${classpath.external}" />
+ <pathelement path="${webinf.dir}/classes" />
+ </path>
+
+ <!-- Copy any resource or configuration files -->
+ <target name="copyResources">
+ <copy todir="${web-inf.dir}/classes" includeEmptyDirs="no">
+ <fileset dir="JavaSource">
+ <patternset>
+ <include name="**/*.*" />
+ <exclude name="**/*.java" />
+ </patternset>
+ </fileset>
+ </copy>
+ </target>
+
+ <!-- Check timestamp on files -->
+ <target name="prepare">
+ <tstamp />
+ </target>
+
+ <!-- Remove classes directory for clean build -->
+ <target name="clean" description="Prepare for clean build">
+ <delete dir="${web-inf.dir}/classes" failonerror="false"/>
+ <mkdir dir="${web-inf.dir}/classes" />
+ </target>
+
+ <!-- Normal build of application -->
+ <target name="compile" depends="prepare, copyResources">
+ <javac srcdir="JavaSource" destdir="${web-inf.dir}/classes">
+ <classpath refid="compile.classpath" />
+ </javac>
+ </target>
+
+ <!-- Build Project -->
+ <target name="build" depends="prepare, compile" />
+
+ <!-- Rebuild Project -->
+ <target name="rebuild" depends="clean, prepare, compile" />
+
+ <!-- Build WAR -->
+ <target name="war" depends="build">
+ <mkdir dir="${build.dir}" />
+ <war warfile="${war.name}" basedir="${web.content.dir}"
webxml="${web-inf.dir}/web.xml">
+ <exclude name="WEB-INF/web.xml" />
+ </war>
+ </target>
+
+ <target name="deploy" depends="war">
+ <delete dir="${deploy.dir}/${project.name}"
failonerror="false"/>
+ <copy file="${war.name}" todir="${deploy.dir}" />
+ </target>
+
+</project>
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/ant/build.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2009-12-07
16:40:49 UTC (rev 19081)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2009-12-07
18:49:25 UTC (rev 19082)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.common.el.core.test;
+import org.jboss.tools.common.el.core.test.refactoring.ELReferencesRenameTest;
+import org.jboss.tools.test.util.ProjectImportTestSetup;
+
import junit.framework.Test;
import junit.framework.TestSuite;
/**
@@ -24,6 +27,10 @@
suite.setName("All tests for " + PLUGIN_ID);
suite.addTestSuite(ELParserTest.class);
suite.addTestSuite(ELModelTest.class);
+ suite.addTest(new ProjectImportTestSetup(new TestSuite(ELReferencesRenameTest.class),
+ "org.jboss.tools.common.el.core.test",
+ new String[]{"projects/testJSFProject",},
+ new String[]{"testJSFProject"}));
return suite;
}
}
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,131 @@
+package org.jboss.tools.common.el.core.test.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ProjectImportTestSetup;
+
+import junit.framework.TestCase;
+
+public class ELRefactoringTest extends TestCase {
+ static String jsfProjectName = "testJSFProject";
+ static IProject jsfProject;
+
+ public ELRefactoringTest(String name){
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ loadProjects();
+ List<IProject> projectList = new ArrayList<IProject>();
+ projectList.add(jsfProject);
+ J2EEComponentClasspathUpdater.getInstance().forceUpdate(projectList);
+ loadProjects();
+ }
+
+ private void loadProjects() throws Exception {
+ jsfProject = ProjectImportTestSetup.loadProject(jsfProjectName);
+ jsfProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ }
+
+ protected TestChangeStructure findChange(List<TestChangeStructure> changeList,
IFile file){
+ for(TestChangeStructure tcs : changeList){
+ if(tcs.getFileName().equals("/"+file.getFullPath().removeFirstSegments(1).toString()))
+ return tcs;
+ }
+ return null;
+ }
+
+ protected IType getJavaType(IProject project, String className){
+ IJavaProject javaProject = EclipseUtil.getJavaProject(project);
+ if(javaProject != null){
+ try{
+ return javaProject.findType(className);
+ }catch(JavaModelException ex){
+ fail(ex.getMessage());
+ }
+ }
+
+ return null;
+ }
+
+ protected IMethod getJavaMethod(IProject project, String className, String methodName){
+ IType type = getJavaType(project, className);
+ if(type != null){
+ return type.getMethod(methodName, new String[0]);
+ }
+ return null;
+ }
+
+ class TestChangeStructure{
+ private IProject project;
+ private String fileName;
+ ArrayList<TestTextChange> textChanges = new ArrayList<TestTextChange>();
+
+
+ public TestChangeStructure(IProject project, String fileName){
+ this.project = project;
+ this.fileName = fileName;
+ }
+
+ public IProject getProject(){
+ return project;
+ }
+
+ public String getFileName(){
+ return fileName;
+ }
+
+ public ArrayList<TestTextChange> getTextChanges(){
+ return textChanges;
+ }
+
+ public void addTextChange(TestTextChange change){
+ textChanges.add(change);
+ }
+
+ public int size(){
+ return textChanges.size();
+ }
+
+ }
+
+ class TestTextChange{
+ private int offset;
+ private int length;
+ private String text;
+
+ public TestTextChange(int offset, int length, String text){
+ this.offset = offset;
+ this.length = length;
+ this.text = text;
+ }
+
+ public int getOffset(){
+ return offset;
+ }
+
+ public int getLength(){
+ return length;
+ }
+
+ public String getText(){
+ return text;
+ }
+ }
+}
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java 2009-12-07
18:49:25 UTC (rev 19082)
@@ -0,0 +1,109 @@
+package org.jboss.tools.common.el.core.test.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.jboss.tools.common.el.ui.refactoring.RenameMethodParticipant;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.test.util.JobUtils;
+
+public class ELReferencesRenameTest extends ELRefactoringTest {
+
+
+ public ELReferencesRenameTest(){
+ super("Rename Method Refactoring Test");
+ }
+
+
+
+ public void testRenameMethod() throws CoreException {
+ ArrayList<TestChangeStructure> list = new
ArrayList<TestChangeStructure>();
+
+
+ TestChangeStructure structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/hello.jsp");
+ TestTextChange change = new TestTextChange(353, 4, "name");
+ structure.addTextChange(change);
+ list.add(structure);
+
+ structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/inputUserName.jsp");
+ change = new TestTextChange(499, 4, "name");
+ structure.addTextChange(change);
+ list.add(structure);
+
+ IMethod method = getJavaMethod(jsfProject, "demo.User",
"getName");
+
+ renameELReferences(method, "alias", list);
+ }
+
+ public void testRenameClass() throws CoreException {
+ ArrayList<TestChangeStructure> list = new
ArrayList<TestChangeStructure>();
+
+
+ TestChangeStructure structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/hello.jsp");
+ TestTextChange change = new TestTextChange(349, 4, "user");
+ structure.addTextChange(change);
+ list.add(structure);
+
+ structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/inputUserName.jsp");
+ change = new TestTextChange(495, 4, "user");
+ structure.addTextChange(change);
+ list.add(structure);
+
+ IType type = getJavaType(jsfProject, "demo.User");
+
+ renameELReferences(type, "person", list);
+ }
+
+ private void renameELReferences(IJavaElement element, String newName,
List<TestChangeStructure> changeList) throws CoreException{
+ JobUtils.waitForIdle();
+
+
+ // Rename EL references
+ RenameMethodParticipant participant = new RenameMethodParticipant();
+ participant.initialize(element, newName);
+ participant.checkConditions(new NullProgressMonitor(), null);
+ CompositeChange rootChange = (CompositeChange)participant.createChange(new
NullProgressMonitor());
+
+ assertEquals("There is unexpected number of changes",changeList.size(),
rootChange.getChildren().length);
+
+ for(int i = 0; i < rootChange.getChildren().length;i++){
+ TextFileChange fileChange = (TextFileChange)rootChange.getChildren()[i];
+
+ MultiTextEdit edit = (MultiTextEdit)fileChange.getEdit();
+
+ TestChangeStructure change = findChange(changeList, fileChange.getFile());
+ if(change != null){
+ assertEquals(change.size(), edit.getChildrenSize());
+ }
+ }
+
+ rootChange.perform(new NullProgressMonitor());
+ JobUtils.waitForIdle();
+ // Test results
+
+ for(TestChangeStructure changeStructure : changeList){
+ IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ //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("There is unexpected change in resource - "+file.getName(),
newName, content.substring(change.getOffset(), change.getOffset()+newName.length()));
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain