summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Elmenthaler2011-07-20 04:41:59 (EDT)
committer Anton Leherbauer2011-07-20 05:03:33 (EDT)
commit9d9efe8e9d73583167fd33ac7b696403bbccfebc (patch)
tree97428c38c47eef1ca7931af93cad2b1bff7336ce
parent163a57b8b7ea789cbec84e578c9992243579767a (diff)
downloadorg.eclipse.cdt-9d9efe8e9d73583167fd33ac7b696403bbccfebc.zip
org.eclipse.cdt-9d9efe8e9d73583167fd33ac7b696403bbccfebc.tar.gz
org.eclipse.cdt-9d9efe8e9d73583167fd33ac7b696403bbccfebc.tar.bz2
Bug 352350 - Outline view corrupts expansion state of namespace nodes
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java17
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cfiles/CModelElementsTestStart.h5
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java12
3 files changed, 26 insertions, 8 deletions
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 d33d356..7cdf237 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 45bfd1f..df422c6 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 349b9cc..2624bc1 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;
}