use of org.eclipse.debug.core.model.ILaunchConfigurationDelegate in project n4js by eclipse.
the class RunnerUiUtils method getRunnerId.
/**
* Read the N4JS runner ID from the given Eclipse launch configuration type. Will throw exceptions if 'failFast' is
* <code>true</code>, otherwise will return <code>null</code> in case of error.
*/
public static String getRunnerId(ILaunchConfigurationType launchConfigType, boolean failFast) {
final Set<Set<String>> modeCombis = launchConfigType.getSupportedModeCombinations();
final Set<String> runnerIds = new HashSet<>();
for (Set<String> modeCombi : modeCombis) {
final ILaunchDelegate[] delegates;
try {
delegates = launchConfigType.getDelegates(modeCombi);
} catch (CoreException e) {
continue;
}
for (ILaunchDelegate launchDelegate : delegates) {
final ILaunchConfigurationDelegate launchConfigDelegate;
try {
launchConfigDelegate = launchDelegate.getDelegate();
} catch (CoreException e) {
throw new WrappedException("error while getting launch configuration delegate from launch delegate", e);
}
if (launchConfigDelegate instanceof IDERunnerDelegate) {
final String runnerId = ((IDERunnerDelegate) launchConfigDelegate).getRunnerId();
if (runnerId != null)
runnerIds.add(runnerId);
}
}
}
if (runnerIds.size() == 1)
return runnerIds.iterator().next();
if (failFast) {
if (runnerIds.isEmpty()) {
throw new IllegalStateException("cannot find an N4JS runner ID for the launch configuration type with ID: " + launchConfigType.getIdentifier());
} else {
// runnerIds.size() > 1
throw new IllegalStateException("several N4JS runner IDs used for a single ILaunchConfigurationType: " + launchConfigType.getIdentifier());
}
}
return null;
}
use of org.eclipse.debug.core.model.ILaunchConfigurationDelegate in project erlide_eclipse by erlang.
the class DebugTraceLaunching method launch.
public static void launch(final IDebugTarget target, final DebuggerTraceView debuggerTraceView) {
if (target == null) {
return;
}
try {
final ILaunchConfigurationType lcType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType("org.erlide.runtime.debug.launchDebugTrace");
final String name = target.toString();
final ILaunchConfigurationWorkingCopy wc = lcType.newInstance(null, name);
final Set<String> modes = new HashSet<>();
modes.add(ILaunchManager.DEBUG_MODE);
final ILaunchDelegate[] delegates = lcType.getDelegates(modes);
final ILaunchConfigurationDelegate delegate = delegates[0].getDelegate();
if (!(delegate instanceof DebugTraceLaunchConfigurationDelegate)) {
return;
}
final DebugTraceLaunchConfigurationDelegate ldtlcd = (DebugTraceLaunchConfigurationDelegate) delegate;
ldtlcd.setInfo(target.getLaunch(), target, debuggerTraceView.getEventsForLaunch(target));
wc.launch(ILaunchManager.DEBUG_MODE, null);
} catch (final CoreException e) {
ErlLogger.error(e);
}
}
Aggregations