Author: dazarov
Date: 2011-10-12 13:11:57 -0400 (Wed, 12 Oct 2011)
New Revision: 35579
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/util/BeanPresentationUtil.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java
Log:
Updated CDI Query Participants in order to search in related projects and check search
scope
https://issues.jboss.org/browse/JBIDE-9801
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/util/BeanPresentationUtil.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/util/BeanPresentationUtil.java 2011-10-12
16:58:31 UTC (rev 35578)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/util/BeanPresentationUtil.java 2011-10-12
17:11:57 UTC (rev 35579)
@@ -13,15 +13,20 @@
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.IBean;
-import org.jboss.tools.cdi.core.IBeanField;
import org.jboss.tools.cdi.core.IBeanMember;
-import org.jboss.tools.cdi.core.IBeanMethod;
import org.jboss.tools.cdi.core.ICDIElement;
-import org.jboss.tools.cdi.core.IInitializerMethod;
import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
import org.jboss.tools.cdi.core.IParameter;
import org.jboss.tools.cdi.core.IProducer;
import org.jboss.tools.cdi.internal.core.impl.AbstractBeanElement;
+import org.jboss.tools.cdi.internal.core.impl.DisposerMethod;
+import org.jboss.tools.cdi.internal.core.impl.EventBean;
+import org.jboss.tools.cdi.internal.core.impl.InitializerMethod;
+import org.jboss.tools.cdi.internal.core.impl.ObserverMethod;
+import org.jboss.tools.cdi.internal.core.impl.ProducerField;
+import org.jboss.tools.cdi.internal.core.impl.ProducerMethod;
import org.jboss.tools.common.text.ITextSourceReference;
/**
@@ -53,14 +58,22 @@
if(bean instanceof IProducer) {
return "@Produces";
}
+ if(bean instanceof EventBean) {
+ return "Event";
+ }
return null;
}
public static String getBeanLocation(IBean bean, boolean includeElementName) {
StringBuilder sb = new StringBuilder();
sb.append(SEPARATOR);
- AbstractBeanElement e = (AbstractBeanElement)bean;
- ITextSourceReference origin = e.getDefinition().getOriginalDefinition();
+
+ ITextSourceReference origin = null;
+ if(bean instanceof AbstractBeanElement){
+ AbstractBeanElement e = (AbstractBeanElement)bean;
+ origin = e.getDefinition().getOriginalDefinition();
+ }
+
if(origin != null) {
//If toString() is not enough, another interface should be introduced.
sb.append(origin.toString());
@@ -86,14 +99,20 @@
public static String getCDIElementKind(ICDIElement element){
if(element instanceof IBean){
return getBeanKind((IBean)element);
- }else if(element instanceof IInjectionPoint){
- return "Injection Point";
- }else if(element instanceof IInitializerMethod){
- return "Injection Point";
- }else if(element instanceof IBeanMethod){
- return "Bean Method";
- }else if(element instanceof IBeanField){
- return "Bean Field";
+ }else if(element instanceof IInjectionPointField){
+ return "Injection Point Field";
+ }else if(element instanceof IInjectionPointParameter){
+ return "Injection Point Parameter";
+ }else if(element instanceof DisposerMethod){
+ return "Disposer Method";
+ }else if(element instanceof InitializerMethod){
+ return "Initializer Method";
+ }else if(element instanceof ObserverMethod){
+ return "Observer Method";
+ }else if(element instanceof ProducerMethod){
+ return "Producer Method";
+ }else if(element instanceof ProducerField){
+ return "Producer Field";
}else if(element instanceof IParameter){
return "Parameter";
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java 2011-10-12
16:58:31 UTC (rev 35578)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/search/InjectionPointQueryParticipant.java 2011-10-12
17:11:57 UTC (rev 35579)
@@ -15,7 +15,6 @@
import java.util.Set;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -110,38 +109,62 @@
}
}
}
- Set<IObserverMethod> observerMethods =
cdiProject.resolveObserverMethods(injectionPoint);
- for(IObserverMethod observerMethod : observerMethods){
- if(containsInSearchScope(querySpecification, observerMethod)){
- // match observer method
- CDIMatch match = new CDIMatch(observerMethod);
- if(!objects.contains(match.getPath())){
- requestor.reportMatch(match);
- objects.add(match.getPath());
- }
- }
+ Set<CDICoreNature> natures = cdiProject.getNature().getCDIProjects(true);
+ for(CDICoreNature nature : natures){
+ resolveObserverMethods(nature.getDelegate(), injectionPoint, requestor,
querySpecification);
}
+ CDICoreNature[] naturesArray = cdiProject.getNature().getAllDependentProjects();
+ for(CDICoreNature nature : naturesArray){
+ resolveObserverMethods(nature.getDelegate(), injectionPoint, requestor,
querySpecification);
+ }
}
if(element instanceof IMethod){
IParameter param = findObserverParameter(beans, (IMethod)element);
if(param != null){
- Set<IInjectionPoint> events = cdiProject.findObservedEvents(param);
- for(IInjectionPoint event : events){
- if(containsInSearchScope(querySpecification, event)){
- // match event
- CDIMatch match = new CDIMatch(event);
- if(!objects.contains(match.getPath())){
- requestor.reportMatch(match);
- objects.add(match.getPath());
- }
- }
+ Set<CDICoreNature> natures = cdiProject.getNature().getCDIProjects(true);
+ for(CDICoreNature nature : natures){
+ findObservedEvents(nature.getDelegate(), param, requestor, querySpecification);
}
+ CDICoreNature[] naturesArray = cdiProject.getNature().getAllDependentProjects();
+ for(CDICoreNature nature : naturesArray){
+ findObservedEvents(nature.getDelegate(), param, requestor, querySpecification);
+ }
}
}
}
}
}
+ private void resolveObserverMethods(ICDIProject cdiProject, IInjectionPoint
injectionPoint, ISearchRequestor requestor,
+ QuerySpecification querySpecification){
+ Set<IObserverMethod> observerMethods =
cdiProject.resolveObserverMethods(injectionPoint);
+ for(IObserverMethod observerMethod : observerMethods){
+ if(containsInSearchScope(querySpecification, observerMethod)){
+ // match observer method
+ CDIMatch match = new CDIMatch(observerMethod);
+ if(!objects.contains(match.getPath())){
+ requestor.reportMatch(match);
+ objects.add(match.getPath());
+ }
+ }
+ }
+ }
+
+ private void findObservedEvents(ICDIProject cdiProject, IParameter param,
ISearchRequestor requestor,
+ QuerySpecification querySpecification){
+ Set<IInjectionPoint> events = cdiProject.findObservedEvents(param);
+ for(IInjectionPoint event : events){
+ if(containsInSearchScope(querySpecification, event)){
+ // match event
+ CDIMatch match = new CDIMatch(event);
+ if(!objects.contains(match.getPath())){
+ requestor.reportMatch(match);
+ objects.add(match.getPath());
+ }
+ }
+ }
+ }
+
private IParameter findObserverParameter(Set<IBean> beans, IMethod method) throws
JavaModelException {
for (IBean bean: beans) {
if(bean instanceof IClassBean) {