ASSIGNED - bug 328300: [CDT][context] Mylyn automatically add all Includes in the context of the task
https://bugs.eclipse.org/bugs/show_bug.cgi?id=328300
diff --git a/org.eclipse.mylyn.cdt.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTStructureBridge.java b/org.eclipse.mylyn.cdt.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTStructureBridge.java
index 2519714..f46c6c1 100644
--- a/org.eclipse.mylyn.cdt.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTStructureBridge.java
+++ b/org.eclipse.mylyn.cdt.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTStructureBridge.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2010 Mylyn project committers and others.
+ * Copyright (c) 2004, 2011 Mylyn project committers and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@
 import org.eclipse.cdt.core.model.CoreModel;
 import org.eclipse.cdt.core.model.IBinary;
 import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.core.model.IFunction;
 import org.eclipse.cdt.core.model.IInclude;
 import org.eclipse.cdt.core.model.IMethod;
@@ -125,7 +126,18 @@
 	// The element name (optional) allows us to find an element within the
 	// TranslationUnit.
 	public static String getHandleForElement(ICElement element) {
-		return element.getHandleIdentifier();
+		String handle = element.getHandleIdentifier();
+		if (handle != null && !(element instanceof ICProject)) {
+			ICProject cProject = element.getCProject();
+			if (cProject != null) {
+				String projectHandle = getHandleForElement(cProject);
+				if (handle.equals(projectHandle)) {
+					// see bug 328300
+					return null;
+				}
+			}
+		}
+		return handle;
 	}
 
 	/**
@@ -204,7 +216,7 @@
 					for (Object adaptable : elements) {
 						IInteractionElement element = ContextCore.getContextManager().getElement(
 								getHandleIdentifier(adaptable));
-						if (element.getInterest().isInteresting()) {
+						if (element != null && element.getInterest().isInteresting()) {
 							return false;
 						}
 					}
diff --git a/org.eclipse.mylyn.cdt.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/DOMCompletionProposalComputer.java b/org.eclipse.mylyn.cdt.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/DOMCompletionProposalComputer.java
index 32ad856..2519104 100644
--- a/org.eclipse.mylyn.cdt.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/DOMCompletionProposalComputer.java
+++ b/org.eclipse.mylyn.cdt.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/DOMCompletionProposalComputer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2010 Tasktop Technologies and others.
+ * Copyright (c) 2004, 2011 Tasktop Technologies and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -338,7 +338,7 @@
 				for (ICPPConstructor constructor : constructors) {
 					handleFunction(constructor, context, baseRelevance, proposals);
 				}
-			} catch (DOMException e) {
+			} catch (Throwable e) {
 			}
 		} else {
 			int relevance = 0;
@@ -354,7 +354,7 @@
 					relevance = RelevanceConstants.UNION_TYPE_RELEVANCE;
 					break;
 				}
-			} catch (DOMException exc) {
+			} catch (Throwable exc) {
 			}
 			if (astContext instanceof IASTName && !(astContext instanceof ICPPASTQualifiedName)) {
 				IASTName name = (IASTName) astContext;
@@ -417,7 +417,7 @@
 					returnTypeStr = ASTTypeUtil.getType(returnType, false);
 				}
 			}
-		} catch (DOMException e) {
+		} catch (Throwable e) {
 		}
 
 		String dispargString = dispargs.toString();
@@ -468,7 +468,7 @@
 			if (varType != null) {
 				returnTypeStr = ASTTypeUtil.getType(varType, false);
 			}
-		} catch (DOMException e) {
+		} catch (Throwable e) {
 		}
 
 		StringBuilder dispStringBuff = new StringBuilder(repStringBuff.toString());
@@ -704,7 +704,7 @@
 					return getImage(delegates[0]);
 				}
 			}
-		} catch (DOMException e) {
+		} catch (Throwable e) {
 		}
 
 		return imageDescriptor != null ? CommonImages.getImage(imageDescriptor) : null;