1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

Automated tests for the type hierarchy

This commit is contained in:
Markus Schorn 2007-01-24 14:02:24 +00:00
parent 61ab28f322
commit 774fde4cf9
14 changed files with 1277 additions and 20 deletions

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
@ -236,6 +237,15 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
* @since 4.0
*/
public void onCreateName(PDOMName pdomName, IASTName name) throws CoreException {
IASTNode parentNode= name.getParent();
if (parentNode instanceof IASTDeclSpecifier) {
IASTDeclSpecifier ds= (IASTDeclSpecifier) parentNode;
if (ds.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
if (pdomName.getEnclosingDefinitionRecord() != 0) {
pdomName.setIsBaseSpecifier(true);
}
}
}
}
/**

View file

@ -161,7 +161,7 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
}
private int getEnclosingDefinitionRecord() throws CoreException {
int getEnclosingDefinitionRecord() throws CoreException {
return pdom.getDB().getInt(record + CALLER_REC_OFFSET);
}

View file

@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -353,10 +352,10 @@ class PDOMCPPLinkage extends PDOMLinkage {
public void onCreateName(PDOMName pdomName, IASTName name) throws CoreException {
super.onCreateName(pdomName, name);
PDOMName derivedClassName= (PDOMName) pdomName.getEnclosingDefinition();
if (derivedClassName != null) {
IASTNode parentNode= name.getParent();
if (parentNode instanceof ICPPASTBaseSpecifier) {
IASTNode parentNode= name.getParent();
if (parentNode instanceof ICPPASTBaseSpecifier) {
PDOMName derivedClassName= (PDOMName) pdomName.getEnclosingDefinition();
if (derivedClassName != null) {
ICPPASTBaseSpecifier baseNode= (ICPPASTBaseSpecifier) parentNode;
PDOMBinding derivedClassBinding= derivedClassName.getPDOMBinding();
if (derivedClassBinding instanceof PDOMCPPClassType) {
@ -366,12 +365,6 @@ class PDOMCPPLinkage extends PDOMLinkage {
pdomName.setIsBaseSpecifier(true);
}
}
else if (parentNode instanceof IASTDeclSpecifier) {
IASTDeclSpecifier ds= (IASTDeclSpecifier) parentNode;
if (ds.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
pdomName.setIsBaseSpecifier(true);
}
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* Copyright (c) 2000, 2007 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
@ -22,6 +22,7 @@ import org.eclipse.cdt.ui.tests.text.TextTestSuite;
import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite;
import org.eclipse.cdt.ui.tests.text.contentassist2.ContentAssist2TestSuite;
import org.eclipse.cdt.ui.tests.text.selection.SelectionTestSuite;
import org.eclipse.cdt.ui.tests.typehierarchy.TypeHierarchyTestSuite;
import org.eclipse.cdt.ui.tests.viewsupport.ViewSupportTestSuite;
/**
@ -51,7 +52,10 @@ public class AutomatedSuite extends TestSuite {
// tests for package org.eclipse.cdt.ui.tests.callhierarchy
addTest(CallHierarchyTestSuite.suite());
// tests for package org.eclipse.cdt.ui.tests.callhierarchy
// tests for package org.eclipse.cdt.ui.tests.typehierarchy
addTest(TypeHierarchyTestSuite.suite());
// tests for package org.eclipse.cdt.ui.tests.includebrowser
addTest(IncludeBrowserTestSuite.suite());
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2007 Wind River Systems, Inc. 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
@ -32,16 +32,16 @@ import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.ui.editor.CEditor;
public class CallHierarchyAccrossProjectsTest extends CallHierarchyBaseTest {
public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest {
private ICProject fCProject2;
public CallHierarchyAccrossProjectsTest(String name) {
public CallHierarchyAcrossProjectsTest(String name) {
super(name);
}
public static Test suite() {
return suite(CallHierarchyAccrossProjectsTest.class);
return suite(CallHierarchyAcrossProjectsTest.class);
}
protected void setUp() throws Exception {

View file

@ -25,6 +25,6 @@ public class CallHierarchyTestSuite extends TestSuite {
addTest(BasicCppCallHierarchyTest.suite());
addTest(InitializersInCallHierarchyTest.suite());
addTest(CppCallHierarchyTest.suite());
addTest(CallHierarchyAccrossProjectsTest.suite());
addTest(CallHierarchyAcrossProjectsTest.suite());
}
}

View file

@ -0,0 +1,400 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.cdt.internal.ui.editor.CEditor;
public class CTypeHierarchyTest extends TypeHierarchyBaseTest {
public CTypeHierarchyTest(String name) {
super(name);
}
public static Test suite() {
return suite(CTypeHierarchyTest.class);
}
// enum E1 {e1, e2};
// typedef enum E2 {e3, e4} TE2;
// enum E3 {e5, e6};
// typedef E3 TE3;
public void testEnumC() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enum.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
Tree tree;
TreeItem item;
editor.selectAndReveal(content.indexOf("E1"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "E1");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"e1", "e2"});
editor.selectAndReveal(content.indexOf("E2"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "E2");
item= checkTreeNode(item, 0, "TE2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"e3", "e4"});
editor.selectAndReveal(content.indexOf("E3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "E3");
item= checkTreeNode(item, 0, "TE3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"e5", "e6"});
}
// enum E1 {e1, e2};
// typedef enum E2 {e3, e4} TE2;
// enum E3 {e5, e6};
// typedef E3 TE3;
public void testEnumCPP() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "enum.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
Tree tree;
TreeItem item;
editor.selectAndReveal(content.indexOf("E1"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "E1");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"e1", "e2"});
editor.selectAndReveal(content.indexOf("E2"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "E2");
item= checkTreeNode(item, 0, "TE2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"e3", "e4"});
editor.selectAndReveal(content.indexOf("E3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "E3");
item= checkTreeNode(item, 0, "TE3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"e5", "e6"});
}
// struct S1 {
// int a1;
// int b1;
// };
// typedef struct S3 {
// int a3;
// int b3;
// } T3;
public void testStructC_1() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "struct.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
editor.selectAndReveal(content.indexOf("S1"), 1);
openTypeHierarchy(editor);
Tree tree = getHierarchyViewer().getTree();
TreeItem item= checkTreeNode(tree, 0, "S1");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a1", "b1"});
editor.selectAndReveal(content.indexOf("S3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "S3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a3", "b3"});
}
// typedef struct S2 {
// int a2;
// int b2;
// } S2;
// typedef struct S3 {
// int a3;
// int b3;
// } T3;
public void _testStructC_2() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "struct.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
editor.selectAndReveal(content.indexOf("S2"), 1);
openTypeHierarchy(editor);
Tree tree = getHierarchyViewer().getTree();
TreeItem item = checkTreeNode(tree, 0, "S2");
item= checkTreeNode(item, 0, "S2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a2", "b2"});
editor.selectAndReveal(content.indexOf("S2;"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "S2");
item= checkTreeNode(item, 0, "S2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[0]);
editor.selectAndReveal(content.indexOf("S3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "S3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a3", "b3"});
editor.selectAndReveal(content.indexOf("T3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "S3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[0]);
}
// struct S1 {
// int a1;
// int b1;
// };
// typedef struct S2 {
// int a2;
// int b2;
// } S2;
// typedef struct S3 {
// int a3;
// int b3;
// } T3;
public void testStructCPP_1() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "struct.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
editor.selectAndReveal(content.indexOf("S1"), 1);
openTypeHierarchy(editor);
Tree tree = getHierarchyViewer().getTree();
TreeItem item= checkTreeNode(tree, 0, "S1");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a1", "b1"});
editor.selectAndReveal(content.indexOf("S2"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "S2");
item= checkTreeNode(item, 0, "S2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a2", "b2"});
editor.selectAndReveal(content.indexOf("S3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "S3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a3", "b3"});
editor.selectAndReveal(content.indexOf("T3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "S3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[0]);
}
// typedef struct S2 {
// int a2;
// int b2;
// } S2;
public void _testStructCPP_2() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "struct.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
editor.selectAndReveal(content.indexOf("S2;"), 1);
openTypeHierarchy(editor);
Tree tree = getHierarchyViewer().getTree();
TreeItem item = checkTreeNode(tree, 0, "S2");
item= checkTreeNode(item, 0, "S2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[0]);
}
// union U1 {
// int a1;
// char b1;
// };
public void testUnionC_1() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "union.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
editor.selectAndReveal(content.indexOf("U1"), 1);
openTypeHierarchy(editor);
Tree tree = getHierarchyViewer().getTree();
TreeItem item= checkTreeNode(tree, 0, "U1");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a1", "b1"});
}
// typedef union U2 {
// int a2;
// int b2;
// } U2;
// typedef union U3 {
// int a3;
// int b3;
// } T3;
public void _testUnionC_2() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "union.c", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
editor.selectAndReveal(content.indexOf("U2"), 1);
openTypeHierarchy(editor);
Tree tree = getHierarchyViewer().getTree();
TreeItem item = checkTreeNode(tree, 0, "U2");
item= checkTreeNode(item, 0, "U2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a2", "b2"});
editor.selectAndReveal(content.indexOf("U2;"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "U2");
item= checkTreeNode(item, 0, "U2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[0]);
editor.selectAndReveal(content.indexOf("U3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "U3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a3", "b3"});
editor.selectAndReveal(content.indexOf("T3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "U3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[0]);
}
// union U1 {
// int a1;
// int b1;
// };
// typedef union U2 {
// int a2;
// int b2;
// } U2;
// typedef union U3 {
// int a3;
// int b3;
// } T3;
public void testUnionCPP_1() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "union.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
editor.selectAndReveal(content.indexOf("U1"), 1);
openTypeHierarchy(editor);
Tree tree = getHierarchyViewer().getTree();
TreeItem item= checkTreeNode(tree, 0, "U1");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a1", "b1"});
editor.selectAndReveal(content.indexOf("U3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "U3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a3", "b3"});
editor.selectAndReveal(content.indexOf("T3"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "U3");
item= checkTreeNode(item, 0, "T3");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[0]);
}
// typedef union U2 {
// int a2;
// int b2;
// } U2;
public void _testUnionCPP_2() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "union.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
Tree tree; TreeItem item;
editor.selectAndReveal(content.indexOf("U2"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item= checkTreeNode(tree, 0, "U2");
item= checkTreeNode(item, 0, "U2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[] {"a2", "b2"});
editor.selectAndReveal(content.indexOf("U2;"), 1);
openTypeHierarchy(editor);
tree = getHierarchyViewer().getTree();
item = checkTreeNode(tree, 0, "U2");
item= checkTreeNode(item, 0, "U2");
assertEquals(0, item.getItemCount());
checkMethodTable(new String[0]);
}
}

View file

@ -0,0 +1,443 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.cdt.internal.ui.editor.CEditor;
public class CppTypeHierarchyTest extends TypeHierarchyBaseTest {
public CppTypeHierarchyTest(String name) {
super(name);
}
public static Test suite() {
return suite(CppTypeHierarchyTest.class);
}
// class Simple1 {
// public:
// int field1;
// int method1();
// };
// class Simple2 : public Simple1 {
// public:
// int field2;
// int method2();
// };
// class Simple3 : public Simple2 {
// public:
// int field3;
// int method3();
// };
// class Simple4 : public Simple1 {
// public:
// int field4;
// int method4();
// };
public void testSimpleInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "class.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("Simple1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Simple2");
item4= checkTreeNode(item1, 1, "Simple4");
assertEquals(2, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1", "method1()"});
editor.selectAndReveal(content.indexOf("Simple2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field2", "method2()"});
editor.selectAndReveal(content.indexOf("Simple3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3", "method3()"});
editor.selectAndReveal(content.indexOf("Simple4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item4= checkTreeNode(item1, 0, "Simple4");
assertEquals(1, item1.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4", "method4()"});
}
// class Multi1 {
// public:
// int field1;
// int method1();
// };
// class Multi2 {
// public:
// int field2;
// int method2();
// };
// class Multi3 : public Multi1, Multi2 {
// public:
// int field3;
// int method3();
// };
// class Multi4 : public Multi3 {
// public:
// int field4;
// int method4();
// };
public void testMultipleInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "multi.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("Multi1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Multi1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1", "method1()"});
editor.selectAndReveal(content.indexOf("Multi2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item2= checkTreeNode(tree, 0, "Multi2");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item2, 0, "Multi3");
assertEquals(1, item2.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field2", "method2()"});
editor.selectAndReveal(content.indexOf("Multi3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Multi1");
item2= checkTreeNode(tree, 1, "Multi2");
assertEquals(2, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
item3= checkTreeNode(item2, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field3", "method3()"});
editor.selectAndReveal(content.indexOf("Multi4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Multi1");
item2= checkTreeNode(tree, 1, "Multi2");
assertEquals(2, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
item3= checkTreeNode(item2, 0, "Multi3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Multi4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4", "method4()"});
}
// class Diamond1 {
// public:
// int field1;
// int method1();
// };
// class Diamond2 : public Diamond1 {
// public:
// int field2;
// int method2();
// };
// class Diamond3 : public Diamond1 {
// public:
// int field3;
// int method3();
// };
// class Diamond4 : public Diamond2, Diamond3 {
// public:
// int field4;
// int method4();
// };
public void testDiamondInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "diamond.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("Diamond1"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
item3= checkTreeNode(item1, 1, "Diamond3");
assertEquals(2, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
item4= checkTreeNode(item3, 0, "Diamond4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1", "method1()"});
editor.selectAndReveal(content.indexOf("Diamond2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field2", "method2()"});
editor.selectAndReveal(content.indexOf("Diamond3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item3= checkTreeNode(item1, 0, "Diamond3");
assertEquals(1, item1.getItemCount());
item4= checkTreeNode(item3, 0, "Diamond4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field3", "method3()"});
editor.selectAndReveal(content.indexOf("Diamond4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Diamond1");
assertEquals(1, tree.getItemCount());
getHierarchyViewer().expandAll();
item2= checkTreeNode(item1, 0, "Diamond2");
item3= checkTreeNode(item1, 1, "Diamond3");
assertEquals(2, item1.getItemCount());
item4= checkTreeNode(item2, 0, "Diamond4");
assertEquals(1, item2.getItemCount());
assertEquals(0, item4.getItemCount());
item4= checkTreeNode(item3, 0, "Diamond4");
assertEquals(1, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4", "method4()"});
}
// class ViaTypedef1 {
// public:
// int field1;
// int method1();
// };
// typedef ViaTypedef1 ViaTypedef2;
//
// class ViaTypedef3 : public ViaTypedef2 {
// public:
// int field3;
// int method3();
// };
// class ViaTypedef4 : public ViaTypedef1 {
// public:
// int field4;
// int method4();
// };
public void testViaTypedefInheritance() throws Exception {
String content= getContentsForTest(1)[0].toString();
IFile file= createFile(getProject(), "viaTypedef.cpp", content);
waitForIndexer(fIndex, file, INDEXER_WAIT_TIME);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(content.indexOf("ViaTypedef1"), 1);
openTypeHierarchy(editor);
getHierarchyViewer().expandAll();
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "ViaTypedef2");
item4= checkTreeNode(item1, 1, "ViaTypedef4");
assertEquals(2, item1.getItemCount());
item3= checkTreeNode(item2, 0, "ViaTypedef3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1", "method1()"});
editor.selectAndReveal(content.indexOf("ViaTypedef2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "ViaTypedef2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "ViaTypedef3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {});
editor.selectAndReveal(content.indexOf("ViaTypedef3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "ViaTypedef2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "ViaTypedef3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3", "method3()"});
editor.selectAndReveal(content.indexOf("ViaTypedef4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "ViaTypedef1");
assertEquals(1, tree.getItemCount());
item4= checkTreeNode(item1, 0, "ViaTypedef4");
assertEquals(1, item1.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4", "method4()"});
}
}

View file

@ -0,0 +1,165 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.Test;
import org.eclipse.core.resources.IFile;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.ui.editor.CEditor;
public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest {
private ICProject fCProject2;
public TypeHierarchyAcrossProjectsTest(String name) {
super(name);
}
public static Test suite() {
return suite(TypeHierarchyAcrossProjectsTest.class);
}
protected void setUp() throws Exception {
super.setUp();
fCProject2= CProjectHelper.createCCProject("__thTest_2__", "bin", IPDOMManager.ID_FAST_INDEXER);
CCoreInternals.getPDOMManager().reindex(fCProject2);
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {fCProject, fCProject2});
TestScannerProvider.sIncludes= new String[]{fCProject.getProject().getLocation().toOSString(), fCProject2.getProject().getLocation().toOSString()};
}
protected void tearDown() throws Exception {
TestScannerProvider.sIncludes= null;
if (fCProject2 != null) {
CProjectHelper.delete(fCProject2);
}
super.tearDown();
}
// class Simple1 {
// public:
// int field1;
// int method1();
// };
// class Simple2 : public Simple1 {
// public:
// int field2;
// int method2();
// };
// #include "simpleHeader.h"
// class Simple3 : public Simple2 {
// public:
// int field3;
// int method3();
// };
// class Simple4 : public Simple1 {
// public:
// int field4;
// int method4();
// };
public void _testSimpleInheritanceAcross() throws Exception {
StringBuffer[] content= getContentsForTest(2);
String header= content[0].toString();
String source = content[1].toString();
IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header);
IFile sourceFile= createFile(fCProject2.getProject(), "simple.cpp", source);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
waitForIndexer(fIndex, sourceFile, TypeHierarchyBaseTest.INDEXER_WAIT_TIME);
CEditor editor= (CEditor) IDE.openEditor(page, sourceFile);
Tree tree;
TreeItem item1, item2, item3, item4;
editor.selectAndReveal(source.indexOf("Simple1"), 1);
openTypeHierarchy(editor);
getHierarchyViewer().expandAll();
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
item4= checkTreeNode(item1, 1, "Simple4");
assertEquals(2, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field1", "method1()"});
editor.selectAndReveal(source.indexOf("Simple2"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field2", "method2()"});
editor.selectAndReveal(source.indexOf("Simple3"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item2= checkTreeNode(item1, 0, "Simple2");
assertEquals(1, item1.getItemCount());
item3= checkTreeNode(item2, 0, "Simple3");
assertEquals(1, item2.getItemCount());
assertEquals(0, item3.getItemCount());
checkMethodTable(new String[] {"field3", "method3()"});
editor.selectAndReveal(source.indexOf("Simple4"), 1);
openTypeHierarchy(editor);
tree= getHierarchyViewer().getTree();
item1= checkTreeNode(tree, 0, "Simple1");
assertEquals(1, tree.getItemCount());
item4= checkTreeNode(item1, 0, "Simple4");
assertEquals(1, item1.getItemCount());
assertEquals(0, item4.getItemCount());
checkMethodTable(new String[] {"field4", "method4()"});
}
public void testDummy() {
}
}

View file

@ -0,0 +1,206 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.typehierarchy;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.tests.BaseUITestCase;
import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;
import org.eclipse.cdt.internal.ui.typehierarchy.TypeHierarchyUI;
public class TypeHierarchyBaseTest extends BaseUITestCase {
protected static final int INDEXER_WAIT_TIME = 8000;
protected ICProject fCProject;
protected IIndex fIndex;
public TypeHierarchyBaseTest(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
fCProject= CProjectHelper.createCCProject("__thTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
CCoreInternals.getPDOMManager().reindex(fCProject);
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
}
protected void tearDown() throws Exception {
if (fCProject != null) {
CProjectHelper.delete(fCProject);
}
super.tearDown();
}
protected IProject getProject() {
return fCProject.getProject();
}
protected CEditor openFile(IFile file) throws PartInitException {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CEditor editor= (CEditor) IDE.openEditor(page, file);
return editor;
}
protected void openTypeHierarchy(CEditor editor) {
TypeHierarchyUI.setIsJUnitTest(true);
TypeHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection());
runEventQueue(200);
}
protected void openTypeHierarchy(CEditor editor, int mode) {
TypeHierarchyUI.setIsJUnitTest(true);
TypeHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection());
runEventQueue(0);
THViewPart th= null;
IWorkbenchPage page = editor.getSite().getPage();
for (int i = 0; i < 400; i++) {
th= (THViewPart)page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
if (th != null)
break;
runEventQueue(10);
}
assertNotNull(th);
th.onSetHierarchyKind(mode);
}
protected TreeViewer getHierarchyViewer() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
runEventQueue(0);
THViewPart th= null;
for (int i=0; i<50; i++) {
th= (THViewPart)page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
if (th != null)
break;
runEventQueue(10);
}
assertNotNull(th);
return th.getHiearchyViewer();
}
protected TableViewer getMethodViewer() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
runEventQueue(0);
THViewPart th= null;
for (int i=0; i<50; i++) {
th= (THViewPart)page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
if (th != null)
break;
runEventQueue(10);
}
assertNotNull(th);
return th.getMethodViewer();
}
protected TreeItem checkTreeNode(Tree tree, int i0, String label) {
TreeItem root= null;
try {
for (int i=0; i<100; i++) {
root= tree.getItem(i0);
try {
if (!"...".equals(root.getText())) {
break;
}
} catch (SWTException e) {
// in case widget was disposed, item may be replaced
}
runEventQueue(10);
}
}
catch (IllegalArgumentException e) {
fail("Tree node " + label + "{" + i0 + "} does not exist!");
}
assertEquals(label, root.getText());
return root;
}
protected TreeItem checkTreeNode(Tree tree, int i0, int i1, String label) {
TreeItem item= null;
try {
TreeItem root= tree.getItem(i0);
for (int i=0; i<40; i++) {
item= root.getItem(i1);
try {
if (!"...".equals(item.getText())) {
break;
}
} catch (SWTException e) {
// in case widget was disposed, item may be replaced
}
runEventQueue(50);
}
}
catch (IllegalArgumentException e) {
fail("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!");
}
assertEquals(label, item.getText());
return item;
}
protected TreeItem checkTreeNode(TreeItem root, int i1, String label) {
TreeItem item= null;
try {
for (int i=0; i<40; i++) {
item= root.getItem(i1);
try {
if (!"...".equals(item.getText())) {
break;
}
} catch (SWTException e) {
// in case widget was disposed, item may be replaced
}
runEventQueue(50);
}
}
catch (IllegalArgumentException e) {
assertNull("Tree node " + label + " does not exist!", label);
return null;
}
assertNotNull("Unexpected tree node " + item.getText(), label);
assertEquals(label, item.getText());
return item;
}
protected void checkMethodTable(String[] items) {
Table table= getMethodViewer().getTable();
TableItem[] titems= table.getItems();
for (int i = 0; i < Math.min(titems.length, items.length); i++) {
assertEquals("wrong item in method table in column " + i, items[i], titems[i].getText());
}
assertTrue("Missing items in method table", items.length <= titems.length);
assertTrue("Superfluous items in method table", items.length >= titems.length);
}
}

View file

@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.typehierarchy;
import junit.framework.TestSuite;
public class TypeHierarchyTestSuite extends TestSuite {
public static TestSuite suite() {
return new TypeHierarchyTestSuite();
}
public TypeHierarchyTestSuite() {
super("Tests in package org.eclipse.cdt.ui.tests.typehierarchy");
addTest(CTypeHierarchyTest.suite());
addTest(CppTypeHierarchyTest.suite());
addTest(TypeHierarchyAcrossProjectsTest.suite());
}
}

View file

@ -34,6 +34,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.internal.ui.text.folding;x-internal:=true,
org.eclipse.cdt.internal.ui.text.template;x-internal:=true,
org.eclipse.cdt.internal.ui.text.util;x-internal:=true,
org.eclipse.cdt.internal.ui.typehierarchy;x-internal:=true,
org.eclipse.cdt.internal.ui.util;x-internal:=true,
org.eclipse.cdt.internal.ui.viewsupport;x-internal:=true,
org.eclipse.cdt.internal.ui.wizards;x-internal:=true,

View file

@ -39,6 +39,7 @@ import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
class THGraph {
private static final Object[] NO_MEMBERS = new Object[0];
private THGraphNode fInputNode= null;
private HashSet fRootNodes= new HashSet();
private HashSet fLeaveNodes= new HashSet();
@ -80,6 +81,9 @@ class THGraph {
}
private boolean createsLoop(THGraphNode from, THGraphNode to) {
if (from == to) {
return true;
}
if (to.getOutgoing().isEmpty() || from.getIncoming().isEmpty()) {
return false;
}
@ -271,6 +275,9 @@ class THGraph {
addMemberElements(index, members, memberList);
graphNode.setMembers(memberList.toArray());
}
else {
graphNode.setMembers(NO_MEMBERS);
}
}
}

View file

@ -844,7 +844,7 @@ public class THViewPart extends ViewPart {
// updateView();
// }
protected void onSetHierarchyKind(int kind) {
public void onSetHierarchyKind(int kind) {
if (fModel.getHierarchyKind() != kind) {
fModel.setHierarchyKind(kind);
updateView();