[jbosstools-commits] JBoss Tools SVN: r30448 - branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri Apr 8 19:51:33 EDT 2011
Author: scabanovich
Date: 2011-04-08 19:51:33 -0400 (Fri, 08 Apr 2011)
New Revision: 30448
Added:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
Log:
JBIDE-8697
https://issues.jboss.org/browse/JBIDE-8697
Added: branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java
===================================================================
--- branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java (rev 0)
+++ branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java 2011-04-08 23:51:33 UTC (rev 30448)
@@ -0,0 +1,166 @@
+package org.jboss.tools.cdi.internal.core.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IParametedType;
+import org.jboss.tools.cdi.core.IQualifier;
+import org.jboss.tools.cdi.core.IQualifierDeclaration;
+import org.jboss.tools.cdi.core.IScope;
+import org.jboss.tools.cdi.core.IScopeDeclaration;
+import org.jboss.tools.cdi.core.IStereotypeDeclaration;
+import org.jboss.tools.cdi.core.ITypeDeclaration;
+import org.jboss.tools.common.text.ITextSourceReference;
+
+/**
+ * 3.6. Additional built-in beans.
+
+ * scope @ Dependent,
+ * no bean EL name
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class BuiltInBean extends CDIElement implements IBean {
+ protected IParametedType type;
+ protected Set<IQualifier> qualifiers = null;
+
+ public BuiltInBean(IParametedType type) {
+ this.type = type;
+ }
+
+ public IScope getScope() {
+ return getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
+ }
+
+ public Set<IScopeDeclaration> getScopeDeclarations() {
+ return new HashSet<IScopeDeclaration>();
+ }
+
+ public Set<IStereotypeDeclaration> getStereotypeDeclarations() {
+ return new HashSet<IStereotypeDeclaration>();
+ }
+
+ public List<IAnnotationDeclaration> getAnnotations() {
+ return new ArrayList<IAnnotationDeclaration>();
+ }
+
+ public IAnnotationDeclaration getAnnotation(String annotationTypeName) {
+ return null;
+ }
+
+ public ITextSourceReference getAnnotationPosition(String annotationTypeName) {
+ return null;
+ }
+
+ public boolean isAnnotationPresent(String annotationTypeName) {
+ return false;
+ }
+
+ public IType getBeanClass() {
+ return type.getType();
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public ITextSourceReference getNameLocation() {
+ return null;
+ }
+
+ public Set<IParametedType> getLegalTypes() {
+ return getAllTypes();
+ }
+
+ public Set<IParametedType> getAllTypes() {
+ Set<IParametedType> result = new HashSet<IParametedType>();
+ result.add(type);
+ return result;
+ }
+
+ public Set<ITypeDeclaration> getAllTypeDeclarations() {
+ return new HashSet<ITypeDeclaration>();
+ }
+
+ public Set<ITypeDeclaration> getRestrictedTypeDeclaratios() {
+ return new HashSet<ITypeDeclaration>();
+ }
+
+ public Set<IQualifierDeclaration> getQualifierDeclarations() {
+ return new HashSet<IQualifierDeclaration>();
+ }
+
+ public Set<IQualifierDeclaration> getQualifierDeclarations(boolean includeInherited) {
+ return new HashSet<IQualifierDeclaration>();
+ }
+
+ public Set<IQualifier> getQualifiers() {
+ if(qualifiers == null) {
+ computeQualifiers();
+ }
+ return qualifiers;
+ }
+
+ protected void computeQualifiers() {
+ qualifiers = new HashSet<IQualifier>();
+ }
+
+ public boolean isAlternative() {
+ return false;
+ }
+
+ public boolean isSelectedAlternative() {
+ return false;
+ }
+
+ public IAnnotationDeclaration getAlternativeDeclaration() {
+ return null;
+ }
+
+ public Set<IInjectionPoint> getInjectionPoints() {
+ return new HashSet<IInjectionPoint>();
+ }
+
+ public IBean getSpecializedBean() {
+ return null;
+ }
+
+ public IAnnotationDeclaration getSpecializesAnnotationDeclaration() {
+ return null;
+ }
+
+ public boolean isSpecializing() {
+ return false;
+ }
+
+ public boolean isDependent() {
+ return true;
+ }
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public boolean isNullable() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#getSimpleJavaName()
+ */
+ public String getSimpleJavaName() {
+ if(type!=null) {
+ return type.getSimpleName();
+ }
+ return "";
+ }
+}
\ No newline at end of file
Property changes on: branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-04-08 23:50:59 UTC (rev 30447)
+++ branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-04-08 23:51:33 UTC (rev 30448)
@@ -328,6 +328,21 @@
}
}
+ if(isBuiltIn(type.getType())) {
+ Set<IBean> rslt = null;
+ if(isParameter) {
+ rslt = getBeans(attemptToResolveAmbiguousDependency, type, qs2.toArray(new IType[0]));
+ } else {
+ rslt = getBeans(attemptToResolveAmbiguousDependency, type, qs.toArray(new IQualifierDeclaration[0]));
+ }
+ if(rslt != null && !rslt.isEmpty()) return rslt;
+ BuiltInBean builtInBean = new BuiltInBean(type);
+ builtInBean.setParent(this);
+ builtInBean.setSourcePath(injectionPoint.getSourcePath());
+ result.add(builtInBean);
+ return result;
+ }
+
Set<IBean> beans = new HashSet<IBean>();
synchronized(allBeans) {
beans.addAll(allBeans);
@@ -378,6 +393,17 @@
return getResolvedBeans(result, attemptToResolveAmbiguousDependency);
}
+ static Set<String> BUILT_IN = new HashSet<String>();
+ static {
+ BUILT_IN.add(CDIConstants.USER_TRANSACTION_TYPE_NAME);
+ BUILT_IN.add(CDIConstants.PRINCIPAL_TYPE_NAME);
+ BUILT_IN.add(CDIConstants.VALIDATION_FACTORY_TYPE_NAME);
+ BUILT_IN.add(CDIConstants.VALIDATOR_TYPE_NAME);
+ }
+ static boolean isBuiltIn(IType type) {
+ return type != null && BUILT_IN.contains(type.getFullyQualifiedName());
+ }
+
public static boolean containsType(Set<IParametedType> types, IParametedType type) {
if(type == null) {
return false;
More information about the jbosstools-commits
mailing list