forked from eclipse-jdt/eclipse.jdt.ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
63149: [ltk] allow changes to be executed after the 'main' change dur…
…ing an undo [refactoring]
- Loading branch information
Markus Keller
committed
Feb 26, 2008
1 parent
0030d8d
commit 31c50f4
Showing
18 changed files
with
689 additions
and
61 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
org.eclipse.ltk.core.refactoring.tests/.settings/org.eclipse.pde.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2000, 2006 IBM Corporation and others. | ||
* Copyright (c) 2000, 2008 IBM Corporation 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: | ||
* IBM Corporation - initial API and implementation | ||
* Oakland Software (Francis Upton) <[email protected]> - | ||
* Fix for Bug 63149 [ltk] allow changes to be executed after the 'main' change during an undo [refactoring] | ||
*******************************************************************************/ | ||
package org.eclipse.ltk.core.refactoring.tests.participants; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.OperationCanceledException; | ||
|
||
import org.eclipse.ltk.core.refactoring.Change; | ||
import org.eclipse.ltk.core.refactoring.NullChange; | ||
import org.eclipse.ltk.core.refactoring.RefactoringStatus; | ||
|
||
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; | ||
import org.eclipse.ltk.core.refactoring.participants.ParticipantManager; | ||
import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant; | ||
|
@@ -25,9 +31,45 @@ | |
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants; | ||
|
||
public class ElementRenameProcessor extends RenameProcessor { | ||
|
||
Object[] fElements= new Object[] { new Element() }; | ||
|
||
|
||
public static List fHistory; | ||
|
||
public static final String WORKING_CREATE= "workingCreate"; | ||
public static final String WORKING_EXEC= "workingExec"; | ||
public static final String WORKING_EXEC_UNDO= "workingExecUndo"; | ||
public static final String WORKINGPRE_CREATE= "workingPreCreate"; | ||
public static final String WORKINGPRE_CREATEPRE= "workingPreCreatePre"; | ||
public static final String WORKINGPRE_EXEC= "workingPreExec"; | ||
public static final String WORKINGPRE_EXECPRE= "workingPreExecPre"; | ||
public static final String WORKINGPRE_EXEC_UNDO= "workingPreExecUndo"; | ||
public static final String WORKINGPRE_EXECPRE_UNDO= "workingPreExecPreUndo"; | ||
public static final String MAIN_CREATE= "mainCreate"; | ||
public static final String MAIN_EXEC= "mainExec"; | ||
public static final String MAIN_EXEC_UNDO= "mainExecUndo"; | ||
|
||
Object[] fElements; | ||
|
||
int fOptions; | ||
|
||
public static void resetHistory() { | ||
fHistory= new ArrayList(); | ||
} | ||
|
||
public ElementRenameProcessor(int options) { | ||
resetHistory(); | ||
fOptions= options; | ||
if ((options & ElementRenameRefactoring.WORKING) != 0) { | ||
if ((options & ElementRenameRefactoring.PRE_CHANGE) != 0) { | ||
if ((options & ElementRenameRefactoring.ALWAYS_ENABLED) != 0) | ||
fElements= new Object[] { new ElementWorkingPreAlways() }; | ||
else | ||
fElements= new Object[] { new ElementWorkingPre() }; | ||
} else | ||
fElements= new Object[] { new ElementWorking() }; | ||
} else | ||
fElements= new Object[] { new Element() }; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
|
@@ -74,14 +116,33 @@ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditio | |
* {@inheritDoc} | ||
*/ | ||
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { | ||
return new NullChange(); | ||
fHistory.add(MAIN_CREATE); | ||
return new NullChange() { | ||
public Change perform(IProgressMonitor monitor) throws CoreException { | ||
if ((fOptions & ElementRenameRefactoring.FAIL_TO_EXECUTE) != 0) | ||
throw new RuntimeException(); | ||
fHistory.add(MAIN_EXEC); | ||
// Undo change | ||
return new NullChange() { | ||
public Change perform(IProgressMonitor m2) throws CoreException { | ||
fHistory.add(MAIN_EXEC_UNDO); | ||
// Redo change | ||
return new NullChange() { | ||
public Change perform(IProgressMonitor m3) throws CoreException { | ||
fHistory.add(MAIN_EXEC); | ||
return null; | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException { | ||
return ParticipantManager.loadRenameParticipants(new RefactoringStatus(), this, fElements[0], | ||
new RenameArguments("test", true), new String[0], new SharableParticipants()); | ||
return ParticipantManager.loadRenameParticipants(new RefactoringStatus(), this, fElements[0], new RenameArguments("test", true), new String[0], new SharableParticipants()); | ||
} | ||
} |
20 changes: 17 additions & 3 deletions
20
...sts/src/org/eclipse/ltk/core/refactoring/tests/participants/ElementRenameRefactoring.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2000, 2006 IBM Corporation and others. | ||
* Copyright (c) 2000, 2008 IBM Corporation 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: | ||
* IBM Corporation - initial API and implementation | ||
* Oakland Software (Francis Upton) <[email protected]> - | ||
* Fix for Bug 63149 [ltk] allow changes to be executed after the 'main' change during an undo [refactoring] | ||
*******************************************************************************/ | ||
package org.eclipse.ltk.core.refactoring.tests.participants; | ||
|
||
import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; | ||
|
||
public class ElementRenameRefactoring extends RenameRefactoring { | ||
|
||
public ElementRenameRefactoring() { | ||
super(new ElementRenameProcessor()); | ||
// Use a working participant | ||
public static final int WORKING= 0x01; | ||
|
||
// Cause the main refactoring to fail | ||
public static final int FAIL_TO_EXECUTE= 0x02; | ||
|
||
// Use the working pre-change participant | ||
public static final int PRE_CHANGE= 0x04; | ||
|
||
// Use the participants that are never disabled | ||
public static final int ALWAYS_ENABLED= 0x08; | ||
|
||
public ElementRenameRefactoring(int options) { | ||
super(new ElementRenameProcessor(options)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ctoring.tests/src/org/eclipse/ltk/core/refactoring/tests/participants/ElementWorking.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2008 Oakland Software Incorporated 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: | ||
* Oakland Software ([email protected]) - initial contribution - bug 63149 | ||
*******************************************************************************/ | ||
package org.eclipse.ltk.core.refactoring.tests.participants; | ||
|
||
/** | ||
* The element to be renamed | ||
*/ | ||
public class ElementWorking { | ||
} |
17 changes: 17 additions & 0 deletions
17
...ring.tests/src/org/eclipse/ltk/core/refactoring/tests/participants/ElementWorkingPre.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2008 Oakland Software Incorporated 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: | ||
* Oakland Software ([email protected]) - initial contribution - bug 63149 | ||
*******************************************************************************/ | ||
package org.eclipse.ltk.core.refactoring.tests.participants; | ||
|
||
/** | ||
* The element to be renamed | ||
*/ | ||
public class ElementWorkingPre { | ||
} |
17 changes: 17 additions & 0 deletions
17
...ests/src/org/eclipse/ltk/core/refactoring/tests/participants/ElementWorkingPreAlways.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2008 Oakland Software Incorporated 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: | ||
* Oakland Software ([email protected]) - initial contribution - bug 63149 | ||
*******************************************************************************/ | ||
package org.eclipse.ltk.core.refactoring.tests.participants; | ||
|
||
/** | ||
* The element to be renamed | ||
*/ | ||
public class ElementWorkingPreAlways { | ||
} |
Oops, something went wrong.