[jbosstools-commits] JBoss Tools SVN: r43310 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Aug 29 19:59:09 EDT 2012


Author: scabanovich
Date: 2012-08-29 19:59:09 -0400 (Wed, 29 Aug 2012)
New Revision: 43310

Modified:
   trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
Log:
JBIDE-12511
https://issues.jboss.org/browse/JBIDE-12511
Lists of names inserted to error messages are filled in the alphabetical order.


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	2012-08-29 23:39:25 UTC (rev 43309)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java	2012-08-29 23:59:09 UTC (rev 43310)
@@ -22,6 +22,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
+import java.util.TreeSet;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
@@ -954,15 +955,19 @@
 			for (IParametedType type : bean.getLegalTypes()) {
 				if(type.getType() != null) legalTypes.add(type.getType().getFullyQualifiedName());
 			}
-			StringBuffer missingTypes = new StringBuffer();
+			Set<String> missingTypesSet = new TreeSet<String>();
 			for (IParametedType specializingType : specializedBean.getLegalTypes()) {
 				if(!legalTypes.contains(specializingType.getType().getFullyQualifiedName())) {
-					if(missingTypes.length()>0) {
-						missingTypes.append(", ");
-					}
-					missingTypes.append(specializingType.getType().getElementName());
+					missingTypesSet.add(specializingType.getType().getElementName());
 				}
 			}
+			StringBuffer missingTypes = new StringBuffer();
+			for (String type: missingTypesSet) {
+				if(missingTypes.length() > 0) {
+					missingTypes.append(", ");
+				}
+				missingTypes.append(type);
+			}
 			if(missingTypes.length()>0) {
 				addProblem(CDIValidationMessages.MISSING_TYPE_IN_SPECIALIZING_BEAN, CDIPreferences.MISSING_TYPE_IN_SPECIALIZING_BEAN,
 						new String[]{beanName, specializingBeanName, missingTypes.toString()},
@@ -990,19 +995,21 @@
 				IClassBean supperClassBean = (IClassBean)specializedBean;
 				Collection<? extends IClassBean> allSpecializingBeans = supperClassBean.getSpecializingBeans();
 				if(allSpecializingBeans.size()>1) {
-					StringBuffer sb = new StringBuffer(bean.getElementName());
-					boolean moreThanTwo = false;
+					Set<String> specializingBeanNames = new TreeSet<String>();
 					for (IClassBean specializingBean : allSpecializingBeans) {
-						if(specializingBean!=bean && specializingBean.isEnabled()) {
-							sb.append(", ").append(specializingBean.getElementName());
-							moreThanTwo = true;
+						if(specializingBean != bean && specializingBean.isEnabled()) {
+							specializingBeanNames.add(specializingBean.getElementName());
 							if(!isAsYouTypeValidation() && shouldValidateType(specializingBean.getBeanClass())) {
 								getValidationContext().addLinkedCoreResource(SHORT_ID, specializingBean.getResource().getFullPath().toOSString(), bean.getSourcePath(), false);
 								getValidationContext().addLinkedCoreResource(SHORT_ID, bean.getSourcePath().toOSString(), specializingBean.getResource().getFullPath(), false);
 							}
 						}
 					}
-					if(moreThanTwo && specializesDeclaration!=null) {
+					if(!specializingBeanNames.isEmpty() && specializesDeclaration!=null) {
+						StringBuffer sb = new StringBuffer(bean.getElementName());
+						for (String name: specializingBeanNames) {
+							sb.append(", ").append(name);
+						}
 						addProblem(CDIValidationMessages.INCONSISTENT_SPECIALIZATION, CDIPreferences.INCONSISTENT_SPECIALIZATION,
 								new String[]{sb.toString(), supperClassBean.getElementName()},
 								specializesDeclaration, bean.getResource());



More information about the jbosstools-commits mailing list