diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java index 9b4887811f3..d7077171d7d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java @@ -60,7 +60,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("proto"), 5); openCallHierarchy(editor); - Tree tree = getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "proto()"); checkTreeNode(tree, 0, 0, "main()"); @@ -71,13 +71,11 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("proto(); //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "proto()"); checkTreeNode(tree, 0, 0, "main()"); editor.selectAndReveal(content.indexOf("func(); //ref"), 7); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "func()"); checkTreeNode(tree, 0, 0, "main()"); } @@ -106,7 +104,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("extern_var"), 0); openCallHierarchy(editor); - Tree tree = getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "extern_var"); checkTreeNode(tree, 0, 0, "main()"); @@ -117,13 +115,11 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("extern_var; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "extern_var"); checkTreeNode(tree, 0, 0, "main()"); editor.selectAndReveal(content.indexOf("global_var; //ref"), 7); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "global_var"); checkTreeNode(tree, 0, 0, "main()"); } @@ -164,7 +160,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("enumerator"), 0); openCallHierarchy(editor); - Tree tree = getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "enumerator"); checkTreeNode(tree, 0, 0, "main()"); @@ -174,7 +170,6 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("enumerator; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "enumerator"); checkTreeNode(tree, 0, 0, "main()"); @@ -229,7 +224,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem1"), 0); openCallHierarchy(editor); - Tree tree = getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "s1::mem1"); checkTreeNode(tree, 0, 0, "main()"); @@ -253,19 +248,16 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem1; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "s1::mem1"); checkTreeNode(tree, 0, 0, "main()"); editor.selectAndReveal(content.indexOf("mem2; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "s2::mem2"); checkTreeNode(tree, 0, 0, "main()"); editor.selectAndReveal(content.indexOf("mem4."), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "s4::mem4"); checkTreeNode(tree, 0, 0, "main()"); } @@ -287,7 +279,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); - Tree tree = getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "(anon)::mem3"); checkTreeNode(tree, 0, 0, "main()"); @@ -298,13 +290,11 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem3; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "(anon)::mem3"); checkTreeNode(tree, 0, 0, "main()"); editor.selectAndReveal(content.indexOf("mem5; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "s4::(anon)::mem5"); checkTreeNode(tree, 0, 0, "main()"); } @@ -361,7 +351,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem1"), 0); openCallHierarchy(editor); - Tree tree = getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "u1::mem1"); checkTreeNode(tree, 0, 0, "main()"); @@ -385,19 +375,16 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem1; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "u1::mem1"); checkTreeNode(tree, 0, 0, "main()"); editor.selectAndReveal(content.indexOf("mem2; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "u2::mem2"); checkTreeNode(tree, 0, 0, "main()"); editor.selectAndReveal(content.indexOf("mem4."), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "u4::mem4"); checkTreeNode(tree, 0, 0, "main()"); } @@ -419,7 +406,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem3"), 0); openCallHierarchy(editor); - Tree tree = getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "(anon)::mem3"); checkTreeNode(tree, 0, 0, "main()"); @@ -430,13 +417,11 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { editor.selectAndReveal(content.indexOf("mem3; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "(anon)::mem3"); checkTreeNode(tree, 0, 0, "main()"); editor.selectAndReveal(content.indexOf("mem5; //ref"), 0); openCallHierarchy(editor); - tree = getCHTree(page); checkTreeNode(tree, 0, "u4::(anon)::mem5"); checkTreeNode(tree, 0, 0, "main()"); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java index 5d0d09e867a..6e31b178926 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCppCallHierarchyTest.java @@ -24,8 +24,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor; public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { - private static final int MAX_TIME_INDEXER = 8000; - public BasicCppCallHierarchyTest(String name) { super(name); } @@ -57,13 +55,13 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testMethods() throws Exception { String content = readTaggedComment("testMethods"); IFile file= createFile(getProject(), "testMethods.cpp", content); - waitForIndexer(fIndex, file, MAX_TIME_INDEXER); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); 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); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, 0, "func()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); @@ -141,13 +139,13 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testStaticMethods() throws Exception { String content = readTaggedComment("testStaticMethods"); IFile file= createFile(getProject(), "testStaticMethods.cpp", content); - waitForIndexer(fIndex, file, MAX_TIME_INDEXER); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); 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); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, 0, "func()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); @@ -230,13 +228,13 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testFields() throws Exception { String content = readTaggedComment("testFields"); IFile file= createFile(getProject(), "testFields.cpp", content); - waitForIndexer(fIndex, file, MAX_TIME_INDEXER); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); 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); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::field"); checkTreeNode(tree, 0, 0, "func()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); @@ -305,13 +303,13 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void _testAutomaticConstructor_156668() throws Exception { String content = readTaggedComment("testAutomaticConstructor"); IFile file= createFile(getProject(), "testConstructor.cpp", content); - waitForIndexer(fIndex, file, MAX_TIME_INDEXER); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); 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); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::MyClass()"); checkTreeNode(tree, 0, 0, "automatic()"); @@ -335,13 +333,13 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testConstructor() throws Exception { String content = readTaggedComment("testConstructor"); IFile file= createFile(getProject(), "testConstructor.cpp", content); - waitForIndexer(fIndex, file, MAX_TIME_INDEXER); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); 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); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::MyClass()"); checkTreeNode(tree, 0, 0, "heap()"); } @@ -349,13 +347,13 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void _testDestructor_156669() throws Exception { String content = readTaggedComment("testConstructor"); IFile file= createFile(getProject(), "testConstructor.cpp", content); - waitForIndexer(fIndex, file, MAX_TIME_INDEXER); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); 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); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::~MyClass()"); checkTreeNode(tree, 0, 0, "heap()"); } @@ -385,13 +383,13 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testNamespace() throws Exception { String content = readTaggedComment("testNamespace"); IFile file= createFile(getProject(), "testNamespace.cpp", content); - waitForIndexer(fIndex, file, MAX_TIME_INDEXER); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); 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); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "ns::var"); checkTreeNode(tree, 0, 0, "gfunc1()"); checkTreeNode(tree, 0, 1, "gfunc2()"); @@ -443,13 +441,13 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest { public void testNamespacePart2_156519() throws Exception { String content = readTaggedComment("testNamespace"); IFile file= createFile(getProject(), "testNamespace.cpp", content); - waitForIndexer(fIndex, file, MAX_TIME_INDEXER); + waitForIndexer(fIndex, file, CallHierarchyBaseTest.INDEXER_WAIT_TIME); 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); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "ns::var"); checkTreeNode(tree, 0, 0, "gfunc1()"); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAccrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAccrossProjectsTest.java new file mode 100644 index 00000000000..8023e5d32be --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAccrossProjectsTest.java @@ -0,0 +1,307 @@ +/******************************************************************************* + * 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.callhierarchy; + +import junit.framework.Test; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.viewers.TreeViewer; +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 CallHierarchyAccrossProjectsTest extends CallHierarchyBaseTest { + + private ICProject fCProject2; + + public CallHierarchyAccrossProjectsTest(String name) { + super(name); + } + + public static Test suite() { + return suite(CallHierarchyAccrossProjectsTest.class); + } + + protected void setUp() throws Exception { + super.setUp(); + + fCProject2= CProjectHelper.createCCProject("__chTest_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(); + } + + // // testMethods.h + // class MyClass { + // public: + // void method(); + // void inline_method() { + // method(); // r1 + // inline_method(); // r1 + // } + // }; + + // // testMethods.cpp + // #include "testMethods.h" + // void MyClass::method() { + // method(); // r2 + // inline_method(); // r2 + // } + // + // void func() { + // MyClass m, *n; + // m.method(); // r3 + // n->inline_method(); // r3 + // } + public void testMethods() throws Exception { + StringBuffer[] content= getContentsForTest(2); + String header= content[0].toString(); + String source = content[1].toString(); + IFile headerFile= createFile(fCProject.getProject(), "testMethods.h", header); + IFile sourceFile= createFile(fCProject2.getProject(), "testMethods.cpp", source); + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + CEditor editor= (CEditor) IDE.openEditor(page, sourceFile); + waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + + editor.selectAndReveal(source.indexOf("method"), 2); + openCallHierarchy(editor, true); + Tree tree = getCHTreeViewer().getTree(); + + checkTreeNode(tree, 0, "MyClass::method()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); + + editor.selectAndReveal(source.indexOf("method(); // r2"), 2); + openCallHierarchy(editor); + + checkTreeNode(tree, 0, "MyClass::method()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); + + editor.selectAndReveal(source.indexOf("inline_method(); // r2"), 2); + openCallHierarchy(editor); + checkTreeNode(tree, 0, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); + + editor.selectAndReveal(source.indexOf("method(); // r3"), 2); + openCallHierarchy(editor); + checkTreeNode(tree, 0, "MyClass::method()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); + + editor.selectAndReveal(source.indexOf("inline_method(); // r3"), 2); + openCallHierarchy(editor); + checkTreeNode(tree, 0, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); + } + + + // // testMethods.h + // class MyClass { + // public: + // void method1(); + // void method2(); + // void method3(); + // }; + + // // testMethods1.cpp + // #include "testMethods.h" + // void MyClass::method1() { + // method2(); + // } + // void MyClass::method3() { + // } + + // // testMethods2.cpp + // #include "testMethods.h" + // void MyClass::method2() { + // method3(); + // } + public void testMethodsInMultipleFiles() throws Exception { + StringBuffer[] content= getContentsForTest(3); + String header= content[0].toString(); + String source1 = content[1].toString(); + String source2 = content[2].toString(); + IFile headerFile= createFile(fCProject.getProject(), "testMethods.h", header); + IFile sourceFile1= createFile(fCProject.getProject(), "testMethods1.cpp", source1); + IFile sourceFile2= createFile(fCProject2.getProject(), "testMethods2.cpp", source2); + + CEditor editor= openFile(sourceFile1); + waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + + editor.selectAndReveal(source1.indexOf("method3"), 2); + openCallHierarchy(editor); + TreeViewer tv = getCHTreeViewer(); + + TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()"); + TreeItem nextItem= checkTreeNode(item, 0, "MyClass::method2()"); + checkTreeNode(item, 1, null); item= nextItem; + tv.setExpandedState(item.getData(), true); + nextItem= checkTreeNode(item, 0, "MyClass::method1()"); + checkTreeNode(item, 1, null); item= nextItem; + tv.setExpandedState(item.getData(), true); + checkTreeNode(item, 0, null); + } + + // // testMethods.h + // class MyClass { + // public: + // void method1(); + // void method2(); + // void method3(); + // }; + + // // testMethods1.cpp + // #include "testMethods.h" + // void MyClass::method1() { + // method2(); + // } + // void MyClass::method3() { + // } + + // // testMethods2.cpp + // #include "testMethods.h" + // void MyClass::method2() { + // method3(); + // } + // void MyClass::method1() { + // method3(); + // } + public void testMultipleImplsForMethod() throws Exception { + StringBuffer[] content= getContentsForTest(3); + String header= content[0].toString(); + String source1 = content[1].toString(); + String source2 = content[2].toString(); + IFile headerFile= createFile(getProject(), "testMethods.h", header); + IFile sourceFile1= createFile(fCProject2.getProject(), "testMethods1.cpp", source1); + IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); + + CEditor editor= openFile(sourceFile1); + waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + + editor.selectAndReveal(source1.indexOf("method3"), 2); + openCallHierarchy(editor); + TreeViewer tv = getCHTreeViewer(); + + TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()"); + TreeItem item0= checkTreeNode(item, 0, "MyClass::method1()"); + TreeItem item1= checkTreeNode(item, 1, "MyClass::method2()"); + checkTreeNode(item, 2, null); item= null; + + // method 1 + tv.setExpandedState(item0.getData(), true); + checkTreeNode(item0, 0, null); + + // method 2 + tv.setExpandedState(item1.getData(), true); + TreeItem nextItem= checkTreeNode(item1, 0, "MyClass::method1()"); + checkTreeNode(item1, 1, null); item1= nextItem; + tv.setExpandedState(item1.getData(), true); + checkTreeNode(item1, 0, null); + } + + // // testMethods.h + // class MyClass { + // public: + // void method1(); + // void method2(); + // void method3(); + // }; + + // // testMethods1.cpp + // #include "testMethods.h" + // void MyClass::method1() { + // method2(); + // } + // void MyClass::method3() { + // } + + // // testMethods2.cpp + // #include "testMethods.h" + // void MyClass::method1() { + // method3(); + // } + // void MyClass::method2() { + // } + // void main() { + // MyClass mc; + // mc.method1(); + // } + public void testReverseMultipleImplsForMethod() throws Exception { + StringBuffer[] content= getContentsForTest(3); + String header= content[0].toString(); + String source1 = content[1].toString(); + String source2 = content[2].toString(); + IFile headerFile= createFile(getProject(), "testMethods.h", header); + IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1); + IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); + + CEditor editor= openFile(sourceFile2); + waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + + editor.selectAndReveal(source2.indexOf("main"), 2); + openCallHierarchy(editor, false); + TreeViewer tv = getCHTreeViewer(); + + TreeItem item= checkTreeNode(tv.getTree(), 0, "main()"); + TreeItem nextItem= checkTreeNode(item, 0, "MyClass::method1()"); + checkTreeNode(item, 1, null); item= nextItem; + tv.setExpandedState(item.getData(), true); + + TreeItem item0= checkTreeNode(item, 0, "MyClass::method1()"); + TreeItem item1= checkTreeNode(item, 1, "MyClass::method1()"); + checkTreeNode(item, 2, null); item= null; + + // method 1 + tv.setExpandedState(item0.getData(), true); + nextItem= checkTreeNode(item0, 0, "MyClass::method2()"); + checkTreeNode(item0, 1, null); item0= nextItem; + tv.setExpandedState(item0.getData(), true); + checkTreeNode(item0, 0, null); + + // method 2 + tv.setExpandedState(item1.getData(), true); + nextItem= checkTreeNode(item1, 0, "MyClass::method3()"); + checkTreeNode(item1, 1, null); item1= nextItem; + tv.setExpandedState(item1.getData(), true); + checkTreeNode(item1, 0, null); + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java index 693e2af946c..b4a8e8d1dec 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java @@ -11,12 +11,17 @@ package org.eclipse.cdt.ui.tests.callhierarchy; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWTException; 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; @@ -35,75 +40,135 @@ import org.eclipse.cdt.internal.ui.editor.CEditor; public class CallHierarchyBaseTest extends BaseUITestCase { protected static final int INDEXER_WAIT_TIME = 8000; - private ICProject fCProject; + protected ICProject fCProject; protected IIndex fIndex; public CallHierarchyBaseTest(String name) { super(name); } - protected void setUp() throws CoreException { + protected void setUp() throws Exception { + super.setUp(); fCProject= CProjectHelper.createCCProject("__chTest__", "bin", IPDOMManager.ID_FAST_INDEXER); CCoreInternals.getPDOMManager().reindex(fCProject); fIndex= CCorePlugin.getIndexManager().getIndex(fCProject); } - protected void tearDown() throws CoreException { + 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 openCallHierarchy(CEditor editor) { CallHierarchyUI.setIsJUnitTest(true); CallHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection()); runEventQueue(200); } - protected Tree getCHTree(IWorkbenchPage page) { + protected void openCallHierarchy(CEditor editor, boolean showReferencedBy) { + CallHierarchyUI.setIsJUnitTest(true); + CallHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection()); + runEventQueue(200); + CHViewPart ch= null; + IWorkbenchPage page = editor.getSite().getPage(); + for (int i = 0; i < 20; i++) { + ch= (CHViewPart)page.findView(CUIPlugin.ID_CALL_HIERARCHY); + if (ch != null) + break; + runEventQueue(200); + } + assertNotNull(ch); + ch.onSetShowReferencedBy(showReferencedBy); + } + + protected TreeViewer getCHTreeViewer() { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); runEventQueue(0); CHViewPart ch= (CHViewPart)page.findView(CUIPlugin.ID_CALL_HIERARCHY); assertNotNull(ch); - Tree tree= ch.getTreeViewer().getTree(); - return tree; + return ch.getTreeViewer(); } - protected void checkTreeNode(Tree tree, int i0, String label) { + protected TreeItem checkTreeNode(Tree tree, int i0, String label) { TreeItem root= null; try { for (int i=0; i<20; i++) { root= tree.getItem(i0); - if (!"...".equals(root.getText())) { - break; + try { + if (!"...".equals(root.getText())) { + break; + } + } catch (SWTException e) { + // in case widget was disposed, item may be replaced } runEventQueue(50); } } catch (IllegalArgumentException e) { - assertTrue("Tree node " + label + "{" + i0 + "} does not exist!", false); + fail("Tree node " + label + "{" + i0 + "} does not exist!"); } assertEquals(label, root.getText()); + return root; } - protected void checkTreeNode(Tree tree, int i0, int i1, String label) { + protected TreeItem checkTreeNode(Tree tree, int i0, int i1, String label) { + TreeItem item= null; try { TreeItem root= tree.getItem(i0); - TreeItem item= root.getItem(i1); for (int i=0; i<40; i++) { - if (!"...".equals(item.getText())) { - break; + item= root.getItem(i1); + try { + if (!"...".equals(item.getText())) { + break; + } + } catch (SWTException e) { + // in case widget was disposed, item may be replaced } runEventQueue(50); } - assertEquals(label, item.getText()); } catch (IllegalArgumentException e) { - assertTrue("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!", false); + 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; + } + } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyTestSuite.java index ca47b9a9cb3..23623b6dbd1 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyTestSuite.java @@ -24,5 +24,7 @@ public class CallHierarchyTestSuite extends TestSuite { addTest(BasicCallHierarchyTest.suite()); addTest(BasicCppCallHierarchyTest.suite()); addTest(InitializersInCallHierarchyTest.suite()); + addTest(CppCallHierarchyTest.suite()); + addTest(CallHierarchyAccrossProjectsTest.suite()); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java index 8b5217169f6..c0ac66a7b0d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java @@ -14,7 +14,9 @@ package org.eclipse.cdt.ui.tests.callhierarchy; import junit.framework.Test; import org.eclipse.core.resources.IFile; +import org.eclipse.jface.viewers.TreeViewer; 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; @@ -24,8 +26,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor; public class CppCallHierarchyTest extends CallHierarchyBaseTest { - private static final int MAX_TIME_INDEXER = 1000; - public CppCallHierarchyTest(String name) { super(name); } @@ -34,7 +34,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { return suite(CppCallHierarchyTest.class); } - // {testMethods.h} + // // testMethods.h // class MyClass { // public: // void method(); @@ -44,7 +44,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // } // }; - // {testMethods.cpp} + // // testMethods.cpp // #include "testMethods.h" // void MyClass::method() { // method(); // r2 @@ -56,51 +56,225 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // m.method(); // r3 // n->inline_method(); // r3 // } - public void _testMethods() throws Exception { - String header= readTaggedComment("testMethods.h"); + public void testMethods() throws Exception { + StringBuffer[] content= getContentsForTest(2); + String header= content[0].toString(); + String source = content[1].toString(); IFile headerFile= createFile(getProject(), "testMethods.h", header); - String source = readTaggedComment("testMethods.cpp"); IFile sourceFile= createFile(getProject(), "testMethods.cpp", source); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); CEditor editor= (CEditor) IDE.openEditor(page, sourceFile); - waitForIndexer(fIndex, sourceFile, MAX_TIME_INDEXER); + waitForIndexer(fIndex, sourceFile, CallHierarchyBaseTest.INDEXER_WAIT_TIME); editor.selectAndReveal(source.indexOf("method"), 2); openCallHierarchy(editor); - Tree tree= getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "MyClass::method()"); - checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); - checkTreeNode(tree, 0, 1, "MyClass::method()"); - checkTreeNode(tree, 0, 2, "func()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); editor.selectAndReveal(source.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()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); editor.selectAndReveal(source.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()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); editor.selectAndReveal(source.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()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); editor.selectAndReveal(source.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()"); + checkTreeNode(tree, 0, 0, "func()"); + checkTreeNode(tree, 0, 1, "MyClass::inline_method()"); + checkTreeNode(tree, 0, 2, "MyClass::method()"); } + + + // // testMethods.h + // class MyClass { + // public: + // void method1(); + // void method2(); + // void method3(); + // }; + + // // testMethods1.cpp + // #include "testMethods.h" + // void MyClass::method1() { + // method2(); + // } + // void MyClass::method3() { + // } + + // // testMethods2.cpp + // #include "testMethods.h" + // void MyClass::method2() { + // method3(); + // } + public void testMethodsInMultipleFiles() throws Exception { + StringBuffer[] content= getContentsForTest(3); + String header= content[0].toString(); + String source1 = content[1].toString(); + String source2 = content[2].toString(); + IFile headerFile= createFile(getProject(), "testMethods.h", header); + IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1); + IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); + + CEditor editor= openFile(sourceFile1); + waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + + editor.selectAndReveal(source1.indexOf("method3"), 2); + openCallHierarchy(editor); + TreeViewer tv = getCHTreeViewer(); + + TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()"); + TreeItem nextItem= checkTreeNode(item, 0, "MyClass::method2()"); + checkTreeNode(item, 1, null); item= nextItem; + tv.setExpandedState(item.getData(), true); + nextItem= checkTreeNode(item, 0, "MyClass::method1()"); + checkTreeNode(item, 1, null); item= nextItem; + tv.setExpandedState(item.getData(), true); + checkTreeNode(item, 0, null); + } + + // // testMethods.h + // class MyClass { + // public: + // void method1(); + // void method2(); + // void method3(); + // }; + + // // testMethods1.cpp + // #include "testMethods.h" + // void MyClass::method1() { + // method2(); + // } + // void MyClass::method3() { + // } + + // // testMethods2.cpp + // #include "testMethods.h" + // void MyClass::method2() { + // method3(); + // } + // void MyClass::method1() { + // method3(); + // } + public void testMultipleImplsForMethod() throws Exception { + StringBuffer[] content= getContentsForTest(3); + String header= content[0].toString(); + String source1 = content[1].toString(); + String source2 = content[2].toString(); + IFile headerFile= createFile(getProject(), "testMethods.h", header); + IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1); + IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); + + CEditor editor= openFile(sourceFile1); + waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + + editor.selectAndReveal(source1.indexOf("method3"), 2); + openCallHierarchy(editor); + TreeViewer tv = getCHTreeViewer(); + + TreeItem item= checkTreeNode(tv.getTree(), 0, "MyClass::method3()"); + TreeItem item0= checkTreeNode(item, 0, "MyClass::method1()"); + TreeItem item1= checkTreeNode(item, 1, "MyClass::method2()"); + checkTreeNode(item, 2, null); item= null; + + // method 1 + tv.setExpandedState(item0.getData(), true); + checkTreeNode(item0, 0, null); + + // method 2 + tv.setExpandedState(item1.getData(), true); + TreeItem nextItem= checkTreeNode(item1, 0, "MyClass::method1()"); + checkTreeNode(item1, 1, null); item1= nextItem; + tv.setExpandedState(item1.getData(), true); + checkTreeNode(item1, 0, null); + } + + // // testMethods.h + // class MyClass { + // public: + // void method1(); + // void method2(); + // void method3(); + // }; + + // // testMethods1.cpp + // #include "testMethods.h" + // void MyClass::method1() { + // method2(); + // } + // void MyClass::method3() { + // } + + // // testMethods2.cpp + // #include "testMethods.h" + // void MyClass::method1() { + // method3(); + // } + // void MyClass::method2() { + // } + // void main() { + // MyClass mc; + // mc.method1(); + // } + public void testReverseMultipleImplsForMethod() throws Exception { + StringBuffer[] content= getContentsForTest(3); + String header= content[0].toString(); + String source1 = content[1].toString(); + String source2 = content[2].toString(); + IFile headerFile= createFile(getProject(), "testMethods.h", header); + IFile sourceFile1= createFile(getProject(), "testMethods1.cpp", source1); + IFile sourceFile2= createFile(getProject(), "testMethods2.cpp", source2); + + CEditor editor= openFile(sourceFile2); + waitForIndexer(fIndex, sourceFile2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); + + editor.selectAndReveal(source2.indexOf("main"), 2); + openCallHierarchy(editor, false); + TreeViewer tv = getCHTreeViewer(); + + TreeItem item= checkTreeNode(tv.getTree(), 0, "main()"); + TreeItem nextItem= checkTreeNode(item, 0, "MyClass::method1()"); + checkTreeNode(item, 1, null); item= nextItem; + tv.setExpandedState(item.getData(), true); + + TreeItem item0= checkTreeNode(item, 0, "MyClass::method1()"); + TreeItem item1= checkTreeNode(item, 1, "MyClass::method1()"); + checkTreeNode(item, 2, null); item= null; + + // method 1 + tv.setExpandedState(item0.getData(), true); + nextItem= checkTreeNode(item0, 0, "MyClass::method2()"); + checkTreeNode(item0, 1, null); item0= nextItem; + tv.setExpandedState(item0.getData(), true); + checkTreeNode(item0, 0, null); + + // method 2 + tv.setExpandedState(item1.getData(), true); + nextItem= checkTreeNode(item1, 0, "MyClass::method3()"); + checkTreeNode(item1, 1, null); item1= nextItem; + tv.setExpandedState(item1.getData(), true); + checkTreeNode(item1, 0, null); + } + } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java index cb082eaa63b..1a11b6f263f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/InitializersInCallHierarchyTest.java @@ -15,9 +15,6 @@ import junit.framework.Test; import org.eclipse.core.resources.IFile; import org.eclipse.swt.widgets.Tree; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -38,12 +35,11 @@ public class InitializersInCallHierarchyTest extends CallHierarchyBaseTest { String content = readTaggedComment("intvar"); IFile file= createFile(getProject(), "intvar.c", content); waitForIndexer(fIndex, file, INDEXER_WAIT_TIME); - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - CEditor editor= (CEditor) IDE.openEditor(page, file); + CEditor editor = openFile(file); editor.selectAndReveal(content.indexOf("a"), 5); openCallHierarchy(editor); - Tree tree = getCHTree(page); + Tree tree = getCHTreeViewer().getTree(); checkTreeNode(tree, 0, "a"); checkTreeNode(tree, 0, 0, "{init b}()"); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java index d94a60dca7a..e6a9024df3f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java @@ -645,7 +645,7 @@ public class CHViewPart extends ViewPart { fContentProvider.setWorkingSetFilter(filterUI); } - protected void onSetShowReferencedBy(boolean showReferencedBy) { + public void onSetShowReferencedBy(boolean showReferencedBy) { if (showReferencedBy != fContentProvider.getComputeReferencedBy()) { Object input= fTreeViewer.getInput(); fTreeViewer.setInput(null);