[jbosstools-commits] JBoss Tools SVN: r42161 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core: validation and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Jun 21 20:28:45 EDT 2012


Author: scabanovich
Date: 2012-06-21 20:28:45 -0400 (Thu, 21 Jun 2012)
New Revision: 42161

Modified:
   trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
   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/validation/CDICoreValidator.java
Log:
JBIDE-10611
https://issues.jboss.org/browse/JBIDE-10611
Named beans in as-you-type cdi model.




Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java	2012-06-22 00:18:29 UTC (rev 42160)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java	2012-06-22 00:28:45 UTC (rev 42161)
@@ -31,6 +31,7 @@
 	protected void copyTo(AnnotationDeclaration other) {
 		other.project = project;
 		other.annotation = annotation;
+		other.values = values;
 	}
 
 	public void setProject(CDICoreNature project) {

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	2012-06-22 00:18:29 UTC (rev 42160)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java	2012-06-22 00:28:45 UTC (rev 42161)
@@ -128,9 +128,58 @@
 		synchronized(this) {
 			p.allBeans.addAll(allBeans);
 		}
-		p.allBeans.removeAll(getBeans(file.getFullPath()));
+		Set<IBean> oldBeans = getBeans(file.getFullPath());
+		p.allBeans.removeAll(oldBeans);
 		p.allBeans.addAll(beans);
 		
+		Set<IBean> oldNamedBeans = null;
+		for (IBean b: oldBeans) {
+			if(b.getName() != null) {
+				if(oldNamedBeans == null) oldNamedBeans = new HashSet<IBean>();
+				oldNamedBeans.add(b);
+			}
+		}
+		Set<IBean> newNamedBeans = null;
+		for (IBean b: beans) {
+			if(b.getName() != null) {
+				if(newNamedBeans == null) newNamedBeans = new HashSet<IBean>();
+				newNamedBeans.add(b);
+			}
+		}
+		if(newNamedBeans != null || oldNamedBeans != null) {
+			p.namedBeans = new HashSet<IBean>();
+			p.beansByName = new HashMap<String, Set<IBean>>();
+			synchronized(this) {
+				p.namedBeans.addAll(namedBeans);
+				if(oldNamedBeans != null) p.namedBeans.removeAll(oldNamedBeans);
+				if(newNamedBeans != null) p.namedBeans.addAll(newNamedBeans);
+				for (String n: beansByName.keySet()) {
+					Set<IBean> bs = new HashSet<IBean>(beansByName.get(n));
+					p.beansByName.put(n, bs);
+				}
+				if(oldNamedBeans != null) {
+					for (IBean b: oldNamedBeans) {
+						String n = b.getName();
+						Set<IBean> bs = p.beansByName.get(n);
+						if(bs != null && bs.contains(b)) {
+							bs.remove(b);
+						}
+					}
+				}
+				if(newNamedBeans != null) {
+					for (IBean b: newNamedBeans) {
+						String n = b.getName();
+						Set<IBean> bs = p.beansByName.get(n);
+						if(bs == null) {
+							bs = new HashSet<IBean>();
+							p.beansByName.put(n, bs);
+						}
+						bs.add(b);
+					}
+				}
+			}
+		}
+		
 		return p;
 	}
 

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-06-22 00:18:29 UTC (rev 42160)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java	2012-06-22 00:28:45 UTC (rev 42161)
@@ -726,6 +726,7 @@
 			 *     • the two beans have the same EL name and the name is not resolvable, or
 			 */
 			Set<IBean> beans = context.getCdiProject().getBeans(name, true);
+			System.out.println("-->" + (beans.size()>1 && beans.contains(bean)));
 			if(beans.size()>1 && beans.contains(bean)) {
 				ITextSourceReference reference = bean.getNameLocation(true);
 				Set<String> names = new HashSet<String>();
@@ -2623,4 +2624,9 @@
 	protected String getMessageBundleName() {
 		return BUNDLE_NAME;
 	}
+
+	protected boolean alwaysCleanAnnotations() {
+		return true;
+	}
+
 }
\ No newline at end of file



More information about the jbosstools-commits mailing list