Author: dazarov
Date: 2009-10-08 12:39:24 -0400 (Thu, 08 Oct 2009)
New Revision: 17984
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/resolver/ELResolutionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameMethodParticipant.java
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.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4771,
https://jira.jboss.org/jira/browse/JBIDE-4856
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-10-08
15:28:23 UTC (rev 17983)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java 2009-10-08
16:39:24 UTC (rev 17984)
@@ -56,7 +56,6 @@
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
import org.jboss.tools.common.el.core.resolver.ELSegment;
import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
-import org.jboss.tools.common.el.core.resolver.JavaMemberELSegment;
import org.jboss.tools.common.el.core.resolver.SimpleELContext;
import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -282,7 +281,7 @@
for(ELInvocationExpression ie : instance.getExpression().getInvocations()){
ELInvocationExpression expression = findComponentReference(ie);
if(expression != null){
- checkMatch(file, expression, getOffset(expression), offset+getOffset(expression),
getLength(expression));
+ checkMatch(file, expression, offset+getOffset(expression), getLength(expression));
}
}
}
@@ -353,49 +352,22 @@
offset += token.length();
}
}
-
protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
- ELInvocationExpression invExp = invocationExpression;
- while(invExp != null){
- if(invExp instanceof ELPropertyInvocation){
- if(((ELPropertyInvocation)invExp).getQualifiedName() != null &&
((ELPropertyInvocation)invExp).getQualifiedName().equals(propertyName))
- return invExp;
- else
- invExp = invExp.getLeft();
-
- }else{
- invExp = invExp.getLeft();
- }
- }
- return null;
+ return invocationExpression;
}
protected abstract boolean isFileCorrect(IFile file);
protected abstract void match(IFile file, int offset, int length);
- private void checkMatch(IFile file, ELExpression operand, int localOffset, int offset,
int length){
+ private void checkMatch(IFile file, ELExpression operand, int offset, int length){
if(javaElement != null && operand != null)
- resolve(file, operand, localOffset, offset, length);
+ resolve(file, operand, offset-getOffset((ELInvocationExpression)operand));
else
match(file, offset, length);
}
- public static String getPropertyName(String methodName){
- if(methodName.startsWith(GET) || methodName.startsWith(SET)){
- String name = methodName.substring(3);
- return name.substring(0, 1).toLowerCase()+name.substring(1);
- }
-
- if(methodName.startsWith(IS)){
- String name = methodName.substring(2);
- return name.substring(0, 1).toLowerCase()+name.substring(1);
- }
-
- return methodName;
- }
-
// TODO: move to util class
public boolean isGetter(IMethod method) {
String name = method.getElementName();
@@ -423,8 +395,7 @@
return false;
}
- private void resolve(IFile file, ELExpression operand, int localOffset,
- int offset, int length) {
+ private void resolve(IFile file, ELExpression operand, int offset) {
ELResolver[] resolvers = ELResolverFactoryManager.getInstance()
.getResolvers(file);
@@ -437,24 +408,28 @@
context.setResource(file);
context.setElResolvers(resolvers);
- List<Var> vars = ElVarSearcher.findAllVars(context, localOffset,
+ List<Var> vars = ElVarSearcher.findAllVars(context, offset,
resolver);
context.setVars(vars);
ELResolution resolution = resolver.resolve(context, operand);
- ELSegment segment = resolution.findSegmentByOffset(localOffset);
-
- if (segment != null && segment instanceof JavaMemberELSegment
- && segment.isResolved()) {
- JavaMemberELSegment javaSegment = (JavaMemberELSegment) segment;
- IJavaElement segmentJavaElement = javaSegment.getJavaElement();
- if (javaElement.equals(segmentJavaElement)){
- match(file, offset, length);
- return;
- }
+ List<ELSegment> segments = resolution.findSegmentsByJavaElement(javaElement);
+
+ for(ELSegment segment : segments){
+ match(file, offset+segment.getSourceReference().getStartPosition(),
segment.getSourceReference().getLength());
}
+
+// if (segment != null && segment instanceof JavaMemberELSegment
+// && segment.isResolved()) {
+// JavaMemberELSegment javaSegment = (JavaMemberELSegment) segment;
+// IJavaElement segmentJavaElement = javaSegment.getJavaElement();
+// if (javaElement.equals(segmentJavaElement)){
+// match(file, offset, length);
+// return;
+// }
+// }
}
}
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolutionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolutionImpl.java 2009-10-08
15:28:23 UTC (rev 17983)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolutionImpl.java 2009-10-08
16:39:24 UTC (rev 17984)
@@ -38,7 +38,7 @@
public List<ELSegment> findSegmentsByJavaElement(IJavaElement element) {
ArrayList<ELSegment> list = new ArrayList<ELSegment>();
for(ELSegment segment : segments){
- if(segment instanceof JavaMemberELSegment &&
((JavaMemberELSegment)segment).getJavaElement().equals(element))
+ if(segment instanceof JavaMemberELSegment &&
((JavaMemberELSegment)segment).getJavaElement() != null &&
((JavaMemberELSegment)segment).getJavaElement().equals(element))
list.add(segment);
}
return list;
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java 2009-10-08
15:28:23 UTC (rev 17983)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java 2009-10-08
16:39:24 UTC (rev 17984)
@@ -31,6 +31,9 @@
* @see org.jboss.tools.common.el.core.resolver.JavaMemberElSegment#getJavaElement()
*/
public IJavaElement getJavaElement() {
+ if(element==null && memberInfo!=null) {
+ element = memberInfo.getJavaElement();
+ }
return element;
}
@@ -56,16 +59,6 @@
}
/**
- * @return the element
- */
- public IJavaElement getElement() {
- if(element==null && memberInfo!=null) {
- element = memberInfo.getJavaElement();
- }
- return element;
- }
-
- /**
* @param element the element to set
*/
public void setElement(IJavaElement element) {
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-10-08
15:28:23 UTC (rev 17983)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-10-08
16:39:24 UTC (rev 17984)
@@ -90,9 +90,9 @@
rootChange = new CompositeChange("");
method = (IMethod)element;
- oldName = SeamRenameMethodSearcher.getPropertyName(method.getElementName());
+ oldName = method.getElementName();
- newName = SeamRenameMethodSearcher.getPropertyName(getArguments().getNewName());
+ newName = getArguments().getNewName();
searcher = new SeamRenameMethodSearcher((IFile)method.getResource(), oldName);
added = false;
return true;
@@ -160,20 +160,20 @@
return null;
}
- protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
- ELInvocationExpression invExp = invocationExpression;
- while(invExp != null){
- if(invExp instanceof ELMethodInvocation || invExp instanceof ELPropertyInvocation){
- if(invExp.getMemberName() != null &&
invExp.getMemberName().equals(propertyName))
- return invExp;
- else
- invExp = invExp.getLeft();
- }else{
- invExp = invExp.getLeft();
- }
- }
- return null;
- }
+// protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
+// ELInvocationExpression invExp = invocationExpression;
+// while(invExp != null){
+// if(invExp instanceof ELMethodInvocation || invExp instanceof
ELPropertyInvocation){
+// if(invExp.getMemberName() != null &&
invExp.getMemberName().equals(propertyName))
+// return invExp;
+// else
+// invExp = invExp.getLeft();
+// }else{
+// invExp = invExp.getLeft();
+// }
+// }
+// return null;
+// }
@Override
protected void match(IFile file, int offset, int length) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameMethodParticipant.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameMethodParticipant.java 2009-10-08
15:28:23 UTC (rev 17983)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameMethodParticipant.java 2009-10-08
16:39:24 UTC (rev 17984)
@@ -91,9 +91,9 @@
rootChange = new CompositeChange("");
method = (IMethod)element;
- oldName = SeamRenameMethodSearcher.getPropertyName(method.getElementName());
+ oldName = method.getElementName();
- newName = SeamRenameMethodSearcher.getPropertyName(getArguments().getNewName());
+ newName = getArguments().getNewName();
searcher = new SeamRenameMethodSearcher((IFile)method.getResource(), oldName);
added = false;
return true;
@@ -167,20 +167,20 @@
return null;
}
- protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
- ELInvocationExpression invExp = invocationExpression;
- while(invExp != null){
- if(invExp instanceof ELMethodInvocation || invExp instanceof ELPropertyInvocation){
- if(invExp.getMemberName() != null &&
invExp.getMemberName().equals(propertyName))
- return invExp;
- else
- invExp = invExp.getLeft();
- }else{
- invExp = invExp.getLeft();
- }
- }
- return null;
- }
+// protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
+// ELInvocationExpression invExp = invocationExpression;
+// while(invExp != null){
+// if(invExp instanceof ELMethodInvocation || invExp instanceof
ELPropertyInvocation){
+// if(invExp.getMemberName() != null &&
invExp.getMemberName().equals(propertyName))
+// return invExp;
+// else
+// invExp = invExp.getLeft();
+// }else{
+// invExp = invExp.getLeft();
+// }
+// }
+// return null;
+// }
@Override
protected void match(IFile file, int offset, int length) {
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-10-08
15:28:23 UTC (rev 17983)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRenameProcessor.java 2009-10-08
16:39:24 UTC (rev 17984)
@@ -30,6 +30,8 @@
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
import org.jboss.tools.common.el.core.refactoring.RefactorSearcher;
import org.jboss.tools.common.model.project.ext.ITextSourceReference;
import org.jboss.tools.common.util.FileUtil;
@@ -461,6 +463,22 @@
return projectsSet.getAllProjects();
}
+ protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
+ ELInvocationExpression invExp = invocationExpression;
+ while(invExp != null){
+ if(invExp instanceof ELPropertyInvocation){
+ if(((ELPropertyInvocation)invExp).getQualifiedName() != null &&
((ELPropertyInvocation)invExp).getQualifiedName().equals(propertyName))
+ return invExp;
+ else
+ invExp = invExp.getLeft();
+
+ }else{
+ invExp = invExp.getLeft();
+ }
+ }
+ return null;
+ }
+
protected IContainer getViewFolder(IProject project){
if(project.equals(projectsSet.getWarProject()))
return projectsSet.getDefaultViewsFolder();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java 2009-10-08
15:28:23 UTC (rev 17983)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java 2009-10-08
16:39:24 UTC (rev 17984)
@@ -53,7 +53,7 @@
ElementQuerySpecification qs = (ElementQuerySpecification)querySpecification;
if(qs.getElement() instanceof IMethod){
IFile file = (IFile)qs.getElement().getResource();
- String name = ELSearcher.getPropertyName(qs.getElement().getElementName());
+ String name = qs.getElement().getElementName();
searcher = new ELSearcher(requestor, qs.getElement(), file, name);
searcher.setSearchScope(qs.getScope());
@@ -112,19 +112,19 @@
requestor.reportMatch(match);
}
- protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
- ELInvocationExpression invExp = invocationExpression;
- while(invExp != null){
- if(invExp instanceof ELMethodInvocation || invExp instanceof ELPropertyInvocation){
- if(invExp.getMemberName() != null &&
invExp.getMemberName().equals(propertyName))
- return invExp;
- else
- invExp = invExp.getLeft();
- }else{
- invExp = invExp.getLeft();
- }
- }
- return null;
- }
+// protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
+// ELInvocationExpression invExp = invocationExpression;
+// while(invExp != null){
+// if(invExp instanceof ELMethodInvocation || invExp instanceof
ELPropertyInvocation){
+// if(invExp.getMemberName() != null &&
invExp.getMemberName().equals(propertyName))
+// return invExp;
+// else
+// invExp = invExp.getLeft();
+// }else{
+// invExp = invExp.getLeft();
+// }
+// }
+// return null;
+// }
}
}