Author: scabanovich
Date: 2011-10-28 16:44:46 -0400 (Fri, 28 Oct 2011)
New Revision: 36078
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderDefaultBeanExtension.java
Log:
JBIDE-9244
https://issues.jboss.org/browse/JBIDE-9244
Provided saving to validation context all default beans.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderDefaultBeanExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderDefaultBeanExtension.java 2011-10-28
20:43:03 UTC (rev 36077)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderDefaultBeanExtension.java 2011-10-28
20:44:46 UTC (rev 36078)
@@ -10,8 +10,10 @@
******************************************************************************/
package org.jboss.tools.cdi.seam.solder.core;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@@ -33,6 +35,7 @@
import org.jboss.tools.cdi.core.extension.ICDIExtension;
import org.jboss.tools.cdi.core.extension.feature.IAmbiguousBeanResolverFeature;
import org.jboss.tools.cdi.core.extension.feature.IBeanKeyProvider;
+import org.jboss.tools.cdi.core.extension.feature.IBeanStoreFeature;
import org.jboss.tools.cdi.core.extension.feature.IProcessAnnotatedTypeFeature;
import org.jboss.tools.cdi.core.extension.feature.IValidatorFeature;
import org.jboss.tools.cdi.internal.core.impl.BeanMember;
@@ -64,7 +67,9 @@
* @author Viacheslav Kabanovich
*
*/
-public class CDISeamSolderDefaultBeanExtension implements ICDIExtension,
IProcessAnnotatedTypeFeature, IAmbiguousBeanResolverFeature, IValidatorFeature,
IBeanKeyProvider {
+public class CDISeamSolderDefaultBeanExtension implements ICDIExtension,
IProcessAnnotatedTypeFeature, IAmbiguousBeanResolverFeature, IValidatorFeature,
IBeanKeyProvider, IBeanStoreFeature {
+
+ protected Map<String, Set<IBean>> defaultBeansByKey = new HashMap<String,
Set<IBean>>();
protected Version getVersion() {
return Version.instance;
@@ -182,7 +187,16 @@
IQualifierDeclaration[] qs = bean.getQualifierDeclarations().toArray(new
IQualifierDeclaration[0]);
IParametedType type = getDefaultType(bean);
if(type != null) {
- validator.getValidationContext().addLinkedCoreResource(CDICoreValidator.SHORT_ID,
createKey(type, bean.getQualifierDeclarations(true)), file.getFullPath(), true);
+ String key = createKey(type, bean.getQualifierDeclarations(true));
+ Set<IBean> linked = defaultBeansByKey.get(key);
+ if(linked != null) {
+ for (IBean link: linked) {
+ if(link.getSourcePath() != null) {
+ validator.getValidationContext().addLinkedCoreResource(CDICoreValidator.SHORT_ID,
key, link.getSourcePath(), true);
+ System.out.println(key + ":" + link.getSourcePath());
+ }
+ }
+ }
Set<IBean> bs2 = cdiProject.getBeans(false, type, qs);
StringBuilder otherDefaultBeans = new StringBuilder();
for (IBean b: bs2) {
@@ -225,8 +239,7 @@
@Override
public String getKey(IBean bean) {
- IAnnotationDeclaration a =
bean.getAnnotation(getVersion().getDefaultBeanAnnotationTypeName());
- if(a != null) {
+ if(isBeanDefault(bean)) {
IParametedType type = getDefaultType(bean);
if(type != null) {
return createKey(type, bean.getQualifierDeclarations(true));
@@ -251,4 +264,22 @@
return sb.toString();
}
+ public synchronized void updateCaches(ICDIProject project) {
+ Map<String, Set<IBean>> map = new HashMap<String,
Set<IBean>>();
+
+ IBean[] beans = project.getBeans();
+ for (IBean b: beans) {
+ String key = getKey(b);
+ if(key != null) {
+ Set<IBean> bs = map.get(key);
+ if(bs == null) {
+ bs = new HashSet<IBean>();
+ map.put(key, bs);
+ }
+ bs.add(b);
+ }
+ }
+ defaultBeansByKey = map;
+ }
+
}