mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +02:00
Additional test cases for Call Hierarchy
This commit is contained in:
parent
6d190ea7c2
commit
a2c5e8987c
8 changed files with 600 additions and 97 deletions
|
@ -17,18 +17,34 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.LineNumberReader;
|
import java.io.LineNumberReader;
|
||||||
|
|
||||||
|
import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestFailure;
|
||||||
|
import junit.framework.TestResult;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.FileLocator;
|
import org.eclipse.core.runtime.FileLocator;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
||||||
|
|
||||||
public class BaseTestCase extends TestCase {
|
public class BaseTestCase extends TestCase {
|
||||||
|
private boolean fExpectFailure= false;
|
||||||
|
private int fBugnumber= 0;
|
||||||
|
|
||||||
public BaseTestCase() {
|
public BaseTestCase() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -37,6 +53,39 @@ public class BaseTestCase extends TestCase {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void run( TestResult result ) {
|
||||||
|
if (!fExpectFailure) {
|
||||||
|
super.run(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.startTest( this );
|
||||||
|
|
||||||
|
TestResult r = new TestResult();
|
||||||
|
super.run( r );
|
||||||
|
if (r.failureCount() == 1) {
|
||||||
|
TestFailure failure= (TestFailure) r.failures().nextElement();
|
||||||
|
String msg= failure.exceptionMessage();
|
||||||
|
if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) {
|
||||||
|
result.addFailure(this, new AssertionFailedError(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( r.errorCount() == 0 && r.failureCount() == 0 )
|
||||||
|
{
|
||||||
|
String err = "Unexpected success"; //$NON-NLS-1$
|
||||||
|
if( fBugnumber != -1 )
|
||||||
|
err += ", bug #" + fBugnumber; //$NON-NLS-1$
|
||||||
|
result.addFailure( this, new AssertionFailedError( err ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
result.endTest( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpectFailure(int bugnumber) {
|
||||||
|
fExpectFailure= true;
|
||||||
|
fBugnumber= bugnumber;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a section in comments form the source of the given class. The section
|
* Reads a section in comments form the source of the given class. The section
|
||||||
* is started with '// {tag}' and ends with the first line not started by '//'
|
* is started with '// {tag}' and ends with the first line not started by '//'
|
||||||
|
@ -119,4 +168,37 @@ public class BaseTestCase extends TestCase {
|
||||||
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
||||||
return createFile(container, new Path(fileName), contents);
|
return createFile(container, new Path(fileName), contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IASTTranslationUnit createPDOMBasedAST(ICProject project, IFile file) throws CModelException, CoreException {
|
||||||
|
ICElement elem= project.findElement(file.getFullPath());
|
||||||
|
if (elem instanceof ITranslationUnit) {
|
||||||
|
ITranslationUnit tu= (ITranslationUnit) elem;
|
||||||
|
if (tu != null) {
|
||||||
|
return tu.getLanguage().getASTTranslationUnit(tu, ILanguage.AST_SKIP_INDEXED_HEADERS |ILanguage.AST_USE_INDEX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fail("Could not create ast for " + file.getFullPath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void waitForIndexer(PDOM pdom, IFile file, int maxmillis) throws Exception {
|
||||||
|
long endTime= System.currentTimeMillis() + maxmillis;
|
||||||
|
do {
|
||||||
|
pdom.acquireReadLock();
|
||||||
|
try {
|
||||||
|
PDOMFile pfile= pdom.getFile(file.getLocation());
|
||||||
|
// mstodo check timestamp
|
||||||
|
if (pfile != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
pdom.releaseReadLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(50);
|
||||||
|
} while (System.currentTimeMillis() < endTime);
|
||||||
|
throw new Exception("Indexer did not complete in time!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,20 +23,18 @@ import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.ide.IDE;
|
import org.eclipse.ui.ide.IDE;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.tests.FailingTest;
|
import org.eclipse.cdt.ui.tests.BaseTestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
|
||||||
|
|
||||||
public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
private static final int EVENT_QUEUE_MILLIS = 100;
|
|
||||||
|
|
||||||
public BasicCallHierarchyTest(String name) {
|
public BasicCallHierarchyTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test getSuite() {
|
public static Test suite() {
|
||||||
TestSuite suite= new TestSuite("BasicCallHierarchyTest");
|
TestSuite suite= new TestSuite("BasicCallHierarchyTest");
|
||||||
suite.addTestSuite(BasicCallHierarchyTest.class);
|
suite.addTestSuite(BasicCallHierarchyTest.class);
|
||||||
suite.addTest(getFailingTests());
|
suite.addTest(getFailingTests());
|
||||||
|
@ -54,8 +52,10 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FailingTest getFailingTest(String name) {
|
private static Test getFailingTest(String name) {
|
||||||
return new FailingTest(new BasicCallHierarchyTest(name));
|
BaseTestCase failingTest= new BasicCallHierarchyTest(name);
|
||||||
|
failingTest.setExpectFailure(0);
|
||||||
|
return failingTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionsC() throws Exception {
|
public void testFunctionsC() throws Exception {
|
||||||
|
@ -77,33 +77,29 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
private void doTestFunctions(String filename) throws IOException, Exception, PartInitException {
|
private void doTestFunctions(String filename) throws IOException, Exception, PartInitException {
|
||||||
String content = readTaggedComment("testFunctions");
|
String content = readTaggedComment("testFunctions");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(file, 1000);
|
waitForIndexer(fPdom, file, 1000);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("proto"), 5);
|
editor.selectAndReveal(content.indexOf("proto"), 5);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
Tree tree = getCHTree(page);
|
Tree tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "proto()");
|
checkTreeNode(tree, 0, "proto()");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("func"), 2);
|
editor.selectAndReveal(content.indexOf("func"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "func()");
|
checkTreeNode(tree, 0, "func()");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("proto(); //ref"), 0);
|
editor.selectAndReveal(content.indexOf("proto(); //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "proto()");
|
checkTreeNode(tree, 0, "proto()");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("func(); //ref"), 7);
|
editor.selectAndReveal(content.indexOf("func(); //ref"), 7);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "func()");
|
checkTreeNode(tree, 0, "func()");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
@ -127,33 +123,29 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
private void doTestVariables(String filename) throws Exception {
|
private void doTestVariables(String filename) throws Exception {
|
||||||
String content = readTaggedComment("testVariables");
|
String content = readTaggedComment("testVariables");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(file, 1000);
|
waitForIndexer(fPdom, file, 1000);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("extern_var"), 0);
|
editor.selectAndReveal(content.indexOf("extern_var"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
Tree tree = getCHTree(page);
|
Tree tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "extern_var");
|
checkTreeNode(tree, 0, "extern_var");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("global_var"), 2);
|
editor.selectAndReveal(content.indexOf("global_var"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "global_var");
|
checkTreeNode(tree, 0, "global_var");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("extern_var; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("extern_var; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "extern_var");
|
checkTreeNode(tree, 0, "extern_var");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("global_var; //ref"), 7);
|
editor.selectAndReveal(content.indexOf("global_var; //ref"), 7);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "global_var");
|
checkTreeNode(tree, 0, "global_var");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
@ -189,32 +181,28 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
private void doTestEnumerator(String filename, String contentTag) throws Exception {
|
private void doTestEnumerator(String filename, String contentTag) throws Exception {
|
||||||
String content = readTaggedComment(contentTag);
|
String content = readTaggedComment(contentTag);
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(file, 1000);
|
waitForIndexer(fPdom, file, 1000);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("enumerator"), 0);
|
editor.selectAndReveal(content.indexOf("enumerator"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
Tree tree = getCHTree(page);
|
Tree tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "enumerator");
|
checkTreeNode(tree, 0, "enumerator");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("main"), 2);
|
editor.selectAndReveal(content.indexOf("main"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "main()");
|
checkTreeNode(tree, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("enumerator; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("enumerator; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "enumerator");
|
checkTreeNode(tree, 0, "enumerator");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("main"), 2);
|
editor.selectAndReveal(content.indexOf("main"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "main()");
|
checkTreeNode(tree, 0, "main()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,56 +246,48 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
private void doTestStructMembers(String filename) throws Exception {
|
private void doTestStructMembers(String filename) throws Exception {
|
||||||
String content = readTaggedComment("testStructMembers");
|
String content = readTaggedComment("testStructMembers");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(file, 1000);
|
waitForIndexer(fPdom, file, 1000);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
Tree tree = getCHTree(page);
|
Tree tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "s1::mem1");
|
checkTreeNode(tree, 0, "s1::mem1");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "s2::mem2");
|
checkTreeNode(tree, 0, "s2::mem2");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "s4::mem4");
|
checkTreeNode(tree, 0, "s4::mem4");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "s4::(anon)::mem5");
|
checkTreeNode(tree, 0, "s4::(anon)::mem5");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem1; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("mem1; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "s1::mem1");
|
checkTreeNode(tree, 0, "s1::mem1");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "s2::mem2");
|
checkTreeNode(tree, 0, "s2::mem2");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "s4::mem4");
|
checkTreeNode(tree, 0, "s4::mem4");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
@ -324,33 +304,29 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
private void doTestAnonymousStructMembers(String filename) throws Exception {
|
private void doTestAnonymousStructMembers(String filename) throws Exception {
|
||||||
String content = readTaggedComment("testStructMembers");
|
String content = readTaggedComment("testStructMembers");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(file, 1000);
|
waitForIndexer(fPdom, file, 1000);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
Tree tree = getCHTree(page);
|
Tree tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "s4::(anon)::mem5");
|
checkTreeNode(tree, 0, "s4::(anon)::mem5");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("mem3; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem5; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("mem5; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "s4::(anon)::mem5");
|
checkTreeNode(tree, 0, "s4::(anon)::mem5");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
@ -402,56 +378,48 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
private void doTestUnionMembers(String filename) throws Exception {
|
private void doTestUnionMembers(String filename) throws Exception {
|
||||||
String content = readTaggedComment("testUnionMembers");
|
String content = readTaggedComment("testUnionMembers");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(file, 1000);
|
waitForIndexer(fPdom, file, 1000);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
editor.selectAndReveal(content.indexOf("mem1"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
Tree tree = getCHTree(page);
|
Tree tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "u1::mem1");
|
checkTreeNode(tree, 0, "u1::mem1");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
editor.selectAndReveal(content.indexOf("mem2"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "u2::mem2");
|
checkTreeNode(tree, 0, "u2::mem2");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
editor.selectAndReveal(content.indexOf("mem4"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "u4::mem4");
|
checkTreeNode(tree, 0, "u4::mem4");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem1; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("mem1; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "u1::mem1");
|
checkTreeNode(tree, 0, "u1::mem1");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("mem2; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "u2::mem2");
|
checkTreeNode(tree, 0, "u2::mem2");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
editor.selectAndReveal(content.indexOf("mem4."), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "u4::mem4");
|
checkTreeNode(tree, 0, "u4::mem4");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
@ -468,33 +436,29 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
private void doTestAnonymousUnionMembers(String filename) throws Exception {
|
private void doTestAnonymousUnionMembers(String filename) throws Exception {
|
||||||
String content = readTaggedComment("testUnionMembers");
|
String content = readTaggedComment("testUnionMembers");
|
||||||
IFile file= createFile(getProject(), filename, content);
|
IFile file= createFile(getProject(), filename, content);
|
||||||
waitForIndexer(file, 1000);
|
waitForIndexer(fPdom, file, 1000);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
editor.selectAndReveal(content.indexOf("mem3"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
Tree tree = getCHTree(page);
|
Tree tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
editor.selectAndReveal(content.indexOf("mem5"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem3; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("mem3; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "(anon)::mem3");
|
checkTreeNode(tree, 0, "(anon)::mem3");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("mem5; //ref"), 0);
|
editor.selectAndReveal(content.indexOf("mem5; //ref"), 0);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
tree = getCHTree(page);
|
tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
checkTreeNode(tree, 0, "u4::(anon)::mem5");
|
||||||
checkTreeNode(tree, 0, 0, "main()");
|
checkTreeNode(tree, 0, 0, "main()");
|
||||||
|
|
|
@ -20,20 +20,18 @@ import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.ide.IDE;
|
import org.eclipse.ui.ide.IDE;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.tests.FailingTest;
|
import org.eclipse.cdt.ui.tests.BaseTestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
|
||||||
|
|
||||||
public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
private static final int EVENT_QUEUE_MILLIS = 100;
|
|
||||||
|
|
||||||
public BasicCppCallHierarchyTest(String name) {
|
public BasicCppCallHierarchyTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test getSuite() {
|
public static Test suite() {
|
||||||
TestSuite suite= new TestSuite("BasicCppCallHierarchyTest");
|
TestSuite suite= new TestSuite("BasicCppCallHierarchyTest");
|
||||||
suite.addTestSuite(BasicCppCallHierarchyTest.class);
|
suite.addTestSuite(BasicCppCallHierarchyTest.class);
|
||||||
suite.addTest(getFailingTests());
|
suite.addTest(getFailingTests());
|
||||||
|
@ -42,11 +40,16 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
private static Test getFailingTests() {
|
private static Test getFailingTests() {
|
||||||
TestSuite suite= new TestSuite("Failing Tests");
|
TestSuite suite= new TestSuite("Failing Tests");
|
||||||
|
suite.addTest(getFailingTest("_testAutomaticConstructor"));
|
||||||
|
suite.addTest(getFailingTest("_testDestructor"));
|
||||||
|
suite.addTest(getFailingTest("_testNamespacePart2"));
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FailingTest getFailingTest(String name) {
|
private static Test getFailingTest(String name) {
|
||||||
return new FailingTest(new BasicCppCallHierarchyTest(name));
|
BaseTestCase failingTest= new BasicCppCallHierarchyTest(name);
|
||||||
|
failingTest.setExpectFailure(0);
|
||||||
|
return failingTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
// {testMethods}
|
// {testMethods}
|
||||||
|
@ -72,13 +75,12 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
public void testMethods() throws Exception {
|
public void testMethods() throws Exception {
|
||||||
String content = readTaggedComment("testMethods");
|
String content = readTaggedComment("testMethods");
|
||||||
IFile file= createFile(getProject(), "testMethods.cpp", content);
|
IFile file= createFile(getProject(), "testMethods.cpp", content);
|
||||||
waitForIndexer(file, 1000);
|
waitForIndexer(fPdom, file, 1000);
|
||||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("method"), 2);
|
editor.selectAndReveal(content.indexOf("method"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
Tree tree = getCHTree(page);
|
Tree tree = getCHTree(page);
|
||||||
checkTreeNode(tree, 0, "MyClass::method()");
|
checkTreeNode(tree, 0, "MyClass::method()");
|
||||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
@ -87,7 +89,6 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("inline_method"), 2);
|
editor.selectAndReveal(content.indexOf("inline_method"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
@ -95,7 +96,6 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("method(); // r1"), 2);
|
editor.selectAndReveal(content.indexOf("method(); // r1"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "MyClass::method()");
|
checkTreeNode(tree, 0, "MyClass::method()");
|
||||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
@ -103,7 +103,6 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2);
|
editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
@ -111,7 +110,6 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("method(); // r2"), 2);
|
editor.selectAndReveal(content.indexOf("method(); // r2"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "MyClass::method()");
|
checkTreeNode(tree, 0, "MyClass::method()");
|
||||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
@ -119,7 +117,6 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2);
|
editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
@ -127,7 +124,6 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("method(); // r3"), 2);
|
editor.selectAndReveal(content.indexOf("method(); // r3"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "MyClass::method()");
|
checkTreeNode(tree, 0, "MyClass::method()");
|
||||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
@ -135,10 +131,347 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
||||||
|
|
||||||
editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2);
|
editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2);
|
||||||
openCallHierarchy(editor);
|
openCallHierarchy(editor);
|
||||||
runEventQueue(EVENT_QUEUE_MILLIS);
|
|
||||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
checkTreeNode(tree, 0, 2, "func()");
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {testStaticMethods}
|
||||||
|
// class MyClass {
|
||||||
|
// public:
|
||||||
|
// static void method();
|
||||||
|
// static void inline_method() {
|
||||||
|
// method(); // r1
|
||||||
|
// inline_method(); // r1
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void MyClass::method() {
|
||||||
|
// method(); // r2
|
||||||
|
// inline_method(); // r2
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void func() {
|
||||||
|
// MyClass::method(); // r3
|
||||||
|
// MyClass::inline_method(); // r3
|
||||||
|
// }
|
||||||
|
public void testStaticMethods() throws Exception {
|
||||||
|
String content = readTaggedComment("testStaticMethods");
|
||||||
|
IFile file= createFile(getProject(), "testStaticMethods.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 1000);
|
||||||
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("method"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
Tree tree = getCHTree(page);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("inline_method"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("method(); // r1"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("method(); // r2"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("method(); // r3"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// {testFields}
|
||||||
|
// class MyClass {
|
||||||
|
// public:
|
||||||
|
// int field;
|
||||||
|
// int static_field;
|
||||||
|
// void method();
|
||||||
|
// void inline_method() {
|
||||||
|
// int i= field; // r1
|
||||||
|
// i= static_field; // r1
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void MyClass::method() {
|
||||||
|
// int i= field; // r2
|
||||||
|
// i= static_field; // r2
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void func() {
|
||||||
|
// MyClass m;
|
||||||
|
// int i= m.field; // r3
|
||||||
|
// i= MyClass::static_field; // r3
|
||||||
|
// }
|
||||||
|
|
||||||
|
public void testFields() throws Exception {
|
||||||
|
String content = readTaggedComment("testFields");
|
||||||
|
IFile file= createFile(getProject(), "testFields.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 1000);
|
||||||
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("field"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
Tree tree = getCHTree(page);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::field");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("static_field"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::static_field");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("field; // r1"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::field");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("static_field; // r1"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::static_field");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("field; // r2"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::field");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("static_field; // r2"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::static_field");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("field; // r3"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::field");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("static_field; // r3"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::static_field");
|
||||||
|
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||||
|
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||||
|
checkTreeNode(tree, 0, 2, "func()");
|
||||||
|
}
|
||||||
|
|
||||||
|
// {testAutomaticConstructor}
|
||||||
|
// class MyClass {
|
||||||
|
// public:
|
||||||
|
// MyClass();
|
||||||
|
// virtual ~MyClass();
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void automatic() {
|
||||||
|
// MyClass m;
|
||||||
|
// }
|
||||||
|
public void _testAutomaticConstructor() throws Exception {
|
||||||
|
String content = readTaggedComment("testAutomaticConstructor");
|
||||||
|
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 1000);
|
||||||
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
Tree tree = getCHTree(page);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::MyClass()");
|
||||||
|
checkTreeNode(tree, 0, 0, "automatic()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("~MyClass"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::~MyClass()");
|
||||||
|
checkTreeNode(tree, 0, 0, "automatic()");
|
||||||
|
}
|
||||||
|
|
||||||
|
// {testConstructor}
|
||||||
|
// class MyClass {
|
||||||
|
// public:
|
||||||
|
// MyClass();
|
||||||
|
// virtual ~MyClass();
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void heap() {
|
||||||
|
// MyClass* m= new MyClass();
|
||||||
|
// delete m;
|
||||||
|
// }
|
||||||
|
public void testConstructor() throws Exception {
|
||||||
|
String content = readTaggedComment("testConstructor");
|
||||||
|
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 1000);
|
||||||
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("MyClass()"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
Tree tree = getCHTree(page);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::MyClass()");
|
||||||
|
checkTreeNode(tree, 0, 0, "heap()");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void _testDestructor() throws Exception {
|
||||||
|
String content = readTaggedComment("testConstructor");
|
||||||
|
IFile file= createFile(getProject(), "testConstructor.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 1000);
|
||||||
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("~MyClass()"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
Tree tree = getCHTree(page);
|
||||||
|
checkTreeNode(tree, 0, "MyClass::~MyClass()");
|
||||||
|
checkTreeNode(tree, 0, 0, "heap()");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// {testNamespace}
|
||||||
|
// namespace ns {
|
||||||
|
// int var;
|
||||||
|
// void func();
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void ns::func() {
|
||||||
|
// --var; // r1
|
||||||
|
// func(); // r1
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void gfunc1() {
|
||||||
|
// int i= ns::var; // r2
|
||||||
|
// ns::func(); // r2
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// using namespace ns;
|
||||||
|
// void gfunc2() {
|
||||||
|
// int i= var; // r3
|
||||||
|
// func(); // r3
|
||||||
|
// }
|
||||||
|
public void testNamespace() throws Exception {
|
||||||
|
String content = readTaggedComment("testNamespace");
|
||||||
|
IFile file= createFile(getProject(), "testNamespace.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 1000);
|
||||||
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("var"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
Tree tree = getCHTree(page);
|
||||||
|
checkTreeNode(tree, 0, "ns::var");
|
||||||
|
checkTreeNode(tree, 0, 0, "gfunc1()");
|
||||||
|
checkTreeNode(tree, 0, 1, "gfunc2()");
|
||||||
|
checkTreeNode(tree, 0, 2, "ns::func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("func()"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "ns::func()");
|
||||||
|
checkTreeNode(tree, 0, 0, "gfunc1()");
|
||||||
|
checkTreeNode(tree, 0, 1, "gfunc2()");
|
||||||
|
checkTreeNode(tree, 0, 2, "ns::func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("func(); // r1"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "ns::func()");
|
||||||
|
checkTreeNode(tree, 0, 0, "gfunc1()");
|
||||||
|
checkTreeNode(tree, 0, 1, "gfunc2()");
|
||||||
|
checkTreeNode(tree, 0, 2, "ns::func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("var; // r2"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "ns::var");
|
||||||
|
checkTreeNode(tree, 0, 0, "gfunc1()");
|
||||||
|
checkTreeNode(tree, 0, 1, "gfunc2()");
|
||||||
|
checkTreeNode(tree, 0, 2, "ns::func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("func(); // r2"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "ns::func()");
|
||||||
|
checkTreeNode(tree, 0, 0, "gfunc1()");
|
||||||
|
checkTreeNode(tree, 0, 1, "gfunc2()");
|
||||||
|
checkTreeNode(tree, 0, 2, "ns::func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("var; // r3"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "ns::var");
|
||||||
|
checkTreeNode(tree, 0, 0, "gfunc1()");
|
||||||
|
checkTreeNode(tree, 0, 1, "gfunc2()");
|
||||||
|
checkTreeNode(tree, 0, 2, "ns::func()");
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("func(); // r3"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
checkTreeNode(tree, 0, "ns::func()");
|
||||||
|
checkTreeNode(tree, 0, 0, "gfunc1()");
|
||||||
|
checkTreeNode(tree, 0, 1, "gfunc2()");
|
||||||
|
checkTreeNode(tree, 0, 2, "ns::func()");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void _testNamespacePart2() throws Exception {
|
||||||
|
String content = readTaggedComment("testNamespace");
|
||||||
|
IFile file= createFile(getProject(), "testNamespace.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 1000);
|
||||||
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
CEditor editor= (CEditor) IDE.openEditor(page, file);
|
||||||
|
|
||||||
|
editor.selectAndReveal(content.indexOf("var; // r1"), 2);
|
||||||
|
openCallHierarchy(editor);
|
||||||
|
Tree tree = getCHTree(page);
|
||||||
|
|
||||||
|
checkTreeNode(tree, 0, "ns::var");
|
||||||
|
checkTreeNode(tree, 0, 0, "gfunc1()");
|
||||||
|
checkTreeNode(tree, 0, 1, "gfunc2()");
|
||||||
|
checkTreeNode(tree, 0, 2, "ns::func()");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.callhierarchy;
|
package org.eclipse.cdt.ui.tests.callhierarchy;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
@ -28,7 +27,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.tests.BaseTestCase;
|
import org.eclipse.cdt.ui.tests.BaseTestCase;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
|
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
|
||||||
import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI;
|
import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI;
|
||||||
|
@ -37,7 +35,7 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
public class CallHierarchyBaseTest extends BaseTestCase {
|
public class CallHierarchyBaseTest extends BaseTestCase {
|
||||||
|
|
||||||
private ICProject fCProject;
|
private ICProject fCProject;
|
||||||
private PDOM fPdom;
|
public PDOM fPdom;
|
||||||
|
|
||||||
public CallHierarchyBaseTest(String name) {
|
public CallHierarchyBaseTest(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
@ -60,32 +58,14 @@ public class CallHierarchyBaseTest extends BaseTestCase {
|
||||||
return fCProject.getProject();
|
return fCProject.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForIndexer(IFile file, int maxmillis) throws Exception {
|
|
||||||
long endTime= System.currentTimeMillis() + maxmillis;
|
|
||||||
do {
|
|
||||||
fPdom.acquireReadLock();
|
|
||||||
try {
|
|
||||||
PDOMFile pfile= fPdom.getFile(file.getLocation());
|
|
||||||
// mstodo check timestamp
|
|
||||||
if (pfile != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
fPdom.releaseReadLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread.sleep(50);
|
|
||||||
} while (System.currentTimeMillis() < endTime);
|
|
||||||
throw new Exception("Indexer did not complete in time!");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void openCallHierarchy(CEditor editor) {
|
protected void openCallHierarchy(CEditor editor) {
|
||||||
CallHierarchyUI.setIsJUnitTest(true);
|
CallHierarchyUI.setIsJUnitTest(true);
|
||||||
CallHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection());
|
CallHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection());
|
||||||
|
runEventQueue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Tree getCHTree(IWorkbenchPage page) {
|
protected Tree getCHTree(IWorkbenchPage page) {
|
||||||
|
runEventQueue(0);
|
||||||
CHViewPart ch= (CHViewPart)page.findView(CUIPlugin.ID_CALL_HIERARCHY);
|
CHViewPart ch= (CHViewPart)page.findView(CUIPlugin.ID_CALL_HIERARCHY);
|
||||||
assertNotNull(ch);
|
assertNotNull(ch);
|
||||||
Tree tree= ch.getTreeViewer().getTree();
|
Tree tree= ch.getTreeViewer().getTree();
|
||||||
|
@ -103,7 +83,13 @@ public class CallHierarchyBaseTest extends BaseTestCase {
|
||||||
protected void checkTreeNode(Tree tree, int i0, String label) {
|
protected void checkTreeNode(Tree tree, int i0, String label) {
|
||||||
TreeItem root= null;
|
TreeItem root= null;
|
||||||
try {
|
try {
|
||||||
root= tree.getItem(i0);
|
for (int i=0; i<20; i++) {
|
||||||
|
root= tree.getItem(i0);
|
||||||
|
if (!"...".equals(root.getText())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
runEventQueue(50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
assertTrue("Tree node " + label + "{" + i0 + "} does not exist!", false);
|
assertTrue("Tree node " + label + "{" + i0 + "} does not exist!", false);
|
||||||
|
@ -112,14 +98,19 @@ public class CallHierarchyBaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkTreeNode(Tree tree, int i0, int i1, String label) {
|
protected void checkTreeNode(Tree tree, int i0, int i1, String label) {
|
||||||
TreeItem item= null;
|
|
||||||
try {
|
try {
|
||||||
TreeItem root= tree.getItem(i0);
|
TreeItem root= tree.getItem(i0);
|
||||||
item= root.getItem(i1);
|
TreeItem item= root.getItem(i1);
|
||||||
|
for (int i=0; i<20; i++) {
|
||||||
|
if (!"...".equals(item.getText())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
runEventQueue(50);
|
||||||
|
}
|
||||||
|
assertEquals(label, item.getText());
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
assertTrue("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!", false);
|
assertTrue("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!", false);
|
||||||
}
|
}
|
||||||
assertEquals(label, item.getText());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class CallHierarchyTestSuite extends TestSuite {
|
||||||
|
|
||||||
public CallHierarchyTestSuite() {
|
public CallHierarchyTestSuite() {
|
||||||
super("Tests in package org.eclipse.cdt.ui.tests.callhierarchy");
|
super("Tests in package org.eclipse.cdt.ui.tests.callhierarchy");
|
||||||
addTest(BasicCallHierarchyTest.getSuite());
|
addTest(BasicCallHierarchyTest.suite());
|
||||||
addTest(BasicCppCallHierarchyTest.getSuite());
|
addTest(BasicCppCallHierarchyTest.suite());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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.text.selection;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
|
import org.eclipse.cdt.ui.tests.BaseTestCase;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
|
||||||
|
public class ResolveBindingTests extends BaseTestCase {
|
||||||
|
|
||||||
|
private ICProject fCProject;
|
||||||
|
private PDOM fPdom;
|
||||||
|
|
||||||
|
public ResolveBindingTests(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
TestSuite suite= new TestSuite("ResolveBindingTests");
|
||||||
|
suite.addTestSuite(ResolveBindingTests.class);
|
||||||
|
suite.addTest(getFailingTests());
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Test getFailingTests() {
|
||||||
|
TestSuite suite= new TestSuite("Failing Tests");
|
||||||
|
suite.addTest(getFailingTest("_testNamespaceVarBinding2", 156519));
|
||||||
|
return suite;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Test getFailingTest(String name, int bug) {
|
||||||
|
BaseTestCase failingTest= new ResolveBindingTests(name);
|
||||||
|
failingTest.setExpectFailure(bug);
|
||||||
|
return failingTest;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
fCProject= CProjectHelper.createCProject("ResolveBindingTests", "bin");
|
||||||
|
CCorePlugin.getPDOMManager().setIndexerId(fCProject, "org.eclipse.cdt.core.fastIndexer");
|
||||||
|
fPdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(fCProject);
|
||||||
|
fPdom.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
if (fCProject != null) {
|
||||||
|
fCProject.getProject().delete(IProject.FORCE | IProject.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||||
|
}
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IASTName getSelectedName(IASTTranslationUnit astTU, int offset, int len) {
|
||||||
|
IASTName[] names= astTU.getLanguage().getSelectedNames(astTU, offset, len);
|
||||||
|
assertEquals(1, names.length);
|
||||||
|
return names[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkBinding(IASTName name, Class clazz) {
|
||||||
|
IBinding binding;
|
||||||
|
binding= name.resolveBinding();
|
||||||
|
assertNotNull("Cannot resolve binding", binding);
|
||||||
|
if (binding instanceof IProblemBinding) {
|
||||||
|
IProblemBinding problem= (IProblemBinding) binding;
|
||||||
|
fail("Cannot resolve binding: " + problem.getMessage());
|
||||||
|
}
|
||||||
|
assertTrue(clazz.isInstance(binding));
|
||||||
|
}
|
||||||
|
|
||||||
|
// {namespace-var-test}
|
||||||
|
// namespace ns {
|
||||||
|
// int var;
|
||||||
|
// void func();
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void ns::func() {
|
||||||
|
// ++var; // r1
|
||||||
|
// ++ns::var; // r2
|
||||||
|
// }
|
||||||
|
|
||||||
|
public void testNamespaceVarBinding() throws Exception {
|
||||||
|
String content = readTaggedComment("namespace-var-test");
|
||||||
|
IFile file= createFile(fCProject.getProject(), "nsvar.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 2000);
|
||||||
|
|
||||||
|
IASTTranslationUnit astTU= createPDOMBasedAST(fCProject, file);
|
||||||
|
IASTName name= getSelectedName(astTU, content.indexOf("var"), 3);
|
||||||
|
IBinding binding= name.resolveBinding();
|
||||||
|
assertTrue(binding instanceof IVariable);
|
||||||
|
|
||||||
|
name= getSelectedName(astTU, content.indexOf("var; // r1"), 3);
|
||||||
|
checkBinding(name, IVariable.class);
|
||||||
|
|
||||||
|
name= getSelectedName(astTU, content.indexOf("var; // r2"), 3);
|
||||||
|
checkBinding(name, IVariable.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void _testNamespaceVarBinding2() throws Exception {
|
||||||
|
String content = readTaggedComment("namespace-var-test");
|
||||||
|
IFile file= createFile(fCProject.getProject(), "nsvar.cpp", content);
|
||||||
|
waitForIndexer(fPdom, file, 2000);
|
||||||
|
|
||||||
|
IASTTranslationUnit astTU= createPDOMBasedAST(fCProject, file);
|
||||||
|
|
||||||
|
IASTName name= getSelectedName(astTU, content.indexOf("var; // r1"), 3);
|
||||||
|
IBinding binding= name.resolveBinding();
|
||||||
|
checkBinding(name, IVariable.class);
|
||||||
|
|
||||||
|
name= getSelectedName(astTU, content.indexOf("var; // r2"), 3);
|
||||||
|
checkBinding(name, IVariable.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ public class SelectionTestSuite extends TestSuite {
|
||||||
super("Tests in package org.eclipse.cdt.ui.tests.text.selection");
|
super("Tests in package org.eclipse.cdt.ui.tests.text.selection");
|
||||||
|
|
||||||
// selection tests
|
// selection tests
|
||||||
|
addTest( ResolveBindingTests.suite() );
|
||||||
addTest( CPPSelectionTestsNoIndexer.suite() );
|
addTest( CPPSelectionTestsNoIndexer.suite() );
|
||||||
addTest( CSelectionTestsNoIndexer.suite() );
|
addTest( CSelectionTestsNoIndexer.suite() );
|
||||||
addTest( CPPSelectionTestsDOMIndexer.suite() );
|
addTest( CPPSelectionTestsDOMIndexer.suite() );
|
||||||
|
|
|
@ -235,10 +235,6 @@ public class CIndexQueries {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IASTName name= names[names.length-1];
|
IASTName name= names[names.length-1];
|
||||||
IASTName[] a= ast.getReferences(name.resolveBinding());
|
|
||||||
if (a.length > 0) {
|
|
||||||
a[0]= null;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < scope.length; i++) {
|
for (int i = 0; i < scope.length; i++) {
|
||||||
ICProject project = scope[i];
|
ICProject project = scope[i];
|
||||||
findCalledBy(name, project, result);
|
findCalledBy(name, project, result);
|
||||||
|
|
Loading…
Add table
Reference in a new issue