diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java index d33d356ae7b..7cdf2374137 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. + * Copyright (c) 2002, 2011 IBM Corporation 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 @@ -69,6 +69,7 @@ public class CModelElementsTests extends TestCase { super(name); } + @Override protected void setUp() throws Exception { monitor = new NullProgressMonitor(); fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER); @@ -93,6 +94,7 @@ public class CModelElementsTests extends TestCase { } + @Override protected void tearDown() { CProjectHelper.delete(fCProject); } @@ -133,6 +135,7 @@ public class CModelElementsTests extends TestCase { checkArrays(tu); checkBug180815(tu); + checkBug352350(tu); } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815 @@ -144,6 +147,18 @@ public class CModelElementsTests extends TestCase { assertEquals(2, struct.getChildren().length); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350 + private void checkBug352350(IParent parent) throws CModelException { + List namespaces = parent.getChildrenOfType(ICElement.C_NAMESPACE); + assertEquals(2, namespaces.size()); + for (Object o : namespaces) { + INamespace namespace = (INamespace)o; + if (namespace.getElementName().length() == 0) { + assertTrue(namespace.equals(namespace)); + } + } + } + private void checkInclude(IParent tu) throws CModelException{ List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE); IInclude inc1 = (IInclude) tuIncludes.get(0); diff --git a/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h b/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h index 45bfd1fb15e..df422c6e855 100644 --- a/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h +++ b/core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h @@ -139,3 +139,8 @@ namespace MyPackage struct bug180815 { int i,j; } bug180815_var0, bug180815_var1; + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350 +namespace { + int bug352350; +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java index 349b9cc4909..2624bc16bfc 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2011 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 @@ -40,11 +40,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.PlatformObject; -/** - * TLETODO Document CElement. - * - * @since 5.0 - */ public abstract class CElement extends PlatformObject implements ICElement { public static final char CEM_ESCAPE = '\\'; @@ -270,12 +265,15 @@ public abstract class CElement extends PlatformObject implements ICElement { } public static boolean equals(ICElement lhs, ICElement rhs) { + if (lhs == rhs) { + return true; + } if (lhs.getElementType() != rhs.getElementType()) { return false; } String lhsName= lhs.getElementName(); String rhsName= rhs.getElementName(); - if( lhsName == null || rhsName == null || lhsName.length() == 0 || + if( lhsName == null || rhsName == null || lhsName.length() != rhsName.length() || !lhsName.equals(rhsName)) { return false; }