Author: akazakov
Date: 2010-02-04 11:10:07 -0500 (Thu, 04 Feb 2010)
New Revision: 20132
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2708
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2010-02-04
15:53:51 UTC (rev 20131)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBean.java 2010-02-04
16:10:07 UTC (rev 20132)
@@ -56,6 +56,14 @@
Set<IParametedType> getLegalTypes();
/**
+ * Obtains all the types of the bean class or producer method or
+ * field (legal types as well as illegal ones). This set will contain inherited types of
the bean.
+ *
+ * @return the legal types
+ */
+ Set<IParametedType> getAllTypes();
+
+ /**
* Obtains all the type declarations of the bean class or producer method or
* field (legal types as well as illegal ones).
*
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2010-02-04
15:53:51 UTC (rev 20131)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2010-02-04
16:10:07 UTC (rev 20132)
@@ -32,7 +32,7 @@
*/
public abstract class BeanMember extends AbstractBeanElement implements IBeanMember {
protected IClassBean classBean;
- protected ITypeDeclaration typeDeclaration;
+ protected TypeDeclaration typeDeclaration;
public BeanMember() {}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-02-04
15:53:51 UTC (rev 20131)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-02-04
16:10:07 UTC (rev 20132)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 2009 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,
@@ -234,6 +234,15 @@
result.addAll(ts);
return result;
}
+ return getAllTypes();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#getAllTypes()
+ */
+ public Set<IParametedType> getAllTypes() {
+ Set<IParametedType> result = new HashSet<IParametedType>();
IType type = getDefinition().getType();
if(type != null) {
ParametedType p = new ParametedType();
@@ -243,6 +252,7 @@
ps = type.getTypeParameterSignatures();
p.setSignature("Q" + type.getFullyQualifiedName() + ',');
} catch (CoreException e) {
+ CDICorePlugin.getDefault().logError(e);
//TODO
}
if(ps == null || ps.length == 0) {
@@ -404,5 +414,4 @@
scope = getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
}
}
-
-}
+}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2010-02-04
15:53:51 UTC (rev 20131)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2010-02-04
16:10:07 UTC (rev 20132)
@@ -11,7 +11,6 @@
package org.jboss.tools.cdi.internal.core.impl;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.eclipse.jdt.core.IAnnotation;
@@ -30,9 +29,7 @@
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
-import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
import org.jboss.tools.common.model.project.ext.impl.ValueInfo;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.text.ITextSourceReference;
/**
@@ -57,7 +54,7 @@
}
public IType getBeanClass() {
- return typeDeclaration != null ? typeDeclaration.getType() : null;
+ return getClassBean().getBeanClass();
}
public Set<IInjectionPoint> getInjectionPoints() {
@@ -72,9 +69,25 @@
result.addAll(ts);
return result;
}
+ return getAllTypes();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#getAllTypes()
+ */
+ public Set<IParametedType> getAllTypes() {
+ Set<IParametedType> result = new HashSet<IParametedType>();
if(typeDeclaration != null) {
- result.add(typeDeclaration);
- //TODO add all inherited types
+ IType type = typeDeclaration.getType();
+ if(type != null) {
+ ParametedType p = new ParametedType();
+ p.setType(type);
+ p.setSignature("Q" + type.getFullyQualifiedName() + ',');
+ result.add(p);
+ }
+ Set<IParametedType> inh = typeDeclaration.getInheritedTypes();
+ if(inh != null) result.addAll(inh);
}
return result;
}
@@ -167,5 +180,4 @@
}
return getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
}
-
-}
+}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-02-04
15:53:51 UTC (rev 20131)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2010-02-04
16:10:07 UTC (rev 20132)
@@ -11,7 +11,6 @@
package org.jboss.tools.cdi.internal.core.impl;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.eclipse.jdt.core.IAnnotation;
@@ -21,7 +20,6 @@
import org.jboss.tools.cdi.core.CDIConstants;
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.IInjectionPoint;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IProducerMethod;
@@ -30,10 +28,8 @@
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
-import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.MethodDefinition;
import org.jboss.tools.common.model.project.ext.impl.ValueInfo;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.text.ITextSourceReference;
/**
@@ -67,7 +63,7 @@
}
public IType getBeanClass() {
- return typeDeclaration != null ? typeDeclaration.getType() : null;
+ return getClassBean().getBeanClass();
}
public Set<IInjectionPoint> getInjectionPoints() {
@@ -82,9 +78,34 @@
result.addAll(ts);
return result;
}
+ return getAllTypes();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.cdi.core.IBean#getAllTypes()
+ */
+ public Set<IParametedType> getAllTypes() {
+ Set<IParametedType> result = new HashSet<IParametedType>();
if(typeDeclaration != null) {
- result.add(typeDeclaration);
- //TODO add all inherited types
+ IType type = typeDeclaration.getType();
+ if(type != null) {
+ ParametedType p = new ParametedType();
+ p.setType(type);
+// String[] ps = null;
+// try {
+// ps = type.getTypeParameterSignatures();
+ p.setSignature("Q" + type.getFullyQualifiedName() + ',');
+// } catch (CoreException e) {
+// CDICorePlugin.getDefault().logError(e);
+// }
+// if(ps == null || ps.length == 0) {
+// //type with parameters is not legal
+ result.add(p);
+// }
+ }
+ Set<IParametedType> inh = typeDeclaration.getInheritedTypes();
+ if(inh != null) result.addAll(inh);
}
return result;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-02-04
15:53:51 UTC (rev 20131)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-02-04
16:10:07 UTC (rev 20132)
@@ -35,6 +35,7 @@
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IQualifierDeclaration;
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.ITypeDeclaration;
@@ -247,14 +248,13 @@
// in the unrestricted set of bean types of a bean
Set<ITypeDeclaration> typedDeclarations = bean.getRestrictedTypeDeclaratios();
if(!typedDeclarations.isEmpty()) {
- Set<ITypeDeclaration> declarations = bean.getAllTypeDeclarations();
+ Set<IParametedType> allTypes = bean.getAllTypes();
for (ITypeDeclaration typedDeclaration : typedDeclarations) {
- IType type = typedDeclaration.getType();
- if(type!=null) {
+ IType typedType = typedDeclaration.getType();
+ if(typedType!=null) {
boolean typeWasFound = false;
- for (ITypeDeclaration declaration : declarations) {
- IType dType = declaration.getType();
- if(dType!=null &&
type.getFullyQualifiedName().equals(dType.getFullyQualifiedName())) {
+ for (IParametedType type : allTypes) {
+ if(type!=null &&
typedType.getFullyQualifiedName().equals(type.getType().getFullyQualifiedName())) {
typeWasFound = true;
break;
}