1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 352350 - Outline view corrupts expansion state of namespace nodes

This commit is contained in:
Jens Elmenthaler 2011-07-20 10:41:59 +02:00 committed by Anton Leherbauer
parent 163a57b8b7
commit 9d9efe8e9d
3 changed files with 26 additions and 8 deletions

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -69,6 +69,7 @@ public class CModelElementsTests extends TestCase {
super(name); super(name);
} }
@Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER); fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER);
@ -93,6 +94,7 @@ public class CModelElementsTests extends TestCase {
} }
@Override
protected void tearDown() { protected void tearDown() {
CProjectHelper.delete(fCProject); CProjectHelper.delete(fCProject);
} }
@ -133,6 +135,7 @@ public class CModelElementsTests extends TestCase {
checkArrays(tu); checkArrays(tu);
checkBug180815(tu); checkBug180815(tu);
checkBug352350(tu);
} }
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815
@ -144,6 +147,18 @@ public class CModelElementsTests extends TestCase {
assertEquals(2, struct.getChildren().length); 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{ private void checkInclude(IParent tu) throws CModelException{
List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE); List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
IInclude inc1 = (IInclude) tuIncludes.get(0); IInclude inc1 = (IInclude) tuIncludes.get(0);

View file

@ -139,3 +139,8 @@ namespace MyPackage
struct bug180815 { struct bug180815 {
int i,j; int i,j;
} bug180815_var0, bug180815_var1; } bug180815_var0, bug180815_var1;
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350
namespace {
int bug352350;
}

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.Path;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
/**
* TLETODO Document CElement.
*
* @since 5.0
*/
public abstract class CElement extends PlatformObject implements ICElement { public abstract class CElement extends PlatformObject implements ICElement {
public static final char CEM_ESCAPE = '\\'; 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) { public static boolean equals(ICElement lhs, ICElement rhs) {
if (lhs == rhs) {
return true;
}
if (lhs.getElementType() != rhs.getElementType()) { if (lhs.getElementType() != rhs.getElementType()) {
return false; return false;
} }
String lhsName= lhs.getElementName(); String lhsName= lhs.getElementName();
String rhsName= rhs.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)) { !lhsName.equals(rhsName)) {
return false; return false;
} }