| package org.eclipse.e4.languages.internal.javascript.debug.launching; |
| |
| import java.io.IOException; |
| import java.util.Map; |
| |
| import org.eclipse.core.runtime.CoreException; |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.core.runtime.IStatus; |
| import org.eclipse.core.runtime.Status; |
| import org.eclipse.debug.core.ILaunch; |
| import org.eclipse.debug.core.ILaunchConfiguration; |
| import org.eclipse.debug.core.model.LaunchConfigurationDelegate; |
| import org.eclipse.e4.languages.javascript.debug.model.JSDIDebugTarget; |
| import org.eclipse.e4.languages.javascript.jsdi.VirtualMachine; |
| import org.eclipse.e4.languages.javascript.jsdi.connect.Connector.Argument; |
| import org.eclipse.e4.languages.javascript.jsdi.rhino.connect.RhinoAttachingConnector; |
| |
| public class RemoteJavaScriptLaunchDelegate extends LaunchConfigurationDelegate { |
| |
| final static String LAUNCH_URI = "launch_uri"; //$NON-NLS-1$ |
| |
| /* |
| * (non-Javadoc) |
| * |
| * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org. eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) |
| */ |
| public void launch(ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException { |
| |
| String port = (String) configuration.getAttribute(ILaunchConstants.PORT, "9000"); |
| RhinoAttachingConnector rhinoConnector = new RhinoAttachingConnector(); |
| Map arguments = rhinoConnector.defaultArguments(); |
| Argument portArgument = (Argument) arguments.get("port"); |
| portArgument.setValue(port); |
| |
| // TODO: factor out Connector creation. This is temporary |
| // because we are bound to Rhino for now |
| VirtualMachine vm; |
| try { |
| vm = rhinoConnector.attach(arguments); |
| } catch (IOException e) { |
| Status status = new Status(IStatus.ERROR, Constants.PLUGIN_ID, "Error occured while launching", e); //$NON-NLS-1$ |
| throw new CoreException(status); |
| } |
| |
| // TODO the process should be the OSGi launched process |
| JSDIDebugTarget target = new JSDIDebugTarget(vm, null, launch, vm.name(), true, true); |
| launch.addDebugTarget(target); |
| } |
| } |