From 744939255535278eb9693a2d7564366f6af8d630 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 12 Jun 2007 15:49:41 +0000 Subject: [PATCH] Fix for 192227, ClassCastException in PDOMCPPNamespaceAlias. --- .../pdom/dom/cpp/PDOMCPPNamespaceAlias.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java index 47093110eff..e656a6de6e3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 QNX Software Systems and others. + * Copyright (c) 2006, 2007 QNX Software Systems 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 @@ -7,6 +7,7 @@ * * Contributors: * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -53,7 +54,22 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements } public ICPPNamespaceScope getNamespaceScope() throws DOMException { - return (ICPPNamespaceScope) getBinding(); + return getNamespaceScope(this, 20); // avoid an infinite loop. + } + + private ICPPNamespaceScope getNamespaceScope(PDOMCPPNamespaceAlias alias, final int maxDepth) { + IBinding binding= alias.getBinding(); + if (binding instanceof ICPPNamespaceScope) { + return (ICPPNamespaceScope) binding; + } + + if (maxDepth <= 0) { + return null; + } + if (binding instanceof PDOMCPPNamespaceAlias) { + return getNamespaceScope((PDOMCPPNamespaceAlias) binding, maxDepth-1); + } + return null; } public IBinding[] getMemberBindings() throws DOMException {