Author: scabanovich
Date: 2011-02-04 11:32:06 -0500 (Fri, 04 Feb 2011)
New Revision: 29010
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
Log:
JBIDE-8325
https://issues.jboss.org/browse/JBIDE-8325
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2011-02-04
16:22:10 UTC (rev 29009)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2011-02-04
16:32:06 UTC (rev 29010)
@@ -460,5 +460,11 @@
*/
List<INodeReference> getInterceptorClasses(String fullQualifiedTypeName);
- List<IInjectionPoint> getInjections(String fullyQualifiedTypeName);
+ /**
+ * Returns set of injection points with declared type exactly equal to
fullyQualifiedTypeName.
+ *
+ * @param fullyQualifiedTypeName
+ * @return
+ */
+ Set<IInjectionPoint> getInjections(String fullyQualifiedTypeName);
}
\ No newline at end of file
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 2011-02-04
16:22:10 UTC (rev 29009)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-02-04
16:32:06 UTC (rev 29010)
@@ -93,6 +93,8 @@
private Set<IDecorator> decorators = new HashSet<IDecorator>();
private Set<IInterceptor> interceptors = new HashSet<IInterceptor>();
+ private Map<String, Set<IInjectionPoint>> injectionPointsByType = new
HashMap<String, Set<IInjectionPoint>>();
+
BeansXMLData beansXMLData = new BeansXMLData();
public CDIProject() {}
@@ -1156,6 +1158,8 @@
for (IBean bean: beans) {
addBean(bean);
}
+
+ buildInjectionPoinsByType();
// System.out.println("Project=" + getNature().getProject());
// System.out.println("Qualifiers=" + qualifiers.size());
@@ -1213,6 +1217,26 @@
}
}
+ void buildInjectionPoinsByType() {
+ injectionPointsByType.clear();
+
+ for (IBean b: allBeans) {
+ Set<IInjectionPoint> ps = b.getInjectionPoints();
+ for (IInjectionPoint p: ps) {
+ IParametedType t = p.getType();
+ if(t == null || t.getType() == null) continue;
+ String n = t.getType().getFullyQualifiedName();
+ Set<IInjectionPoint> s = injectionPointsByType.get(n);
+ if(s == null) {
+ s = new HashSet<IInjectionPoint>();
+ injectionPointsByType.put(n, s);
+ }
+ s.add(p);
+ }
+ }
+
+ }
+
void rebuildXML() {
beansXMLData.clean();
Set<BeansXMLDefinition> beanXMLs = n.getDefinitions().getBeansXMLDefinitions();
@@ -1324,31 +1348,9 @@
return getBeans(attemptToResolveAmbiguousDependency, beanType, qualifiers.toArray(new
IType[0]));
}
- public List<IInjectionPoint> getInjections(String fullyQualifiedTypeName) {
- List<IInjectionPoint> result = new ArrayList<IInjectionPoint>();
-
- IType type = null;
- try {
- type = EclipseJavaUtil.findType(EclipseUtil.getJavaProject(getNature().getProject()),
fullyQualifiedTypeName);
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- if(type == null) {
- return result;
- }
- IParametedType pType = getNature().getTypeFactory().newParametedType(type);
- Set<IParametedType> types = ((ParametedType)pType).getAllTypes();
- IBean[] beans = getBeans();
- for (IBean b: beans) {
- Set<IInjectionPoint> ps = b.getInjectionPoints();
- for (IInjectionPoint p: ps) {
- IParametedType t = p.getType();
- if(containsType(types, t)) {
- result.add(p);
- }
- }
- }
-
+ public Set<IInjectionPoint> getInjections(String fullyQualifiedTypeName) {
+ Set<IInjectionPoint> result = injectionPointsByType.get(fullyQualifiedTypeName);
+ if(result == null) result = Collections.emptySet();
return result;
}