summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Khodjaiants2012-03-01 16:53:15 -0500
committerMikhail Khodjaiants2012-03-01 16:53:15 -0500
commitfb808b7db2d2f5e9f95f7f1f35b4dfa780003a6c (patch)
treeb4d3eadbbb4ef39cc467482cf3149766f8f78c6f
parentdddeb4dbcc4188e024db1f32d939775bccb9fa40 (diff)
downloadorg.eclipse.cdt-fb808b7db2d2f5e9f95f7f1f35b4dfa780003a6c.zip
org.eclipse.cdt-fb808b7db2d2f5e9f95f7f1f35b4dfa780003a6c.tar.gz
org.eclipse.cdt-fb808b7db2d2f5e9f95f7f1f35b4dfa780003a6c.tar.xz
Bug 372795 - Refactor common code in GDBControl* classes
Fixed API compatibility issues.
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java1
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java96
2 files changed, 66 insertions, 31 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
index 1898564..e6c5e4d 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
@@ -365,6 +365,7 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
protected void initialize(RequestMonitor requestMonitor) {
requestMonitor.done();
}
+
protected void shutdown(RequestMonitor requestMonitor) {
requestMonitor.done();
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
index ddfa692..717de15 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
@@ -46,34 +46,70 @@ import org.eclipse.debug.core.ILaunchConfiguration;
public class GDBControl_7_0 extends GDBControl {
/**
- * @deprecated use {@link GDBControl.InitializationShutdownStep}.
+ * @deprecated use {@link GDBControl.InitializationShutdownStep}
*/
- @Deprecated
- public static class InitializationShutdownStep extends GDBControl.InitializationShutdownStep {
-
+ @Deprecated
+ public static class InitializationShutdownStep extends Sequence.Step {
+
/**
- * @deprecated use {@link GDBControl.InitializationShutdownStep.Direction}.
+ * @deprecated use {@link GDBControl.InitializationShutdownStep.Direction}
*/
@Deprecated
- public enum Direction { INITIALIZING, SHUTTING_DOWN }
-
- public InitializationShutdownStep(Direction direction) {
- super((direction == Direction.INITIALIZING) ?
- GDBControl.InitializationShutdownStep.Direction.INITIALIZING :
- GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN);
- }
+ public enum Direction { INITIALIZING, SHUTTING_DOWN }
+
+ private GDBControl.InitializationShutdownStep.Direction fDirection;
+ private GDBControl.InitializationShutdownStep fDelegate;
+
+ public InitializationShutdownStep(Direction direction) {
+ fDirection = (direction == Direction.INITIALIZING) ?
+ GDBControl.InitializationShutdownStep.Direction.INITIALIZING :
+ GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN;
+
+ fDelegate = new GDBControl.InitializationShutdownStep(fDirection);
+ }
+
+ private InitializationShutdownStep(
+ GDBControl.InitializationShutdownStep.Direction direction,
+ GDBControl.InitializationShutdownStep delegate) {
+ fDirection = direction;
+ fDelegate = delegate;
+ }
+
+ @Override
+ final public void execute(RequestMonitor requestMonitor) {
+ if (fDirection == GDBControl.InitializationShutdownStep.Direction.INITIALIZING) {
+ initialize(requestMonitor);
+ } else {
+ shutdown(requestMonitor);
+ }
+ }
+
+ @Override
+ final public void rollBack(RequestMonitor requestMonitor) {
+ if (fDirection == GDBControl.InitializationShutdownStep.Direction.INITIALIZING) {
+ shutdown(requestMonitor);
+ } else {
+ super.rollBack(requestMonitor);
+ }
+ }
+
+ protected void initialize(RequestMonitor requestMonitor) {
+ fDelegate.initialize(requestMonitor);
+ }
+
+ protected void shutdown(RequestMonitor requestMonitor) {
+ fDelegate.shutdown(requestMonitor);
+ }
}
/**
- * @deprecated use {@link GDBControl.CommandMonitoringStep}.
+ * @deprecated use {@link GDBControl.CommandMonitoringStep}
*/
@Deprecated
- protected class CommandMonitoringStep extends GDBControl.CommandMonitoringStep {
-
- CommandMonitoringStep(GDBControl_7_0.InitializationShutdownStep.Direction direction) {
- super((direction == GDBControl_7_0.InitializationShutdownStep.Direction.INITIALIZING) ?
- GDBControl.InitializationShutdownStep.Direction.INITIALIZING :
- GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN);
+ protected class CommandMonitoringStep extends InitializationShutdownStep {
+
+ CommandMonitoringStep(GDBControl.InitializationShutdownStep.Direction direction) {
+ super(direction, new GDBControl.CommandMonitoringStep(direction));
}
}
@@ -81,12 +117,10 @@ public class GDBControl_7_0 extends GDBControl {
* @deprecated use {@link GDBControl.CommandProcessorsStep}.
*/
@Deprecated
- protected class CommandProcessorsStep extends GDBControl.CommandProcessorsStep {
+ protected class CommandProcessorsStep extends InitializationShutdownStep {
- CommandProcessorsStep(GDBControl_7_0.InitializationShutdownStep.Direction direction) {
- super((direction == GDBControl_7_0.InitializationShutdownStep.Direction.INITIALIZING) ?
- GDBControl.InitializationShutdownStep.Direction.INITIALIZING :
- GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN);
+ CommandProcessorsStep(GDBControl.InitializationShutdownStep.Direction direction) {
+ super(direction, new GDBControl.CommandProcessorsStep(direction));
}
}
@@ -94,12 +128,10 @@ public class GDBControl_7_0 extends GDBControl {
* @deprecated use {@link GDBControl.RegisterStep}.
*/
@Deprecated
- protected class RegisterStep extends GDBControl.RegisterStep {
+ protected class RegisterStep extends InitializationShutdownStep {
- RegisterStep(GDBControl_7_0.InitializationShutdownStep.Direction direction) {
- super((direction == GDBControl_7_0.InitializationShutdownStep.Direction.INITIALIZING) ?
- GDBControl.InitializationShutdownStep.Direction.INITIALIZING :
- GDBControl.InitializationShutdownStep.Direction.SHUTTING_DOWN);
+ RegisterStep(GDBControl.InitializationShutdownStep.Direction direction) {
+ super(direction, new GDBControl.RegisterStep(direction));
}
}
@@ -178,9 +210,11 @@ public class GDBControl_7_0 extends GDBControl {
/** @since 4.0 */
- protected class ListFeaturesStep extends GDBControl.InitializationShutdownStep {
+ protected class ListFeaturesStep extends InitializationShutdownStep {
- ListFeaturesStep(GDBControl.InitializationShutdownStep.Direction direction) { super(direction); }
+ ListFeaturesStep(GDBControl.InitializationShutdownStep.Direction direction) {
+ super(direction, new GDBControl.InitializationShutdownStep(direction));
+ }
@Override
protected void initialize(final RequestMonitor requestMonitor) {