Skip to content

Commit b01dfa3

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of debug/org.eclipse.ui.externaltools
1 parent 49cef7d commit b01dfa3

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsImages.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,18 @@ private static void setImageDescriptors(IAction action, String type, String relP
154154

155155
try {
156156
ImageDescriptor id= ImageDescriptor.createFromURL(makeIconFileURL("d" + type, relPath)); //$NON-NLS-1$
157-
if (id != null)
157+
if (id != null) {
158158
action.setDisabledImageDescriptor(id);
159+
}
159160
} catch (MalformedURLException e) {
160161
ExternalToolsPlugin.getDefault().log(e);
161162
}
162163

163164
try {
164165
ImageDescriptor id= ImageDescriptor.createFromURL(makeIconFileURL("c" + type, relPath)); //$NON-NLS-1$
165-
if (id != null)
166+
if (id != null) {
166167
action.setHoverImageDescriptor(id);
168+
}
167169
} catch (MalformedURLException e) {
168170
ExternalToolsPlugin.getDefault().log(e);
169171
}

debug/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,7 @@ private void handleEditButtonPressed() {
659659
TableItem selection= items[0];
660660
if (selection != null) {
661661
Object data = selection.getData();
662-
if (data instanceof ILaunchConfiguration) {
663-
ILaunchConfiguration config= (ILaunchConfiguration) data;
662+
if (data instanceof ILaunchConfiguration config) {
664663
userHasMadeChanges= true;
665664
boolean wasAutobuilding= ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
666665
try {
@@ -675,8 +674,7 @@ private void handleEditButtonPressed() {
675674
handleException(e);
676675
}
677676
}
678-
} else if (data instanceof ICommand) {
679-
ICommand command= (ICommand) data;
677+
} else if (data instanceof ICommand command) {
680678
if (command.isConfigurable()) {
681679
if (editCommand(command)) {
682680
userHasMadeChanges= true;
@@ -739,8 +737,7 @@ private void handleTableSelectionChanged() {
739737
}
740738
for (TableItem item : items) {
741739
Object data= item.getData();
742-
if (data instanceof ILaunchConfiguration) {
743-
ILaunchConfiguration config= (ILaunchConfiguration)data;
740+
if (data instanceof ILaunchConfiguration config) {
744741
String builderName= null;
745742
try {
746743
builderName = config.getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
@@ -779,8 +776,7 @@ private void handleTableSelectionChanged() {
779776
* @return whether the given element is enabled
780777
*/
781778
private boolean isEnabled(Object element) {
782-
if (element instanceof ICommand) {
783-
ICommand command = (ICommand) element;
779+
if (element instanceof ICommand command) {
784780
String val = command.getArguments().get(COMMAND_ENABLED);
785781
if(val != null) {
786782
//null means enabled, see #doPerformOk
@@ -906,8 +902,7 @@ private void doPerformOk(IProgressMonitor monitor, Object[] itemData) {
906902
command.setArguments(args);
907903
}
908904
}
909-
} else if (data instanceof ILaunchConfiguration) {
910-
ILaunchConfiguration config= (ILaunchConfiguration) data;
905+
} else if (data instanceof ILaunchConfiguration config) {
911906
String disabledBuilderName;
912907
try {
913908
disabledBuilderName = config.getAttribute(IExternalToolConstants.ATTR_DISABLED_BUILDER, (String)null);
@@ -917,8 +912,7 @@ private void doPerformOk(IProgressMonitor monitor, Object[] itemData) {
917912
}
918913
} catch (CoreException e1) {
919914
}
920-
if (config instanceof ILaunchConfigurationWorkingCopy) {
921-
ILaunchConfigurationWorkingCopy workingCopy = ((ILaunchConfigurationWorkingCopy) config);
915+
if (config instanceof ILaunchConfigurationWorkingCopy workingCopy) {
922916
// Save any changes to the config (such as enable/disable)
923917
if (workingCopy.isDirty()) {
924918
try {
@@ -1133,8 +1127,7 @@ public boolean performCancel() {
11331127
int numCommands = builderTable.getItemCount();
11341128
for (int i = 0; i < numCommands; i++) {
11351129
Object data = builderTable.getItem(i).getData();
1136-
if (data instanceof ICommand) {
1137-
ICommand command= (ICommand)data;
1130+
if (data instanceof ICommand command) {
11381131
Map<String, String> args = command.getArguments();
11391132
args.remove(COMMAND_ENABLED);
11401133
command.setArguments(args);

0 commit comments

Comments
 (0)