Author: akazakov
Date: 2009-12-10 16:02:27 -0500 (Thu, 10 Dec 2009)
New Revision: 19198
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFImplicitObjectELResolver.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5383
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2009-12-10
20:20:20 UTC (rev 19197)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2009-12-10
21:02:27 UTC (rev 19198)
@@ -24,6 +24,13 @@
public interface IBeanManager {
/**
+ * Returns all @Named beans.
+ *
+ * @return all @Named beans
+ */
+ Set<IBean> getNamedBeans();
+
+ /**
* Returns the set of beans which match the given EL name.
*
* @param name
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java 2009-12-10
20:20:20 UTC (rev 19197)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java 2009-12-10
21:02:27 UTC (rev 19198)
@@ -11,39 +11,24 @@
package org.jboss.tools.cdi.internal.core.el;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.cdi.core.CDICorePlugin;
-import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IBeanManager;
import org.jboss.tools.cdi.core.IBeanMember;
-import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
-import org.jboss.tools.cdi.core.IInjectionPoint;
-import org.jboss.tools.cdi.core.IParametedType;
-import org.jboss.tools.cdi.core.IStereotypeDeclaration;
-import org.jboss.tools.cdi.core.ITypeDeclaration;
-import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.parser.ELParserFactory;
import org.jboss.tools.common.el.core.parser.ELParserUtil;
import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.MemberInfo;
-import org.jboss.tools.common.text.ITextSourceReference;
/**
* @author Alexey Kazakov
@@ -103,12 +88,14 @@
String varName = expr.toString();
+ Set<IBean> resolvedBeans = null;
if (varName != null) {
IBeanManager manager = CDICorePlugin.getCDI(project, false).getDelegate();
- Set<IBean> resolvedBeans = manager.getBeans(varName, true);
if(onlyEqualNames) {
+ resolvedBeans = manager.getBeans(varName, true);
beans.addAll(resolvedBeans);
} else {
+ resolvedBeans = manager.getNamedBeans();
for (IBean bean : resolvedBeans) {
if(bean.getName().startsWith(varName)) {
beans.add(bean);
@@ -116,22 +103,20 @@
}
}
}
- if (beans.isEmpty() && varName != null &&
(varName.startsWith("\"") || varName.startsWith("'"))
- && (varName.endsWith("\"") ||
varName.endsWith("'"))) {
- IJavaProject jp = EclipseUtil.getJavaProject(project.getProject());
- try {
- IType type = jp.findType("java.lang.String");
- if(type != null) {
- IMethod m = type.getMethod("toString", new String[0]);
- if(m != null) {
- IBean bean = new StringVariable(m);
- beans.add(bean);
+ if (resolvedBeans != null && !resolvedBeans.isEmpty()) {
+ List<IBean> newResolvedVars = new ArrayList<IBean>();
+ for (IBean var : resolvedBeans) {
+ if(!isFinal) {
+ // Do filter by equals (name)
+ // In case of the last pass - do not filter by startsWith(name) instead of equals
+ if (varName.equals(var.getName())) {
+ newResolvedVars.add(var);
}
+ } else {
+ newResolvedVars.add(var);
}
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
}
-
+ return newResolvedVars;
}
return beans;
}
@@ -143,97 +128,4 @@
public ELParserFactory getParserFactory() {
return factory;
}
-
- private static class StringVariable implements IBean {
-
- private IMember member;
-
- public StringVariable(IMember member) {
- this.member = member;
- }
-
- public Set<ITypeDeclaration> getAllTypeDeclarations() {
- return Collections.emptySet();
- }
-
- public IAnnotationDeclaration getAlternativeDeclaration() {
- return null;
- }
-
- public IType getBeanClass() {
- return member.getDeclaringType();
- }
-
- public Set<IInjectionPoint> getInjectionPoints() {
- return Collections.emptySet();
- }
-
- public Set<IParametedType> getLegalTypes() {
- return Collections.emptySet();
- }
-
- public String getName() {
- return null;
- }
-
- public ITextSourceReference getNameLocation() {
- return null;
- }
-
- public Set<IAnnotationDeclaration> getQualifierDeclarations() {
- return Collections.emptySet();
- }
-
- public Set<ITypeDeclaration> getRestrictedTypeDeclaratios() {
- return Collections.emptySet();
- }
-
- public IBean getSpecializedBean() {
- return null;
- }
-
- public IAnnotationDeclaration getSpecializesAnnotationDeclaration() {
- return null;
- }
-
- public Set<IStereotypeDeclaration> getStereotypeDeclarations() {
- return Collections.emptySet();
- }
-
- public boolean isAlternative() {
- return false;
- }
-
- public boolean isDependent() {
- return false;
- }
-
- public boolean isEnabled() {
- return false;
- }
-
- public boolean isSpecializing() {
- return false;
- }
-
- public IType getScope() {
- return null;
- }
-
- public Set<IAnnotationDeclaration> getScopeDeclarations() {
- return Collections.emptySet();
- }
-
- public ICDIProject getCDIProject() {
- return null;
- }
-
- public IResource getResource() {
- return member.getResource();
- }
-
- public IPath getSourcePath() {
- return member.getPath();
- }
- }
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-10
20:20:20 UTC (rev 19197)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-10
21:02:27 UTC (rev 19198)
@@ -34,7 +34,6 @@
import org.jboss.tools.cdi.core.IObserverMethod;
import org.jboss.tools.cdi.core.IProducer;
import org.jboss.tools.cdi.core.IStereotype;
-import org.jboss.tools.cdi.internal.core.impl.definition.AbstractTypeDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
import org.jboss.tools.common.text.INodeReference;
@@ -347,4 +346,12 @@
bs.add(bean);
}
-}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBeanManager#getNamedBeans()
+ */
+ public Set<IBean> getNamedBeans() {
+ // TODO
+ return new HashSet<IBean>();
+ }
+}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java 2009-12-10
20:20:20 UTC (rev 19197)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFELCompletionEngine.java 2009-12-10
21:02:27 UTC (rev 19198)
@@ -14,7 +14,11 @@
import java.util.List;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.swt.graphics.Image;
import org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
@@ -69,7 +73,7 @@
*/
public List<IJSFVariable> resolveVariables(IFile file, ELInvocationExpression
expr, boolean isFinal, boolean onlyEqualNames) {
IModelNature project = EclipseResourceUtil.getModelNature(file.getProject());
- return resolveVariables(project, expr, isFinal, onlyEqualNames);
+ return resolveVariables(file, project, expr, isFinal, onlyEqualNames);
}
/**
@@ -80,7 +84,7 @@
* @param onlyEqualNames
* @return
*/
- public List<IJSFVariable> resolveVariables(IModelNature project,
ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
+ public List<IJSFVariable> resolveVariables(IFile file, IModelNature project,
ELInvocationExpression expr, boolean isFinal, boolean onlyEqualNames) {
List<IJSFVariable>resolvedVars = new ArrayList<IJSFVariable>();
if (project == null)
@@ -105,6 +109,24 @@
}
}
return newResolvedVars;
+ } else if (varName != null && (varName.startsWith("\"") ||
varName.startsWith("'")) && (varName.endsWith("\"")
|| varName.endsWith("'"))) {
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(file.getProject());
+ if(jp!=null) {
+ try {
+ IType type = jp.findType("java.lang.String");
+ if (type != null) {
+ IMethod m = type.getMethod("toString", new String[0]);
+ if (m != null) {
+ IJSFVariable v = new Variable("String", m);
+ List<IJSFVariable> newResolvedVars = new ArrayList<IJSFVariable>();
+ newResolvedVars.add(v);
+ return newResolvedVars;
+ }
+ }
+ } catch (JavaModelException e) {
+ JSFModelPlugin.getDefault().logError(e);
+ }
+ }
}
return new ArrayList<IJSFVariable>();
}
@@ -139,4 +161,31 @@
public static interface IJSFVariable extends IVariable {
public IMember getSourceMember();
}
+
+ public static class Variable implements IJSFVariable {
+
+ private String name;
+ private IMember source;
+
+ public Variable(String name, IMember source) {
+ this.name = name;
+ this.source = source;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jsf.model.JSFELCompletionEngine.IJSFVariable#getSourceMember()
+ */
+ public IMember getSourceMember() {
+ return source;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine.IVariable#getName()
+ */
+ public String getName() {
+ return name;
+ }
+ }
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFImplicitObjectELResolver.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFImplicitObjectELResolver.java 2009-12-10
20:20:20 UTC (rev 19197)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFImplicitObjectELResolver.java 2009-12-10
21:02:27 UTC (rev 19198)
@@ -18,7 +18,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.text.BadLocationException;
@@ -153,31 +152,4 @@
}
return list;
}
-
- public static class Variable implements IJSFVariable {
-
- private String name;
- private IMember source;
-
- public Variable(String name, IMember source) {
- this.name = name;
- this.source = source;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jsf.model.JSFELCompletionEngine.IJSFVariable#getSourceMember()
- */
- public IMember getSourceMember() {
- return source;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.jst.web.kb.el.AbstractELCompletionEngine.IVariable#getName()
- */
- public String getName() {
- return name;
- }
- }
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2009-12-10
20:20:20 UTC (rev 19197)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2009-12-10
21:02:27 UTC (rev 19198)
@@ -12,22 +12,14 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -48,10 +40,6 @@
import org.jboss.tools.common.el.core.resolver.JavaMemberELSegment;
import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
import org.jboss.tools.common.el.core.resolver.Var;
-import org.jboss.tools.common.java.IJavaSourceReference;
-import org.jboss.tools.common.model.project.ext.event.Change;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.text.ITextSourceReference;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
@@ -64,7 +52,6 @@
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.el.SeamExpressionResolver.MessagesInfo;
-import org.w3c.dom.Element;
/**
* Utility class used to collect info for EL
@@ -277,25 +264,6 @@
}
return newResolvedVars;
}
- else if(varName != null && (varName.startsWith("\"") ||
varName.startsWith("'"))
- && (varName.endsWith("\"") ||
varName.endsWith("'"))) {
- IJavaProject jp = EclipseResourceUtil.getJavaProject(project.getProject());
- try {
- IType type = jp.findType("java.lang.String");
- if(type != null) {
- IMethod m = type.getMethod("toString", new String[0]);
- if(m != null) {
- ISeamContextVariable v = new StringVariable(m);
- List<ISeamContextVariable> newResolvedVars = new
ArrayList<ISeamContextVariable>();
- newResolvedVars.add(v);
- return newResolvedVars;
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
-
- }
return new ArrayList<ISeamContextVariable>();
}
@@ -414,59 +382,4 @@
public static boolean isSeamMessagesComponentVariable(ISeamContextVariable variable) {
return (null != getSeamMessagesComponentVariable(variable));
}
-}
-
-class StringVariable implements ISeamContextVariable, IJavaSourceReference {
- IMember member;
- public StringVariable(IMember member) {
- this.member = member;
- }
- public ScopeType getScope() {
- return ScopeType.APPLICATION;
- }
- public void setName(String name) {
- }
- public void setScope(ScopeType type) {
- }
- public ITextSourceReference getLocationFor(String path) {
- return null;
- }
- public String getName() {
- return "String";
- }
- public ISeamElement getParent() {
- return null;
- }
- public IResource getResource() {
- return null;
- }
- public ISeamProject getSeamProject() {
- return null;
- }
- public IPath getSourcePath() {
- return null;
- }
- public void loadXML(Element element, Properties context) {
- }
- public List<Change> merge(ISeamElement s) {
- return null;
- }
- public Element toXML(Element parent, Properties context) {
- return null;
- }
- public Object getAdapter(Class adapter) {
- return null;
- }
- public IMember getSourceMember() {
- return member;
- }
- public int getLength() {
- return 0;
- }
- public int getStartPosition() {
- return 0;
- }
- public StringVariable clone() throws CloneNotSupportedException {
- throw new CloneNotSupportedException();
- }
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2009-12-10
20:20:20 UTC (rev 19197)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2009-12-10
21:02:27 UTC (rev 19198)
@@ -105,14 +105,8 @@
}
for (ISeamContextVariable variable : variables) {
String n = variable.getName();
- if(onlyEqualNames) {
- if (n.equals(name)) {
- resolvedVariables.add(variable);
- }
- } else {
- if (n.startsWith(name)) {
- resolvedVariables.add(variable);
- }
+ if (n.startsWith(name)) {
+ resolvedVariables.add(variable);
}
}
return resolvedVariables;