Author: scabanovich
Date: 2011-06-24 18:23:07 -0400 (Fri, 24 Jun 2011)
New Revision: 32359
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanValidator.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/messages.properties
Log:
JBIDE-8695
https://issues.jboss.org/browse/JBIDE-8695
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanValidator.java 2011-06-24
21:42:56 UTC (rev 32358)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanValidator.java 2011-06-24
22:23:07 UTC (rev 32359)
@@ -16,7 +16,11 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IAnnotatable;
import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.osgi.util.NLS;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDIUtil;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
@@ -35,7 +39,6 @@
import org.jboss.tools.cdi.seam.solder.core.CDISeamSolderPreferences;
import org.jboss.tools.cdi.seam.solder.core.validation.SeamSolderValidationMessages;
import org.jboss.tools.common.text.ITextSourceReference;
-import org.jboss.tools.common.util.EclipseJavaUtil;
/**
*
@@ -88,14 +91,22 @@
* than respective generic beans will result in ambiguous beans for injections
* with that set of qualifiers.
*/
+ StringBuffer duplicates = new StringBuffer();
List<IQualifierDeclaration> ds = bs.get(d);
for (AbstractMemberDefinition d1: bs.keySet()) {
List<IQualifierDeclaration> ds2 = bs.get(d1);
- if(ds2 != ds && !d1.getTypeDefinition().isVetoed() &&
CDIProject.areMatchingQualifiers(ds, ds2)) {
- validator.addError(SeamSolderValidationMessages.AMBIGUOUS_GENERIC_CONFIGURATION_POINT,
- CDISeamSolderPreferences.AMBIGUOUS_GENERIC_CONFIGURATION_POINT, new String[0],
reference, file);
+ if(ds2 != ds && !d1.getTypeDefinition().isVetoed()
+ && CDIProject.areMatchingQualifiers(ds, ds2)
+ && CDIProject.areMatchingQualifiers(ds2, ds)) {
+ duplicates.append(", ").append(definitionToString(d1));
}
}
+ if(duplicates.length() > 0) {
+ duplicates.insert(0, definitionToString(d));
+ String message =
NLS.bind(SeamSolderValidationMessages.AMBIGUOUS_GENERIC_CONFIGURATION_POINT,
duplicates.toString());
+ validator.addError(message,
+ CDISeamSolderPreferences.AMBIGUOUS_GENERIC_CONFIGURATION_POINT, new String[0],
reference, file);
+ }
/*
* Type of generic configuration point must be assignable to the configuration type.
@@ -112,6 +123,21 @@
}
+ private String definitionToString(AbstractMemberDefinition d) {
+ IAnnotatable e = d.getMember();
+ String result = "";
+ if(e instanceof IType) {
+ result = ((IType)e).getElementName();
+ } else if(e instanceof IMember) {
+ IMember m = (IMember)e;
+ result = m.getDeclaringType().getElementName() + "." + m.getElementName();
+ if(e instanceof IMethod) {
+ result += "()";
+ }
+ }
+ return result;
+ }
+
private IBean findGenericBean(IFile file, IMember member, CDICoreNature project) {
Set<IBean> bs = project.getDelegate().getBeans(file.getFullPath());
for (IBean b: bs) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/messages.properties 2011-06-24
21:42:56 UTC (rev 32358)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/validation/messages.properties 2011-06-24
22:23:07 UTC (rev 32359)
@@ -1,4 +1,4 @@
-AMBIGUOUS_GENERIC_CONFIGURATION_POINT=Duplicate generic configuration point.
+AMBIGUOUS_GENERIC_CONFIGURATION_POINT=Duplicate generic configuration point: {0}.
WRONG_TYPE_OF_GENERIC_CONFIGURATION_POINT=Type of generic configuration point must be
assignable to the generic configuration type.
WRONG_GENERIC_CONFIGURATION_ANNOTATION_REFERENCE=Annotation type mismatch: {0} is not a
generic configuration annotation.
GENERIC_CONFIGURATION_TYPE_IS_A_GENERIC_BEAN=Generic configuration types may not be
generic beans.