diff --git a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF index a61944f81ba..6e839c4ba05 100644 --- a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF @@ -13,7 +13,7 @@ Export-Package: org.eclipse.cdt.ui.testplugin, org.eclipse.cdt.ui.tests.chelp, org.eclipse.cdt.ui.tests.text, org.eclipse.cdt.ui.tests.text.contentassist, - org.eclipse.cdt.ui.tests.text.selectiontests + org.eclipse.cdt.ui.tests.text.selection Require-Bundle: org.eclipse.jface.text, org.eclipse.core.resources, org.eclipse.cdt.ui, diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java index 78641d23033..ad7b2c4047d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java @@ -15,58 +15,8 @@ package org.eclipse.cdt.ui.tests; import junit.framework.Test; import junit.framework.TestSuite; -import org.eclipse.cdt.ui.tests.text.CAutoIndentTest; -import org.eclipse.cdt.ui.tests.text.CBreakIteratorTest; -import org.eclipse.cdt.ui.tests.text.CPartitionerTest; -import org.eclipse.cdt.ui.tests.text.CWordIteratorTest; -import org.eclipse.cdt.ui.tests.text.InactiveCodeHighlightingTest; -import org.eclipse.cdt.ui.tests.text.NumberRuleTest; -import org.eclipse.cdt.ui.tests.text.SemanticHighlightingTest; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionFailedTest_MemberReference_Arrow_Prefix2; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_NoPrefix2; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ArgumentType_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ClassReference_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ClassReference_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ConstructorReference; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ExceptionReference_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ExceptionReference_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_FieldType_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_FieldType_NoPrefix2; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_FieldType_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_FunctionReference_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_FunctionReference_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MacroRef_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MacroRef_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Arrow_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Arrow_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Dot_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_MemberReference_Dot_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_NamespaceRef_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_NamespaceRef_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_NewTypeReference_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_NewTypeReference_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ScopedReference_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ScopedReference_NonCodeScope; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_ScopedReference_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_SingleName_Method_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_SingleName_Method_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_SingleName_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_SingleName_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_SingleName_Prefix2; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeDef_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeRef_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_TypeRef_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_NestedPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_NoPrefix; -import org.eclipse.cdt.ui.tests.text.contentassist.CompletionTest_VariableType_Prefix; -import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTests; -import org.eclipse.cdt.ui.tests.text.selectiontests.CPPSelectionTestsCTagsIndexer; -import org.eclipse.cdt.ui.tests.text.selectiontests.CPPSelectionTestsDOMIndexer; -import org.eclipse.cdt.ui.tests.text.selectiontests.CPPSelectionTestsNoIndexer; -import org.eclipse.cdt.ui.tests.text.selectiontests.CSelectionTestsCTagsIndexer; -import org.eclipse.cdt.ui.tests.text.selectiontests.CSelectionTestsDOMIndexer; -import org.eclipse.cdt.ui.tests.text.selectiontests.CSelectionTestsNoIndexer; +import org.eclipse.cdt.ui.tests.text.TextTestSuite; +import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite; import org.eclipse.cdt.ui.tests.viewsupport.ViewSupportTestSuite; /** @@ -87,75 +37,22 @@ public class AutomatedSuite extends TestSuite { */ public AutomatedSuite() { - // Success Tests - //addTest(PartitionTokenScannerTest.suite()); - addTest(NumberRuleTest.suite()); - addTest(CAutoIndentTest.suite()); - addTest(CPartitionerTest.suite()); - - // completion tests - addTest(CompletionTest_FieldType_Prefix.suite()); - addTest(CompletionTest_FieldType_NoPrefix.suite()); - addTest(CompletionTest_FieldType_NoPrefix2.suite()); - addTest(CompletionTest_VariableType_Prefix.suite()); - addTest(CompletionTest_VariableType_NoPrefix.suite()); - addTest(CompletionTest_ArgumentType_NoPrefix.suite()); - addTest(CompletionTest_ArgumentType_NoPrefix2.suite()); - addTest(CompletionTest_ArgumentType_Prefix.suite()); - addTest(CompletionTest_ArgumentType_NoPrefix2.suite()); - addTest(CompletionTest_SingleName_Method_Prefix.suite()); - addTest(CompletionTest_SingleName_Method_NoPrefix.suite()); - addTest(CompletionTest_SingleName_Prefix.suite()); - addTest(CompletionTest_SingleName_Prefix2.suite()); - addTest(CompletionTest_SingleName_NoPrefix.suite()); - addTest(CompletionTest_MemberReference_Dot_Prefix.suite()); - addTest(CompletionTest_MemberReference_Dot_NoPrefix.suite()); - addTest(CompletionTest_MemberReference_Arrow_Prefix.suite()); - addTest(CompletionTest_MemberReference_Arrow_NoPrefix.suite()); - addTest(CompletionTest_NamespaceRef_Prefix.suite()); - addTest(CompletionTest_NamespaceRef_NoPrefix.suite()); - addTest(CompletionTest_TypeRef_NoPrefix.suite()); - addTest(CompletionTest_TypeRef_Prefix.suite()); - addTest(CompletionTest_ClassReference_NoPrefix.suite()); - addTest(CompletionTest_ClassReference_Prefix.suite()); - addTest(CompletionTest_NewTypeReference_NoPrefix.suite()); - addTest(CompletionTest_NewTypeReference_Prefix.suite()); - addTest(CompletionTest_ExceptionReference_NoPrefix.suite()); - addTest(CompletionTest_ExceptionReference_Prefix.suite()); - addTest(CompletionTest_FunctionReference_Prefix.suite()); - addTest(CompletionTest_ScopedReference_NoPrefix.suite()); - addTest(CompletionTest_ScopedReference_Prefix.suite()); - addTest(CompletionTest_ScopedReference_NonCodeScope.suite()); - addTest(CompletionTest_MacroRef_NoPrefix.suite()); - addTest(CompletionTest_MacroRef_Prefix.suite()); - addTest(CompletionTest_FunctionReference_NoPrefix.suite()); - addTest(CompletionTest_ConstructorReference.suite()); - addTest(CompletionTest_TypeDef_NoPrefix.suite()); - addTest(CompletionTest_VariableType_NestedPrefix.suite()); - - addTest( ContentAssistTests.suite() ); - - // Failed Tests - addTest(CompletionFailedTest_MemberReference_Arrow_Prefix2.suite()); - - // selection tests - addTest( CPPSelectionTestsNoIndexer.suite() ); - addTest( CSelectionTestsNoIndexer.suite() ); - addTest( CPPSelectionTestsDOMIndexer.suite() ); - addTest( CSelectionTestsDOMIndexer.suite() ); - addTest( CPPSelectionTestsCTagsIndexer.suite() ); - addTest( CSelectionTestsCTagsIndexer.suite() ); + // tests from package org.eclipse.cdt.ui.tests.text + addTest(TextTestSuite.suite()); - // Break iterator tests. - addTest(CBreakIteratorTest.suite()); - addTest(CWordIteratorTest.suite()); - - // highlighting tests - addTest(SemanticHighlightingTest.suite()); - addTest(InactiveCodeHighlightingTest.suite()); - // tests for package viewsupport addTest(ViewSupportTestSuite.suite()); + + // tests from package org.eclipse.cdt.ui.tests.text.contentAssist + addTest(ContentAssistTestSuite.suite()); + + // tests from package org.eclipse.cdt.ui.tests.text.contentAssist2 + // commented out because they are failing pretty badly + // addTest(ContentAssist2TestSuite.suite()); + + // tests from package org.eclipse.cdt.ui.tests.text.selection + // commented out because they are failing pretty badly + // addTest(SelectionTestSuite.suite()); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TextTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TextTestSuite.java new file mode 100644 index 00000000000..b98e432d47b --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TextTestSuite.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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; + +import junit.framework.TestSuite; + +public class TextTestSuite extends TestSuite { + + public static TestSuite suite() { + return new TextTestSuite(); + } + + public TextTestSuite() { + super("Tests in package org.eclipse.cdt.ui.tests.text.text"); + + // Success Tests + //addTest(PartitionTokenScannerTest.suite()); + addTest(NumberRuleTest.suite()); + addTest(CAutoIndentTest.suite()); + addTest(CPartitionerTest.suite()); + + // Break iterator tests. + addTest(CBreakIteratorTest.suite()); + addTest(CWordIteratorTest.suite()); + + // highlighting tests + addTest(SemanticHighlightingTest.suite()); + addTest(InactiveCodeHighlightingTest.suite()); + + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java new file mode 100644 index 00000000000..b6f599c92fa --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTestSuite.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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.contentassist; + +import junit.framework.TestSuite; + +public class ContentAssistTestSuite extends TestSuite { + + public static TestSuite suite() { + return new ContentAssistTestSuite(); + } + + public ContentAssistTestSuite() { + super("Tests in package org.eclipse.cdt.ui.tests.text.contentassist"); + + // completion tests + addTest(CompletionTest_FieldType_Prefix.suite()); + addTest(CompletionTest_FieldType_NoPrefix.suite()); + addTest(CompletionTest_FieldType_NoPrefix2.suite()); + addTest(CompletionTest_VariableType_Prefix.suite()); + addTest(CompletionTest_VariableType_NoPrefix.suite()); + addTest(CompletionTest_ArgumentType_NoPrefix.suite()); + addTest(CompletionTest_ArgumentType_NoPrefix2.suite()); + addTest(CompletionTest_ArgumentType_Prefix.suite()); + addTest(CompletionTest_ArgumentType_NoPrefix2.suite()); + addTest(CompletionTest_SingleName_Method_Prefix.suite()); + addTest(CompletionTest_SingleName_Method_NoPrefix.suite()); + addTest(CompletionTest_SingleName_Prefix.suite()); + addTest(CompletionTest_SingleName_Prefix2.suite()); + addTest(CompletionTest_SingleName_NoPrefix.suite()); + addTest(CompletionTest_MemberReference_Dot_Prefix.suite()); + addTest(CompletionTest_MemberReference_Dot_NoPrefix.suite()); + addTest(CompletionTest_MemberReference_Arrow_Prefix.suite()); + addTest(CompletionTest_MemberReference_Arrow_NoPrefix.suite()); + addTest(CompletionTest_NamespaceRef_Prefix.suite()); + addTest(CompletionTest_NamespaceRef_NoPrefix.suite()); + addTest(CompletionTest_TypeRef_NoPrefix.suite()); + addTest(CompletionTest_TypeRef_Prefix.suite()); + addTest(CompletionTest_ClassReference_NoPrefix.suite()); + addTest(CompletionTest_ClassReference_Prefix.suite()); + addTest(CompletionTest_NewTypeReference_NoPrefix.suite()); + addTest(CompletionTest_NewTypeReference_Prefix.suite()); + addTest(CompletionTest_ExceptionReference_NoPrefix.suite()); + addTest(CompletionTest_ExceptionReference_Prefix.suite()); + addTest(CompletionTest_FunctionReference_Prefix.suite()); + addTest(CompletionTest_ScopedReference_NoPrefix.suite()); + addTest(CompletionTest_ScopedReference_Prefix.suite()); + addTest(CompletionTest_ScopedReference_NonCodeScope.suite()); + addTest(CompletionTest_MacroRef_NoPrefix.suite()); + addTest(CompletionTest_MacroRef_Prefix.suite()); + addTest(CompletionTest_FunctionReference_NoPrefix.suite()); + addTest(CompletionTest_ConstructorReference.suite()); + addTest(CompletionTest_TypeDef_NoPrefix.suite()); + addTest(CompletionTest_VariableType_NestedPrefix.suite()); + + addTest( ContentAssistTests.suite() ); + + // Failed Tests + addTest(CompletionFailedTest_MemberReference_Arrow_Prefix2.suite()); + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssistProcessor2_Suite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssist2TestSuite.java similarity index 93% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssistProcessor2_Suite.java rename to core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssist2TestSuite.java index d6399c38323..53aa8773509 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssistProcessor2_Suite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ContentAssist2TestSuite.java @@ -16,13 +16,15 @@ import junit.framework.TestSuite; /** * This suite bundles all tests for the CContentAssistProcessor2 */ -public class ContentAssistProcessor2_Suite extends TestSuite { +public class ContentAssist2TestSuite extends TestSuite { public static Test suite() { - return new ContentAssistProcessor2_Suite() ; + return new ContentAssist2TestSuite() ; } - public ContentAssistProcessor2_Suite() { + public ContentAssist2TestSuite() { + super("Tests in package org.eclipse.cdt.ui.tests.text.contentassist2"); + addTest(CompletionFailedTest_MemberReference_Arrow_Prefix2.suite()); addTest(CompletionTest_ArgumentType_NoPrefix.suite()); addTest(CompletionTest_ArgumentType_NoPrefix2.suite()); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/BaseSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java similarity index 95% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/BaseSelectionTestsIndexer.java rename to core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java index e5ec77c4e2d..c99d3a1cc4a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/BaseSelectionTestsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java @@ -7,8 +7,9 @@ * * Contributors: * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text.selectiontests; +package org.eclipse.cdt.ui.tests.text.selection; import java.io.ByteArrayInputStream; import java.io.File; @@ -16,17 +17,6 @@ import java.io.InputStream; import junit.framework.TestCase; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.ICDescriptor; -import org.eclipse.cdt.core.ICDescriptorOperation; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.testplugin.FileManager; -import org.eclipse.cdt.internal.core.parser.ParserException; -import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -49,6 +39,22 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AbstractTextEditor; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ICDescriptor; +import org.eclipse.cdt.core.ICDescriptorOperation; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.testplugin.FileManager; + +import org.eclipse.cdt.internal.core.parser.ParserException; + +import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds; +import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction; +import org.eclipse.cdt.internal.ui.search.actions.OpenDefinitionAction; + /** * Base test class for testing Ctrl_F3/F3 with the indexers. * @@ -190,8 +196,8 @@ public class BaseSelectionTestsIndexer extends TestCase { if (part instanceof AbstractTextEditor) { ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length)); - final IAction action = ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$ - action.run(); + final OpenDeclarationsAction action = (OpenDeclarationsAction) ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$ + action.runSync(); // update the file/part to point to the newly opened IFile/IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); @@ -278,8 +284,8 @@ public class BaseSelectionTestsIndexer extends TestCase { if (part instanceof AbstractTextEditor) { ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length)); - final IAction action = ((AbstractTextEditor)part).getAction("OpenDefinition"); //$NON-NLS-1$ - action.run(); + final OpenDefinitionAction action = (OpenDefinitionAction) ((AbstractTextEditor)part).getAction("OpenDefinition"); //$NON-NLS-1$ + action.runSync(); // update the file/part to point to the newly opened IFile/IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); @@ -328,8 +334,8 @@ public class BaseSelectionTestsIndexer extends TestCase { if (part instanceof AbstractTextEditor) { ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length)); - final IAction action = ((AbstractTextEditor)part).getAction("OpenDefinition"); //$NON-NLS-1$ - action.run(); + final OpenDefinitionAction action = (OpenDefinitionAction) ((AbstractTextEditor)part).getAction("OpenDefinition"); //$NON-NLS-1$ + action.runSync(); // update the file/part to point to the newly opened IFile/IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsCTagsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsCTagsIndexer.java similarity index 99% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsCTagsIndexer.java rename to core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsCTagsIndexer.java index 59a543f7bb7..46f263ef34f 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsCTagsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsCTagsIndexer.java @@ -7,8 +7,9 @@ * * Contributors: * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text.selectiontests; +package org.eclipse.cdt.ui.tests.text.selection; import java.io.File; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsDOMIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsDOMIndexer.java similarity index 99% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsDOMIndexer.java rename to core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsDOMIndexer.java index 057158318f5..01c4d5d9fdf 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsDOMIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsDOMIndexer.java @@ -7,8 +7,9 @@ * * Contributors: * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text.selectiontests; +package org.eclipse.cdt.ui.tests.text.selection; import java.io.File; import java.io.StringWriter; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java similarity index 98% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java rename to core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java index 008e229714a..ee62ce39dd0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CPPSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java @@ -7,8 +7,9 @@ * * Contributors: * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text.selectiontests; +package org.eclipse.cdt.ui.tests.text.selection; import java.io.ByteArrayInputStream; import java.io.File; @@ -20,17 +21,6 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.FileManager; -import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -41,7 +31,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelection; @@ -52,6 +41,22 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AbstractTextEditor; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.FileManager; + +import org.eclipse.cdt.internal.core.dom.parser.ASTNode; +import org.eclipse.cdt.internal.core.parser.ParserException; + +import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction; +import org.eclipse.cdt.internal.ui.search.actions.OpenDefinitionAction; + /** * It is required to test the selection performance independent of the indexer to make sure that the DOM is functioning properly. * @@ -222,8 +227,8 @@ public class CPPSelectionTestsNoIndexer extends TestCase { if (part instanceof AbstractTextEditor) { ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length)); - final IAction action = ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$ - action.run(); + final OpenDeclarationsAction action = (OpenDeclarationsAction) ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$ + action.runSync(); // the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU ISelection sel = ((AbstractTextEditor)part).getSelectionProvider().getSelection(); @@ -266,8 +271,8 @@ public class CPPSelectionTestsNoIndexer extends TestCase { if (part instanceof AbstractTextEditor) { ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length)); - final IAction action = ((AbstractTextEditor)part).getAction("OpenDefinition"); //$NON-NLS-1$ - action.run(); + final OpenDefinitionAction action = (OpenDefinitionAction) ((AbstractTextEditor)part).getAction("OpenDefinition"); //$NON-NLS-1$ + action.runSync(); // the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU ISelection sel = ((AbstractTextEditor)part).getSelectionProvider().getSelection(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsCTagsIndexer.java similarity index 99% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java rename to core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsCTagsIndexer.java index 622bf122bde..58499da0417 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsCTagsIndexer.java @@ -7,8 +7,9 @@ * * Contributors: * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text.selectiontests; +package org.eclipse.cdt.ui.tests.text.selection; import java.io.File; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsDOMIndexer.java similarity index 99% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java rename to core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsDOMIndexer.java index d09f9af7fe8..8a28937890d 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsDOMIndexer.java @@ -7,8 +7,9 @@ * * Contributors: * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text.selectiontests; +package org.eclipse.cdt.ui.tests.text.selection; import java.io.File; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java similarity index 98% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsNoIndexer.java rename to core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java index b190dd24479..cd840eaf5ee 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsNoIndexer.java @@ -7,8 +7,9 @@ * * Contributors: * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.ui.tests.text.selectiontests; +package org.eclipse.cdt.ui.tests.text.selection; import java.io.ByteArrayInputStream; import java.io.File; @@ -18,17 +19,6 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.FileManager; -import org.eclipse.cdt.internal.core.dom.parser.ASTNode; -import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -39,7 +29,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; -import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelection; @@ -50,6 +39,22 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AbstractTextEditor; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.FileManager; + +import org.eclipse.cdt.internal.core.dom.parser.ASTNode; +import org.eclipse.cdt.internal.core.parser.ParserException; + +import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction; +import org.eclipse.cdt.internal.ui.search.actions.OpenDefinitionAction; + /** * It is required to test the selection performance independent of the indexer to make sure that the DOM is functioning properly. * @@ -274,8 +279,8 @@ public class CSelectionTestsNoIndexer extends TestCase { if (part instanceof AbstractTextEditor) { ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length)); - final IAction action = ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$ - action.run(); + final OpenDeclarationsAction action = (OpenDeclarationsAction) ((AbstractTextEditor)part).getAction("OpenDeclarations"); //$NON-NLS-1$ + action.runSync(); // the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU ISelection sel = ((AbstractTextEditor)part).getSelectionProvider().getSelection(); @@ -317,8 +322,8 @@ public class CSelectionTestsNoIndexer extends TestCase { if (part instanceof AbstractTextEditor) { ((AbstractTextEditor)part).getSelectionProvider().setSelection(new TextSelection(offset,length)); - final IAction action = ((AbstractTextEditor)part).getAction("OpenDefinition"); //$NON-NLS-1$ - action.run(); + final OpenDefinitionAction action = (OpenDefinitionAction) ((AbstractTextEditor)part).getAction("OpenDefinition"); //$NON-NLS-1$ + action.runSync(); // the action above should highlight the declaration, so now retrieve it and use that selection to get the IASTName selected on the TU ISelection sel = ((AbstractTextEditor)part).getSelectionProvider().getSelection(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/SelectionTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/SelectionTestSuite.java new file mode 100644 index 00000000000..f0d7341471b --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/SelectionTestSuite.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.TestSuite; + +public class SelectionTestSuite extends TestSuite { + + public static TestSuite suite() { + return new SelectionTestSuite(); + } + + public SelectionTestSuite() { + super("Tests in package org.eclipse.cdt.ui.tests.text.selection"); + + // selection tests + addTest( CPPSelectionTestsNoIndexer.suite() ); + addTest( CSelectionTestsNoIndexer.suite() ); + addTest( CPPSelectionTestsDOMIndexer.suite() ); + addTest( CSelectionTestsDOMIndexer.suite() ); + addTest( CPPSelectionTestsCTagsIndexer.suite() ); + addTest( CSelectionTestsCTagsIndexer.suite() ); + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java index 4ae784bbbe7..9b027cadd23 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java @@ -109,11 +109,13 @@ public class AsyncViewerTest extends TestCase { public void testSyncPopulation() { TestDialog dlg = createTestDialog(false); doTestSyncPopulation(dlg); + dlg.close(); } public void testSyncPopulationEx() { TestDialog dlg = createTestDialog(true); doTestSyncPopulation(dlg); + dlg.close(); } private void doTestSyncPopulation(TestDialog dlg) { @@ -159,11 +161,13 @@ public class AsyncViewerTest extends TestCase { public void testAsyncPopulation() throws InterruptedException { TestDialog dlg = createTestDialog(false); doTestAsyncPopulation(dlg); + dlg.close(); } public void testAsyncPopulationEx() throws InterruptedException { TestDialog dlg = createTestDialog(true); doTestAsyncPopulation(dlg); + dlg.close(); } private void doTestAsyncPopulation(TestDialog dlg) throws InterruptedException { @@ -265,6 +269,7 @@ public class AsyncViewerTest extends TestCase { assertEquals(6, countVisibleItems(dlg.fViewer)); assertEquals(1, dlg.fViewer.getTree().getSelectionCount()); assertEquals("c", dlg.fViewer.getTree().getSelection()[0].getText()); + dlg.close(); } private void sleepAndDispatch(int sleep, int count) throws InterruptedException { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/ViewSupportTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/ViewSupportTestSuite.java index e290c64a4c0..8da2e2fd615 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/ViewSupportTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/ViewSupportTestSuite.java @@ -20,7 +20,7 @@ public class ViewSupportTestSuite extends TestSuite { } public ViewSupportTestSuite() { - super("View support tests"); + super("Tests in package org.eclipse.cdt.ui.tests.viewsupport"); addTestSuite(AsyncViewerTest.class); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java index 09bb570d155..1f988ef52d8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.search.actions; @@ -23,6 +24,7 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.text.ITextSelection; @@ -70,7 +72,7 @@ public class OpenDeclarationsAction extends SelectionParseAction { if (binding != null && !(binding instanceof IProblemBinding)) { final IASTName[] declNames = ast.getDeclarations(binding); if (declNames.length > 0) { - Display.getDefault().asyncExec(new Runnable() { + runInUIThread(new Runnable() { public void run() { try { open(declNames[0]); @@ -113,5 +115,25 @@ public class OpenDeclarationsAction extends SelectionParseAction { new Runner().schedule(); } } + + private void runInUIThread(Runnable runnable) { + if (Display.getCurrent() != null) { + runnable.run(); + } + else { + Display.getDefault().asyncExec(runnable); + } + } + + /** + * For the purpose of regression testing. + * @since 4.0 + */ + public void runSync() { + selNode = getSelectedStringFromEditor(); + if (selNode != null) { + new Runner().run(new NullProgressMonitor()); + } + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java index 25682a6a554..8e3ffecf559 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java @@ -7,24 +7,28 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.search.actions; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.swt.widgets.Display; + 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.model.ILanguage; import org.eclipse.cdt.core.model.IWorkingCopy; +import org.eclipse.cdt.ui.CUIPlugin; + import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.CEditorMessages; -import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.swt.widgets.Display; /** * Open Definition Action (Ctrl+F3). @@ -70,7 +74,7 @@ public class OpenDefinitionAction extends SelectionParseAction { if (binding != null) { final IASTName[] declNames = ast.getDefinitions(binding); if (declNames.length > 0) { - Display.getDefault().asyncExec(new Runnable() { + runInUIThread(new Runnable() { public void run() { try { open(declNames[0]); @@ -97,4 +101,28 @@ public class OpenDefinitionAction extends SelectionParseAction { } } + /** + * For the purpose of regression testing. + * @since 4.0 + */ + private void runInUIThread(Runnable runnable) { + if (Display.getCurrent() != null) { + runnable.run(); + } + else { + Display.getDefault().asyncExec(runnable); + } + } + + /** + * For the purpose of regression testing. + * @since 4.0 + */ + public void runSync() { + selNode = getSelectedStringFromEditor(); + if (selNode != null) { + new Runner().run(new NullProgressMonitor()); + } + } + } diff --git a/releng/org.eclipse.cdt.testing/test.xml b/releng/org.eclipse.cdt.testing/test.xml index 034dc46b0bb..f0f4ee03415 100644 --- a/releng/org.eclipse.cdt.testing/test.xml +++ b/releng/org.eclipse.cdt.testing/test.xml @@ -64,7 +64,7 @@ - +