Author: vrubezhny
Date: 2010-04-02 17:13:06 -0400 (Fri, 02 Apr 2010)
New Revision: 21250
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegment.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.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
Log:
JBIDE-4947: Tool tip for EL in XHTML/JSP/XML editors.
The EL Tooltips are done for EL in Strings for Java Editor and for EL's in XHTML/JSP
editors (but with no icons because of WTP hovers limitations)
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2010-04-02
20:57:25 UTC (rev 21249)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ca/AbstractELCompletionEngine.java 2010-04-02
21:13:06 UTC (rev 21250)
@@ -12,8 +12,10 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@@ -61,7 +63,6 @@
import org.jboss.tools.common.text.TextProposal;
public abstract class AbstractELCompletionEngine<V extends IVariable> implements
ELResolver, ELCompletionEngine {
-
public AbstractELCompletionEngine() {}
public abstract Image getELProposalImage();
@@ -797,13 +798,16 @@
proposalsToFilter.addAll(infos.getPropertyPresentations(segment.getUnpairedGettersOrSetters()));
// segment.setMemberInfo(mbr);
}
+
for (TypeInfoCollector.MemberPresentation proposal : proposalsToFilter) {
// We do expect nothing but name for method tokens (No round brackets)
String filter = expr.getMemberName();
if(filter == null) filter = ""; //$NON-NLS-1$
+ String presentationString = proposal.getPresentation();
+
if(returnEqualedVariablesOnly) {
// This is used for validation.
- if (proposal.getPresentation().equals(filter)) {
+ if (presentationString.equals(filter)) {
TextProposal kbProposal = new TextProposal();
kbProposal.setReplacementString(proposal.getPresentation());
@@ -812,6 +816,14 @@
kbProposals.add(kbProposal);
segment.setMemberInfo(proposal.getMember());
+ if (proposal.getAllMembers() != null &&
!proposal.getAllMembers().isEmpty()) {
+ for (MemberInfo mi : proposal.getAllMembers()) {
+ IJavaElement je = mi.getJavaElement();
+ if (je != null) {
+ segment.addJavaElement(je);
+ }
+ }
+ }
if(segment.getUnpairedGettersOrSetters()!=null) {
TypeInfoCollector.MethodInfo unpirMethod =
segment.getUnpairedGettersOrSetters().get(filter);
segment.clearUnpairedGettersOrSetters();
@@ -821,7 +833,7 @@
}
break;
}
- } else if (proposal.getPresentation().startsWith(filter)) {
+ } else if (presentationString.startsWith(filter)) {
// JBIDE-512, JBIDE-2541 related changes ===>>>
// This is used for CA.
@@ -899,6 +911,16 @@
kbProposals.add(kbProposal);
segment.setMemberInfo(proposal.getMember());
+
+ if (proposal.getAllMembers() != null &&
!proposal.getAllMembers().isEmpty()) {
+ for (MemberInfo mi : proposal.getAllMembers()) {
+ IJavaElement je = mi.getJavaElement();
+ if (je != null) {
+ segment.addJavaElement(je);
+ }
+ }
+ }
+
if(segment.getUnpairedGettersOrSetters()!=null) {
TypeInfoCollector.MethodInfo unpirMethod =
segment.getUnpairedGettersOrSetters().get(filter);
segment.clearUnpairedGettersOrSetters();
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegment.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegment.java 2010-04-02
20:57:25 UTC (rev 21249)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegment.java 2010-04-02
21:13:06 UTC (rev 21250)
@@ -29,6 +29,13 @@
IJavaElement getJavaElement();
/**
+ * Returns the array of Java Elements collected for the segment
+ *
+ * @return The Array of collected Java Elements
+ */
+ IJavaElement[] getAllJavaElements();
+
+ /**
* @return true if an underlying object is field and this field has getter.
*/
boolean hasGetter();
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 2010-04-02
20:57:25 UTC (rev 21249)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/JavaMemberELSegmentImpl.java 2010-04-02
21:13:06 UTC (rev 21250)
@@ -11,7 +11,9 @@
package org.jboss.tools.common.el.core.resolver;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import org.eclipse.jdt.core.IJavaElement;
import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.MemberInfo;
@@ -22,6 +24,7 @@
public class JavaMemberELSegmentImpl extends ELSegmentImpl implements JavaMemberELSegment
{
protected IJavaElement element;
+ protected Set<IJavaElement> allElements;
protected MemberInfo memberInfo;
protected boolean hasSetter;
protected boolean hasGetter;
@@ -66,6 +69,29 @@
}
/**
+ * Adds a Java Element for the Segment
+ *
+ * @param element
+ */
+ public void addJavaElement(IJavaElement element) {
+ if (this.allElements == null) {
+ this.allElements = new HashSet<IJavaElement>();
+ }
+ this.allElements.add(element);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.el.core.resolver.JavaMemberELSegment#getAllJavaElements()
+ */
+ public IJavaElement[] getAllJavaElements() {
+ if (this.allElements == null || this.allElements.size() == 0) {
+ return new IJavaElement[0];
+ }
+ return (IJavaElement[])this.allElements.toArray(new
IJavaElement[this.allElements.size()]);
+ }
+
+ /**
* @return the hasSetter
*/
public boolean isHasSetter() {
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2010-04-02
20:57:25 UTC (rev 21249)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2010-04-02
21:13:06 UTC (rev 21250)
@@ -971,11 +971,13 @@
public static class MemberPresentation {
private String presentation;
private MemberInfo member;
+ private Set<MemberInfo> allMembers = new HashSet<MemberInfo>();
public MemberPresentation(String presentation, MemberInfo member) {
super();
this.presentation = presentation;
this.member = member;
+ addMember(member);
}
public String getPresentation() {
@@ -1003,6 +1005,28 @@
public String toString() {
return presentation;
}
+
+ /**
+ * Adds a pair member to the member info
+ * In case of a property there may be up to 2 members added: getter and setter
+ * In case of a method there will be a single member added (the method itself)
+ *
+ * @param pair
+ */
+ public void addMember(MemberInfo pair) {
+ this.allMembers.add(pair);
+ }
+
+ /**
+ * Returns all the members collected
+ * In case of a property there may be up to 2 members returned: getter and setter
+ * In case of a method there will be a single member returned (the method itself)
+ *
+ * @return
+ */
+ public Set<MemberInfo> getAllMembers() {
+ return allMembers;
+ }
}
private static class MemberPresentationComparator implements
Comparator<MemberPresentation> {
@@ -1138,6 +1162,7 @@
*/
public Set<MemberPresentation> getPropertyPresentations(Map<String,
MethodInfo> unpairedGettersOrSetters) {
Set<MemberPresentation> properties = new
TreeSet<MemberPresentation>(MEMBER_PRESENTATION_COMPARATOR);
+ HashMap<String, MemberPresentation> presentations = new HashMap<String,
MemberPresentation>();
List<MemberInfo> props = getProperties();
HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
HashMap<String, MethodInfo> setters = new HashMap<String, MethodInfo>();
@@ -1159,6 +1184,10 @@
MemberPresentation pr = new MemberPresentation(propertyName, m);
if(!properties.contains(pr)) {
properties.add(pr);
+ presentations.put(pr.getPresentation(), pr);
+ } else {
+ MemberPresentation existingPresentation = presentations.get(pr.getPresentation());
+ existingPresentation.addMember(m);
}
if(unpairedGettersOrSetters!=null) {
MethodInfo previousGetter = getters.get(propertyName);
@@ -1176,7 +1205,9 @@
}
}
} else {
- properties.add(new MemberPresentation(info.getName(), info));
+ MemberPresentation pr = new MemberPresentation(info.getName(), info);
+ properties.add(pr);
+ presentations.put(pr.getPresentation(), pr);
}
}
return properties;