diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java index 5ae5b2344fa..6963b4af42b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java @@ -28,6 +28,7 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.TextSelection; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.Refactoring; +import org.eclipse.ltk.core.refactoring.RefactoringContext; import org.eclipse.ltk.core.refactoring.RefactoringDescriptor; import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy; import org.eclipse.ltk.core.refactoring.RefactoringStatus; @@ -50,7 +51,6 @@ import org.eclipse.cdt.ui.testplugin.CTestPlugin; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContext; -import org.eclipse.cdt.internal.ui.refactoring.RefactoringContext; /** * Common base for refactoring tests. @@ -145,8 +145,6 @@ public abstract class RefactoringTestBase extends BaseTestCase { } protected void assertRefactoringSuccess() throws Exception { - if (historyScript != null) - return; // History tests are temporarily disabled. executeRefactoring(true); compareFiles(); } @@ -217,9 +215,9 @@ public abstract class RefactoringTestBase extends BaseTestCase { for (RefactoringDescriptorProxy proxy : history.getDescriptors()) { RefactoringDescriptor descriptor = proxy.requestDescriptor(NULL_PROGRESS_MONITOR); RefactoringStatus status = new RefactoringStatus(); -// RefactoringContext context = descriptor.createRefactoringContext(status); -// assertTrue(status.isOK()); -// executeRefactoring(context.getRefactoring(), context, false, expectedSuccess); + RefactoringContext context = descriptor.createRefactoringContext(status); + assertTrue(status.isOK()); + executeRefactoring(context.getRefactoring(), context, false, expectedSuccess); } } diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index d5fbc3e8463..cb5ca91c63c 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -103,8 +103,8 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)", org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)", org.eclipse.help;bundle-version="[3.2.0,4.0.0)", org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)", - org.eclipse.ltk.core.refactoring;bundle-version="3.4.0", - org.eclipse.ltk.ui.refactoring;bundle-version="3.4.0", + org.eclipse.ltk.core.refactoring;bundle-version="3.6.0", + org.eclipse.ltk.ui.refactoring;bundle-version="3.6.0", org.eclipse.search;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.3.0,4.0.0)", org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)", diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java index 29f4343c884..9dc38f553c1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContext.java @@ -16,6 +16,7 @@ import java.util.concurrent.ConcurrentHashMap; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.ltk.core.refactoring.RefactoringContext; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java index ddc97b5f9fd..0481355551f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescriptor.java @@ -57,13 +57,13 @@ public abstract class CRefactoringDescriptor extends RefactoringDescriptor { @Override public abstract CRefactoring createRefactoring(RefactoringStatus status) throws CoreException; -// @Override -// public CRefactoringContext createRefactoringContext(RefactoringStatus status) throws CoreException { -// CRefactoring refactoring= createRefactoring(status); -// if (refactoring == null) -// return null; -// return new CRefactoringContext(refactoring); -// } + @Override + public CRefactoringContext createRefactoringContext(RefactoringStatus status) throws CoreException { + CRefactoring refactoring= createRefactoring(status); + if (refactoring == null) + return null; + return new CRefactoringContext(refactoring); + } protected ISelection getSelection() throws CoreException { ISelection selection; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringContext.java deleted file mode 100644 index c52983f2138..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringContext.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Google, 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: - * Sergey Prigogin - [refactoring] Provide a way to implement refactorings that depend on resources that have to be explicitly released - https://bugs.eclipse.org/347599 - * IBM Corporation - bug fixes - *******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring; - -import org.eclipse.ltk.core.refactoring.Refactoring; - -/** - *

- * Refactoring context is a disposable object that can be used by a refactoring to hold resources - * that have to be explicitly released. The refactoring context is guaranteed to receive - * a {@link #dispose()} call after the associated refactoring has finished or produced an error. - * At this point, the refactoring context must release all resources and detach all listeners. - * A refactoring context can only be disposed once; it cannot be reused. - *

- *

- * This class is intended to be subclassed by clients wishing to implement new refactorings that - * depend on resources that have to be explicitly released. - *

- */ -public class RefactoringContext { - private Refactoring fRefactoring; - - /** - * Creates a context for the given refactoring. - * - * @param refactoring The refactoring associated with the context. Cannot be null. - * @throws NullPointerException if refactoring is null. - */ - public RefactoringContext(Refactoring refactoring) { - if (refactoring == null) - throw new NullPointerException(); - fRefactoring= refactoring; - } - - /** - * Returns the refactoring associated with the context. - *

- * The returned refactoring must be in an initialized state, i.e. ready to - * be executed via {@link PerformRefactoringOperation}. - *

- * @return The refactoring associated with the context. - * @nooverride This method is not intended to be re-implemented or extended by clients. - */ - public Refactoring getRefactoring() { - return fRefactoring; - } - - /** - * Disposes of the context. This method will be called exactly once during the life cycle - * of the context after the associated refactoring has finished or produced an error. - *

- * Subclasses may extend this method (must call super). - *

- */ - public void dispose() { - if (fRefactoring == null) - throw new IllegalStateException("dispose() called more than once."); //$NON-NLS-1$ - fRefactoring= null; - } -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java index c9e2d31caa2..52f9e12837b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescriptor.java @@ -40,14 +40,13 @@ public class ExtractConstantRefactoringDescriptor extends CRefactoringDescriptor @Override public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException { - return null; -// ISelection selection = getSelection(); -// ICProject project = getCProject(); -// ExtractConstantRefactoring refactoring = -// new ExtractConstantRefactoring(getTranslationUnit(), selection, project); -// ExtractConstantInfo info = refactoring.getRefactoringInfo(); -// info.setName(arguments.get(NAME)); -// info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY))); -// return refactoring; + ISelection selection = getSelection(); + ICProject project = getCProject(); + ExtractConstantRefactoring refactoring = + new ExtractConstantRefactoring(getTranslationUnit(), selection, project); + ExtractConstantInfo info = refactoring.getRefactoringInfo(); + info.setName(arguments.get(NAME)); + info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY))); + return refactoring; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java index a0a78c91551..92a03a90c54 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescriptor.java @@ -41,15 +41,14 @@ public class ExtractFunctionRefactoringDescriptor extends CRefactoringDescriptor @Override public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException { - return null; -// ISelection selection = getSelection(); -// ICProject project = getCProject(); -// ExtractFunctionRefactoring refactoring = -// new ExtractFunctionRefactoring(getTranslationUnit(), selection, project); -// ExtractFunctionInformation info = refactoring.getRefactoringInfo(); -// info.setMethodName(arguments.get(NAME)); -// info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY))); -// info.setReplaceDuplicates(Boolean.parseBoolean(arguments.get(REPLACE_DUPLICATES))); -// return refactoring; + ISelection selection = getSelection(); + ICProject project = getCProject(); + ExtractFunctionRefactoring refactoring = + new ExtractFunctionRefactoring(getTranslationUnit(), selection, project); + ExtractFunctionInformation info = refactoring.getRefactoringInfo(); + info.setMethodName(arguments.get(NAME)); + info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY))); + info.setReplaceDuplicates(Boolean.parseBoolean(arguments.get(REPLACE_DUPLICATES))); + return refactoring; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java index 6cbca133b4c..d4efbd7b831 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescriptor.java @@ -38,12 +38,11 @@ public class ExtractLocalVariableRefactoringDescriptor extends CRefactoringDescr @Override public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException { - return null; -// ISelection selection = getSelection(); -// ICProject proj = getCProject(); -// ExtractLocalVariableRefactoring refactoring = -// new ExtractLocalVariableRefactoring(getTranslationUnit(), selection, proj); -// refactoring.getRefactoringInfo().setName(arguments.get(NAME)); -// return refactoring; + ISelection selection = getSelection(); + ICProject proj = getCProject(); + ExtractLocalVariableRefactoring refactoring = + new ExtractLocalVariableRefactoring(getTranslationUnit(), selection, proj); + refactoring.getRefactoringInfo().setName(arguments.get(NAME)); + return refactoring; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java index 48999d0e571..820ba8034f3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescriptor.java @@ -37,9 +37,8 @@ public class HideMethodRefactoringDescriptor extends CRefactoringDescriptor { @Override public CRefactoring createRefactoring(RefactoringStatus status) throws CoreException { - return null; -// ISelection selection = getSelection(); -// ICProject proj = getCProject(); -// return new HideMethodRefactoring(getTranslationUnit(), selection, proj); + ISelection selection = getSelection(); + ICProject proj = getCProject(); + return new HideMethodRefactoring(getTranslationUnit(), selection, proj); } }