From 0cfd0be3652fe5b3aef9f5391da3a89f8508afb5 Mon Sep 17 00:00:00 2001 From: Eclipse Platform Bot Date: Thu, 18 Sep 2025 02:31:06 +0000 Subject: [PATCH 1/2] Perform clean code of bundles/org.eclipse.core.commands --- .../src/org/eclipse/core/commands/Command.java | 12 ++++-------- .../org/eclipse/core/commands/CommandManager.java | 8 +++----- .../org/eclipse/core/commands/Parameterization.java | 3 +-- .../eclipse/core/commands/ParameterizedCommand.java | 3 +-- .../eclipse/core/commands/common/HandleObject.java | 3 +-- .../commands/operations/DefaultOperationHistory.java | 9 ++++----- .../core/commands/operations/ObjectUndoContext.java | 6 +++--- .../commands/operations/OperationHistoryEvent.java | 6 +++--- .../commands/operations/TriggeredOperations.java | 2 +- 9 files changed, 21 insertions(+), 31 deletions(-) diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Command.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Command.java index 1c04a1004cc..5afacb713fc 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Command.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Command.java @@ -550,8 +550,7 @@ private void fireNotDefined(final NotDefinedException e) { if (executionListeners != null) { for (final IExecutionListener object : executionListeners) { - if (object instanceof IExecutionListenerWithChecks) { - final IExecutionListenerWithChecks listener = (IExecutionListenerWithChecks) object; + if (object instanceof final IExecutionListenerWithChecks listener) { listener.notDefined(getId(), e); } } @@ -576,8 +575,7 @@ private void fireNotEnabled(final NotEnabledException e) { if (executionListeners != null) { for (final IExecutionListener object : executionListeners) { - if (object instanceof IExecutionListenerWithChecks) { - final IExecutionListenerWithChecks listener = (IExecutionListenerWithChecks) object; + if (object instanceof final IExecutionListenerWithChecks listener) { listener.notEnabled(getId(), e); } } @@ -788,8 +786,7 @@ public IParameter[] getParameters() throws NotDefinedException { */ public ParameterType getParameterType(final String parameterId) throws NotDefinedException { final IParameter parameter = getParameter(parameterId); - if (parameter instanceof ITypedParameter) { - final ITypedParameter parameterWithType = (ITypedParameter) parameter; + if (parameter instanceof final ITypedParameter parameterWithType) { return parameterWithType.getParameterType(); } return null; @@ -1077,8 +1074,7 @@ public void undefine() { final String[] stateIds = getStateIds(); if (stateIds != null) { - if (handler instanceof IObjectWithState) { - final IObjectWithState handlerWithState = (IObjectWithState) handler; + if (handler instanceof final IObjectWithState handlerWithState) { for (final String stateId : stateIds) { handlerWithState.removeState(stateId); diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/CommandManager.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/CommandManager.java index 9a7f6fcedf5..7cf1262abd2 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/CommandManager.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/CommandManager.java @@ -54,8 +54,7 @@ private final class ExecutionListener implements public void notDefined(String commandId, NotDefinedException exception) { if (executionListeners != null) { for (final IExecutionListener object : executionListeners) { - if (object instanceof IExecutionListenerWithChecks) { - final IExecutionListenerWithChecks listener = (IExecutionListenerWithChecks) object; + if (object instanceof final IExecutionListenerWithChecks listener) { listener.notDefined(commandId, exception); } } @@ -66,8 +65,7 @@ public void notDefined(String commandId, NotDefinedException exception) { public void notEnabled(String commandId, NotEnabledException exception) { if (executionListeners != null) { for (final IExecutionListener object : executionListeners) { - if (object instanceof IExecutionListenerWithChecks) { - final IExecutionListenerWithChecks listener = (IExecutionListenerWithChecks) object; + if (object instanceof final IExecutionListenerWithChecks listener) { listener.notEnabled(commandId, exception); } } @@ -246,7 +244,7 @@ private static String unescape(final String escapedText) */ private IExecutionListenerWithChecks executionListener; - private boolean shouldCommandFireEvents = true; + private final boolean shouldCommandFireEvents = true; /** * The collection of execution listeners. This collection is diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Parameterization.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Parameterization.java index c520470c45c..51da20f65c0 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Parameterization.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/Parameterization.java @@ -90,11 +90,10 @@ public final boolean equals(final Object object) { return true; } - if (!(object instanceof Parameterization)) { + if (!(object instanceof final Parameterization parameterization)) { return false; } - final Parameterization parameterization = (Parameterization) object; if (!(Objects.equals(this.parameter.getId(), parameterization.parameter.getId()))) { return false; } diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/ParameterizedCommand.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/ParameterizedCommand.java index 8302321886e..fdc32c39ea4 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/ParameterizedCommand.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/ParameterizedCommand.java @@ -423,11 +423,10 @@ public boolean equals(final Object object) { return true; } - if (!(object instanceof ParameterizedCommand)) { + if (!(object instanceof final ParameterizedCommand command)) { return false; } - final ParameterizedCommand command = (ParameterizedCommand) object; return Objects.equals(this.command, command.command) && Arrays.equals(this.parameterizations, command.parameterizations); } diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/common/HandleObject.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/common/HandleObject.java index cf61a6780ca..8bc21eb9522 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/common/HandleObject.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/common/HandleObject.java @@ -118,12 +118,11 @@ public boolean equals(final Object object) { } // Check if they're the same type. - if (!(object instanceof HandleObject)) { + if (!(object instanceof final HandleObject handle)) { return false; } // Check each property in turn. - final HandleObject handle= (HandleObject) object; return Objects.equals(id, handle.id) && (this.getClass() == handle.getClass()); } diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/DefaultOperationHistory.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/DefaultOperationHistory.java index 2a63b6aa968..1f92fff5b77 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/DefaultOperationHistory.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/DefaultOperationHistory.java @@ -127,7 +127,7 @@ public final class DefaultOperationHistory implements IOperationHistory { /** * a map of undo limits per context */ - private Map limits = Collections.synchronizedMap(new HashMap<>()); + private final Map limits = Collections.synchronizedMap(new HashMap<>()); /** * the list of {@link IOperationHistoryListener}s @@ -137,12 +137,12 @@ public final class DefaultOperationHistory implements IOperationHistory { /** * the list of operations available for redo, LIFO */ - private List redoList = Collections.synchronizedList(new ArrayList<>()); + private final List redoList = Collections.synchronizedList(new ArrayList<>()); /** * the list of operations available for undo, LIFO */ - private List undoList = Collections.synchronizedList(new ArrayList<>()); + private final List undoList = Collections.synchronizedList(new ArrayList<>()); /** * a lock that is used to synchronize access between the undo and redo @@ -807,8 +807,7 @@ public IUndoableOperation getUndoOperation(IUndoContext context) { private IStatus getExecuteApproval(IUndoableOperation operation, IAdaptable info) { for (IOperationApprover tmp : approvers) { - if (tmp instanceof IOperationApprover2) { - IOperationApprover2 approver = (IOperationApprover2) tmp; + if (tmp instanceof IOperationApprover2 approver) { IStatus approval = approver.proceedExecuting(operation, this, info); if (!approval.isOK()) { if (DEBUG_OPERATION_HISTORY_APPROVAL) { diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/ObjectUndoContext.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/ObjectUndoContext.java index 9a1e6b0a11f..6a7bbf39e6e 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/ObjectUndoContext.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/ObjectUndoContext.java @@ -27,11 +27,11 @@ */ public final class ObjectUndoContext extends UndoContext { - private Object object; + private final Object object; - private String label; + private final String label; - private List children = new ArrayList<>(); + private final List children = new ArrayList<>(); /** * Construct an operation context that represents the given object. diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/OperationHistoryEvent.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/OperationHistoryEvent.java index c17ee13ce70..446329cc5dc 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/OperationHistoryEvent.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/OperationHistoryEvent.java @@ -144,12 +144,12 @@ public final class OperationHistoryEvent { private int code = 0; - private IOperationHistory history; + private final IOperationHistory history; - private IUndoableOperation operation; + private final IUndoableOperation operation; /* @since 3.2 */ - private IStatus status; + private final IStatus status; /** * Construct an event for the specified operation history. diff --git a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/TriggeredOperations.java b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/TriggeredOperations.java index bfbbee0080d..e3232d111a0 100644 --- a/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/TriggeredOperations.java +++ b/bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/TriggeredOperations.java @@ -48,7 +48,7 @@ public final class TriggeredOperations extends AbstractOperation implements private IUndoableOperation triggeringOperation; - private IOperationHistory history; + private final IOperationHistory history; private List children = new ArrayList<>(); From cc1be79c59d5768b47b5cbe7f4bc6f0e1e114e99 Mon Sep 17 00:00:00 2001 From: Eclipse Platform Bot Date: Thu, 18 Sep 2025 02:35:20 +0000 Subject: [PATCH 2/2] Version bump(s) for 4.38 stream --- bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF index e9976632db3..f3b945668b8 100644 --- a/bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.core.commands/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.core.commands -Bundle-Version: 3.12.400.qualifier +Bundle-Version: 3.12.500.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.core.commands,