Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2011-04-18 12:11:23 -0400
committerMarc-Andre Laperle2011-04-18 12:11:23 -0400
commiteb7b3490138dbf4d9d5ca5b4f4950c53d3254e49 (patch)
tree1572f9e47a822701d82610fa0f64e0c9b0115e08 /core/org.eclipse.cdt.ui.tests
parent3cf16d06a7610bdb4943d6d9475efce66abdfa3a (diff)
downloadorg.eclipse.cdt-eb7b3490138dbf4d9d5ca5b4f4950c53d3254e49.tar.gz
org.eclipse.cdt-eb7b3490138dbf4d9d5ca5b4f4950c53d3254e49.tar.xz
org.eclipse.cdt-eb7b3490138dbf4d9d5ca5b4f4950c53d3254e49.zip
Bug 292851 - [performance] Source->Implement Method were defined throughout a class hierarchy takes too long
Diffstat (limited to 'core/org.eclipse.cdt.ui.tests')
-rw-r--r--core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts8
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java51
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/DefinitionFinderTest.java2
3 files changed, 36 insertions, 25 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts
index ad0fb7421e..ba804a149a 100644
--- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts
+++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts
@@ -2,6 +2,7 @@
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
+infos=1
//@A.h
class X {
public:
@@ -24,6 +25,7 @@ inline bool X::a(int int1) const
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
+infos=1
//@A.h
class X {
public:
@@ -46,6 +48,7 @@ inline bool X::xy(int int1, int i) const
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
+infos=1
//@A.h
template<class T> class A
{
@@ -76,6 +79,7 @@ template<class T> inline void A<T>::test()
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
+infos=1
//@A.h
template<class T> class A
{
@@ -137,6 +141,7 @@ void Demo::SubClass::test()
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
+infos=1
//@A.h
class A
{
@@ -431,6 +436,7 @@ int A::foo(int param1, int param2)
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
+infos=1
//@A.h
class A
{
@@ -581,6 +587,7 @@ namespace OuterSpace {
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
+infos=1
//@A.h
template<class T, class U> class A
{
@@ -714,6 +721,7 @@ void Test::doNothing(void)
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=TestClass.h
+infos=1
//@TestClass.h
#ifndef TESTCLASS_H_
#define TESTCLASS_H_
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java
index 49fc46dab9..9d5d147179 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Institute for Software - initial API and implementation
+ * Marc-Andre Laperle
*******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.implementmethod;
@@ -18,10 +19,12 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest;
import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile;
-import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring2;
import org.eclipse.cdt.internal.ui.refactoring.implementmethod.ImplementMethodRefactoring;
/**
@@ -30,6 +33,7 @@ import org.eclipse.cdt.internal.ui.refactoring.implementmethod.ImplementMethodRe
public class ImplementMethodRefactoringTest extends RefactoringTest {
protected int finalWarnings;
private int initialWarnings;
+ private int infos;
public ImplementMethodRefactoringTest(String name, Collection<TestSourceFile> files) {
super(name, files);
@@ -38,37 +42,36 @@ public class ImplementMethodRefactoringTest extends RefactoringTest {
@Override
protected void runTest() throws Throwable {
IFile refFile = project.getFile(fileName);
- CRefactoring refactoring = new ImplementMethodRefactoring(refFile, selection, null, cproject);
-
- try {
- refactoring.lockIndex();
- RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR);
+ ICElement element = CoreModel.getDefault().create(refFile);
+ CRefactoring2 refactoring = new ImplementMethodRefactoring(element, selection, cproject, astCache);
+ RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR);
- if(initialWarnings == 0) {
- assertConditionsOk(checkInitialConditions);
- } else {
- assertConditionsFatalError(checkInitialConditions, initialWarnings);
- return;
- }
+ if (initialWarnings == 0) {
+ assertConditionsOk(checkInitialConditions);
+ } else {
+ assertConditionsFatalError(checkInitialConditions, initialWarnings);
+ return;
+ }
- refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR);
- RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR);
- if (finalWarnings == 0) {
- Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR);
- assertConditionsOk(finalConditions);
- createChange.perform(NULL_PROGRESS_MONITOR);
- } else {
- assertConditionsWarning(finalConditions, finalWarnings);
- }
- compareFiles(fileMap);
- } finally {
- refactoring.unlockIndex();
+ RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR);
+ Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR);
+
+ if (finalWarnings > 0) {
+ assertConditionsWarning(finalConditions, finalWarnings);
+ } else if (infos > 0) {
+ assertConditionsInfo(finalConditions, infos);
+ } else {
+ assertConditionsOk(finalConditions);
}
+
+ createChange.perform(NULL_PROGRESS_MONITOR);
+ compareFiles(fileMap);
}
@Override
protected void configureRefactoring(Properties refactoringProperties) {
finalWarnings = new Integer(refactoringProperties.getProperty("finalWarnings", "0")).intValue(); //$NON-NLS-1$//$NON-NLS-2$
initialWarnings = Integer.parseInt(refactoringProperties.getProperty("initialWarnings", "0")); //$NON-NLS-1$//$NON-NLS-2$
+ infos = Integer.parseInt(refactoringProperties.getProperty("infos", "0")); //$NON-NLS-1$//$NON-NLS-2$
}
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/DefinitionFinderTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/DefinitionFinderTest.java
index d5ef5cf515..ec4d06b093 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/DefinitionFinderTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/utils/DefinitionFinderTest.java
@@ -44,7 +44,7 @@ public class DefinitionFinderTest extends RefactoringTest {
IASTTranslationUnit ast = astCache.getAST((ITranslationUnit) element, null);
for (IASTDeclaration declaration : ast.getDeclarations()) {
if (declaration instanceof IASTSimpleDeclaration) {
- assertNotNull(DefinitionFinder2.getDefinition((IASTSimpleDeclaration) declaration, astCache));
+ assertNotNull(DefinitionFinder2.getDefinition((IASTSimpleDeclaration) declaration, astCache, NULL_PROGRESS_MONITOR));
}
}
}

Back to the top