Skip to content

Commit 317b798

Browse files
SougandhSmerks
authored andcommitted
Do not enable Link Prototypes if there are no prototypes
This commit disables Link Prototypes from launch configurations context if there are no prototypes defined launch type.
1 parent dcc6e9d commit 317b798

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*******************************************************************************/
1414
package org.eclipse.debug.internal.ui.launchConfigurations;
1515

16-
import java.util.Collection;
17-
import java.util.HashSet;
18-
1916
import org.eclipse.core.runtime.CoreException;
2017
import org.eclipse.debug.core.ILaunchConfiguration;
2118
import org.eclipse.debug.core.ILaunchConfigurationType;
@@ -104,34 +101,37 @@ protected void performAction() {
104101
*/
105102
@Override
106103
protected boolean updateSelection(IStructuredSelection selection) {
107-
// Enable action only if launch configuration(s) of the same type
108-
// is(are) selected and the launch configuration type allows prototypes
109-
Collection<ILaunchConfigurationType> launchConfigurationTypes = new HashSet<>();
104+
if (selection.isEmpty()) {
105+
return false;
106+
}
107+
ILaunchConfigurationType type = null;
110108
for (Object object : selection.toList()) {
111-
if (object instanceof ILaunchConfiguration) {
112-
if (((ILaunchConfiguration) object).isPrototype()) {
109+
if (!(object instanceof ILaunchConfiguration launchConfig)) {
110+
return false;
111+
}
112+
113+
if (launchConfig.isPrototype()) {
114+
return false;
115+
}
116+
117+
ILaunchConfigurationType currentType;
118+
try {
119+
currentType = launchConfig.getType();
120+
if (currentType.getPrototypes().length == 0) {
113121
return false;
114-
} else {
115-
ILaunchConfigurationType type = null;
116-
try {
117-
type = ((ILaunchConfiguration) object).getType();
118-
} catch (CoreException e) {
119-
DebugUIPlugin.log(e.getStatus());
120-
}
121-
if (type != null) {
122-
launchConfigurationTypes.add(type);
123-
} else {
124-
return false;
125-
}
126122
}
127-
} else {
123+
} catch (CoreException e) {
124+
DebugUIPlugin.log(e.getStatus());
125+
return false;
126+
}
127+
128+
if (type == null) {
129+
type = currentType;
130+
} else if (!type.equals(currentType)) {
128131
return false;
129132
}
130133
}
131-
if (launchConfigurationTypes.size() == 1) {
132-
return launchConfigurationTypes.iterator().next().supportsPrototypes();
133-
}
134-
return false;
134+
return true;
135135
}
136136

137137
@Override

0 commit comments

Comments
 (0)