### Eclipse Workspace Patch 1.0
#P org.jboss.tools.cdi.core
Index: src/org/jboss/tools/cdi/internal/core/validation/CDIProjectTree.java
===================================================================
--- src/org/jboss/tools/cdi/internal/core/validation/CDIProjectTree.java	(revision 34444)
+++ src/org/jboss/tools/cdi/internal/core/validation/CDIProjectTree.java	(working copy)
@@ -104,14 +104,14 @@
 
 	private Set<CDICoreNature> getRootProjects(CDICoreNature project) {
 		Set<CDICoreNature> result = new HashSet<CDICoreNature>();
-		Set<CDICoreNature> dependentProjects = project.getDependentProjects();
-		if(dependentProjects.isEmpty()) {
+		CDICoreNature[] dependentProjects = project.getAllDependentProjects();
+		if(dependentProjects.length == 0) {
 			result.add(project);
 		} else {
 			for (CDICoreNature nature : dependentProjects) {
 				if(!nature.getProject().isAccessible()) continue;
-				if(!result.contains(nature)) {
-					result.addAll(getRootProjects(nature));
+				if(nature.getDependentProjects().isEmpty()) {
+					result.add(nature);
 				}
 			}
 		}
Index: src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java	(revision 34444)
+++ src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java	(working copy)
@@ -973,7 +973,7 @@
 		return scopesByPath.get(path);
 	}
 
-	public void update() {
+	public void update(boolean updateDependent) {
 		rebuildXML();
 		rebuildAnnotationTypes();
 		rebuildBeans();
@@ -988,13 +988,15 @@
 				bp.buildBeans(this);
 			}
 		}
-		
-		CDICoreNature[] ps = n.getDependentProjects().toArray(new CDICoreNature[0]);
-		for (CDICoreNature p: ps) {
-			if(p.getProject() != null && p.getProject().isAccessible() && p.getDelegate() != null) {
-				p.getDelegate().update();
+
+		if(updateDependent) {
+			CDICoreNature[] ps = n.getAllDependentProjects();
+			for (CDICoreNature p: ps) {
+				if(p.getProject() != null && p.getProject().isAccessible() && p.getDelegate() != null) {
+					p.getDelegate().update(false);
+				}
 			}
-		}	
+		}
 		CDICorePlugin.fire(new CDIProjectChangeEvent(this));
 	}
 
Index: src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
===================================================================
--- src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java	(revision 34444)
+++ src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java	(working copy)
@@ -380,7 +380,7 @@
 		//extensions may add to dependencies while they change
 		dependencies = workingCopy.dependencies;
 
-		project.getDelegate().update();
+		project.getDelegate().update(true);
 
 		workingCopy = null;
 	}
@@ -414,9 +414,15 @@
 				|| (result.getType().getResource() != null && result.getType().getResource().getProject() != project.getProject())
 				) {
 			//3. Look in annotations loaded by used projects
-			Set<CDICoreNature> ns = project.getCDIProjects(true);
+			Set<CDICoreNature> ns = project.getCDIProjects(false);
+			Set<CDICoreNature> ns2 = project.getCDIProjects(true);
+			boolean cyclic = ns2.contains(project);
+			if(cyclic) {
+				ns = ns2;
+			}
 			for (CDICoreNature n: ns) {
-				AnnotationDefinition r = n.getDefinitions().getAnnotation(fullyQualifiedName);
+				DefinitionContext d = n.getDefinitions();
+				AnnotationDefinition r = (!cyclic) ? d.getAnnotation(fullyQualifiedName) : d.annotations.get(fullyQualifiedName);
 				if(r != null) {
 					result = r;
 					//4. Store result for the case if used project is cleaned.
Index: src/org/jboss/tools/cdi/core/CDICoreNature.java
===================================================================
--- src/org/jboss/tools/cdi/core/CDICoreNature.java	(revision 34444)
+++ src/org/jboss/tools/cdi/core/CDICoreNature.java	(working copy)
@@ -13,9 +13,12 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.eclipse.core.resources.ICommand;
@@ -178,7 +181,7 @@
 
 	public List<AnnotationDefinition> getAllAnnotations() {
 		Set<CDICoreNature> ps = getCDIProjects(false);
-		if(ps == null || ps.isEmpty()) {
+		if(ps == null || ps.isEmpty() || getCDIProjects(true).contains(this)) {
 			return getDefinitions().getAllAnnotations();
 		}
 		List<AnnotationDefinition> result = new ArrayList<AnnotationDefinition>();
@@ -236,6 +239,35 @@
 		return usedBy;
 	}
 
+	public CDICoreNature[] getAllDependentProjects() {
+		Map<CDICoreNature, Integer> set = new HashMap<CDICoreNature, Integer>();
+		getAllDependentProjects(set, 0);
+		CDICoreNature[] result = set.keySet().toArray(new CDICoreNature[set.size()]);
+		Arrays.sort(result, new D(set));
+		return result;
+	}
+	private void getAllDependentProjects(Map<CDICoreNature, Integer> result, int level) {
+		if(level > 10) return;
+		for (CDICoreNature n:usedBy) {
+			if(!result.containsKey(n) || result.get(n).intValue() < level) {
+				result.put(n, level);
+				n.getAllDependentProjects(result, level + 1);
+			}
+		}
+	}
+	private static class D implements Comparator<CDICoreNature> {
+		Map<CDICoreNature, Integer> set;
+		D(Map<CDICoreNature, Integer> set) {
+			this.set = set;
+		}
+		@Override
+		public int compare(CDICoreNature o1, CDICoreNature o2) {
+			return set.get(o1).intValue() - set.get(o2).intValue();
+		}
+		
+	}
+
+
 	public void addCDIProject(final CDICoreNature p) {
 		if(dependsOn.contains(p)) return;
 		addUsedCDIProject(p);
@@ -246,7 +278,7 @@
 				public void run() {
 					p.resolve();
 					if(p.getDelegate() != null) {
-						p.getDelegate().update();
+						p.getDelegate().update(true);
 					}
 				}
 				
@@ -361,7 +393,7 @@
 
 		definitions.clean();
 		if(cdiProjectDelegate != null) {
-			cdiProjectDelegate.update();
+			cdiProjectDelegate.update(true);
 		}
 //		IPath[] ps = sourcePaths2.keySet().toArray(new IPath[0]);
 //		for (int i = 0; i < ps.length; i++) {
Index: src/org/jboss/tools/cdi/core/ICDIProject.java
===================================================================
--- src/org/jboss/tools/cdi/core/ICDIProject.java	(revision 34444)
+++ src/org/jboss/tools/cdi/core/ICDIProject.java	(working copy)
@@ -17,5 +17,5 @@
 
 	public CDICoreNature getNature();
 	public void setNature(CDICoreNature n);
-	public void update();
+	public void update(boolean updateDependent);
 }
\ No newline at end of file
#P org.jboss.tools.cdi.ui.test
Index: src/org/jboss/tools/cdi/ui/test/testmodel/CDIProject.java
===================================================================
--- src/org/jboss/tools/cdi/ui/test/testmodel/CDIProject.java	(revision 34444)
+++ src/org/jboss/tools/cdi/ui/test/testmodel/CDIProject.java	(working copy)
@@ -297,7 +297,7 @@
 	}
 
 	@Override
-	public void update() {
+	public void update(boolean updateDependent) {
 	}
 
-}
+}
\ No newline at end of file
