org.eclipse.debug.core.Launch Java Examples

The following examples show how to use org.eclipse.debug.core.Launch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TLCModelLaunchDelegate.java    From tlaplus with MIT License 5 votes vote down vote up
/**
   * 1. method called during the launch
   */
  public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException
  {
// MAK 02/22/2018 changed super.getLaunch(...) - which returned null - to
// explicitly create the Launch instance here to get hold of the instance.
// Return null here causes
// org.eclipse.debug.internal.core.LaunchConfiguration.launch(String,
// IProgressMonitor, boolean, boolean) to create the instance but it doesn't
// correctly clean up the instance if our finalLaunchCheck below throws an
// error. This in turn causes calls to
// org.lamport.tla.toolbox.tool.tlc.model.Model.isRunning() to return true even
// though finalLaunchCheck threw an exception.
  	this.launch = new Launch(configuration, mode, null);
return launch;
  }
 
Example #2
Source File: SimulationSessionViewerFactory.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Image getImage(Object element) {
	if (element instanceof Launch) {
		IDebugTarget debugTarget = ((Launch) element).getDebugTarget();
		if (debugTarget != null && debugTarget.isSuspended()) {
			return DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_ELCL_SUSPEND);
		}
		return SimulationImages.LAUNCHER_ICON.image();
	}
	return SimulationImages.SUB_STATECHART_PICTOGRAM.image();
}
 
Example #3
Source File: SimulationSessionViewerFactory.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean hasChildren(Object element) {
	if (element instanceof Launch) {
		return ((Launch) element).getDebugTargets().length > 0;
	}
	return false;
}
 
Example #4
Source File: SimulationSessionViewerFactory.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object[] getChildren(Object parentElement) {
	if (parentElement instanceof Launch) {
		return ((Launch) parentElement).getDebugTargets();
	}
	return null;
}
 
Example #5
Source File: TestabilityLauncher.java    From testability-explorer with Apache License 2.0 5 votes vote down vote up
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) {
  if (TestabilityConstants.TESTABILITY.equals(mode)) {
    return new Launch(configuration, mode, null);
  } else {
    throw new IllegalStateException(
        "Cannot launch testability configuration when not in testability mode.");
  }
}
 
Example #6
Source File: PydevIProcessFactory.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param launch
 * @param process
 * @param clientPort
 * @param interpreter
 * @param frame
 * @param env
 * @param cmdLine
 */
public PydevConsoleLaunchInfo(Launch launch, Process process, int clientPort, IInterpreterInfo interpreter,
        PyStackFrame frame, String[] cmdLine, String[] env, String encoding) {
    this.launch = launch;
    this.process = process;
    this.clientPort = clientPort;
    this.interpreter = interpreter;
    this.frame = frame;
    this.cmdLine = cmdLine;
    this.env = env;
    this.encoding = encoding;
}
 
Example #7
Source File: PyUnitLaunch.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public static IPyUnitLaunch fromIO(String mode, String memento) {
    if (memento != null && mode != null) {
        try {
            ILaunchConfiguration launchConfiguration = DebugPlugin.getDefault().getLaunchManager()
                    .getLaunchConfiguration(memento);
            return new PyUnitLaunch(new Launch(launchConfiguration, mode, new PySourceLocator()),
                    launchConfiguration);
        } catch (Exception e) {
            Log.log(e);
        }
    }
    // Something went wrong or the info is not complete: create a launch that can't really be launched.
    return new PyUnitLaunch(null, null);
}
 
Example #8
Source File: ProverJob.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * Constructor. This constructor sets the appropriate scheduling rule for this job, so there is no
 * need to call {@link #setRule(org.eclipse.core.runtime.jobs.ISchedulingRule)}.
 * @param module the module on which the prover is being launched.
 * @param offset a character offset on the line of the step or leaf proof on which the prover will be launched. This will
 * launch the prover on the first step on that line, or if the line contains only a leaf proof, it will launch
 * the prover on the step for which that is a leaf proof. If the line does not contain a leaf proof or a step,
 * the prover will be launched on the entire module. Setting the offset to -1 will cause the PM to be launched
 * on the entire module.
 * @param checkStatus true iff the PM should be launched for status checking only
 * @param options the options used to launch the PM in an array, e.g. {"--paranoid","--threads","2"}.
 * The elements in the array would normally be separated by a space in the command line. This
 * array should NOT contain the --toolbox option or the --noproving option. This job will put
 * those options in. The --noproving options should be specified using the checkStatus argument.
 * This argument can be null if no additional options are to be used.
 * @param toolboxMode true iff the
 */
public ProverJob(IFile module, int offset, boolean checkStatus, String[] options, boolean toolboxMode)
{
    super(checkStatus ? "Status Checking Launch" : "Prover Launch");
    this.checkStatus = checkStatus;
    this.toolboxMode = toolboxMode;
    this.module = module;
    this.offset = offset;
    this.options = options;

    /*
     * Running this job can potentially result in parsing
     * the module. This can result in changes to the workspace (because
     * of markers removed from or placed on parse errors). This must
     * be indicated in the scheduling rule for this job. We do this
     * by using a multi rule that includes the ProverJobRule and the
     * rule associated with the root of the workspace. If this is not done,
     * an exception can be thrown. See the comments for MultiRule
     * and read the article http://www.eclipse.org/articles/Article-Concurrency/jobs-api.html
     * for more information on eclipse Jobs.
     */
    setRule(new MultiRule(new ISchedulingRule[] { new ProverJobRule(), this.module.getWorkspace().getRoot() }));

    /*
     * The following sets the path to tlapm.
     */
    Assert.isTrue(Platform.isRunning(), "Platform is not running when prover was launched. This makes no sense.");
    
    final TLAPMExecutableLocator locator = TLAPMExecutableLocator.INSTANCE;
    this.tlapmPath = locator.getTLAPMPath();
    this.cygwinPath = locator.getCygwinPath();

    /*
     * We create a useless launch object. It is
     * used later to construct a IProcess. This object
     * provides convenience methods for processes.
     * In particular, an IProcess listens for the termination
     * of the underlying process.
     */
    this.launch = new Launch(null, "", null);
}
 
Example #9
Source File: ExternalWebServer.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param program
 * @param arguments
 * @param workingDirectory
 * @return created process
 * @throws CoreException
 */
private IProcess exec(String[] arguments, IPath workingDirectory) throws CoreException
{

	File workingDir = null;
	if (workingDirectory != null)
	{
		workingDir = workingDirectory.toFile();
		if (!workingDir.isDirectory())
		{
			workingDir = null;
		}
	}

	// FIXME Make a launch configuration? Doing this low-level stuff by hand is error-prone...
	Process p = DebugPlugin.exec(arguments, workingDir);
	IProcess process = null;
	if (p != null)
	{
		// Do a quick check to see if the execution immediately failed, meaning we probably have a busted command.
		try
		{
			int exitValue = p.exitValue();
			if (exitValue != 0)
			{
				throw new CoreException(ProcessUtil.processResult(p));
			}
		}
		catch (IllegalThreadStateException e)
		{
			// ignore
		}
		fLaunch = new Launch(null, ILaunchManager.RUN_MODE, null);
		fLaunch.setAttribute(DebugPlugin.ATTR_LAUNCH_TIMESTAMP, Long.toString(System.currentTimeMillis()));
		getLaunchManager().addLaunch(fLaunch);
		process = DebugPlugin.newProcess(fLaunch, p,
				MessageFormat.format("{0} - {1}", getType().getName(), getName())); //$NON-NLS-1$
		process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(arguments));

		if (fLaunchListener == null)
		{
			fLaunchListener = new LaunchListener();
		}
		getLaunchManager().addLaunchListener(fLaunchListener);
	}

	return process;
}
 
Example #10
Source File: PydevIProcessFactory.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public PydevConsoleLaunchInfo createLaunch(IInterpreterManager interpreterManager, IInterpreterInfo interpreter,
        Collection<String> pythonpath, IPythonNature nature, List<IPythonNature> naturesUsed) throws Exception {
    Process process = null;
    this.naturesUsed = naturesUsed;
    Integer[] ports = SocketUtil.findUnusedLocalPorts(2);
    int port = ports[0];
    int clientPort = ports[1];

    final Launch launch = new Launch(createLaunchConfig(), "interactive", null);
    launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, "false");
    launch.setAttribute(INTERACTIVE_LAUNCH_PORT, "" + port);

    File scriptWithinPySrc = CorePlugin.getScriptWithinPySrc("pydevconsole.py");
    String pythonpathEnv = SimpleRunner.makePythonPathEnvFromPaths(pythonpath);
    String[] commandLine;
    switch (interpreterManager.getInterpreterType()) {

        case IInterpreterManager.INTERPRETER_TYPE_PYTHON:
            commandLine = SimplePythonRunner.makeExecutableCommandStr(interpreter.getExecutableOrJar(),
                    scriptWithinPySrc.getAbsolutePath(),
                    new String[] { String.valueOf(port), String.valueOf(clientPort) });
            break;

        case IInterpreterManager.INTERPRETER_TYPE_IRONPYTHON:
            commandLine = SimpleIronpythonRunner.makeExecutableCommandStr(interpreter.getExecutableOrJar(),
                    scriptWithinPySrc.getAbsolutePath(),
                    new String[] { String.valueOf(port), String.valueOf(clientPort) });
            break;

        case IInterpreterManager.INTERPRETER_TYPE_JYTHON:
            String vmArgs = PydevDebugPlugin.getDefault().getPreferenceStore()
                    .getString(PydevConsoleConstants.INTERACTIVE_CONSOLE_VM_ARGS);

            commandLine = SimpleJythonRunner.makeExecutableCommandStrWithVMArgs(interpreter.getExecutableOrJar(),
                    scriptWithinPySrc.getAbsolutePath(), pythonpathEnv, vmArgs, new String[] {
                            String.valueOf(port), String.valueOf(clientPort) });
            break;

        case IInterpreterManager.INTERPRETER_TYPE_JYTHON_ECLIPSE:
            commandLine = null;
            break;

        default:
            throw new RuntimeException(
                    "Expected interpreter manager to be Python or Jython or IronPython related.");
    }
    String[] cmdLine;
    String[] env;

    String encoding = PydevDebugPlugin.getDefault().getPreferenceStore()
            .getString(PydevConsoleConstants.INTERACTIVE_CONSOLE_ENCODING);
    if (encoding.trim().length() == 0) {
        encoding = "UTF-8"; //Default is utf-8
    }

    if (interpreterManager.getInterpreterType() == IInterpreterManager.INTERPRETER_TYPE_JYTHON_ECLIPSE) {
        process = new JythonEclipseProcess(scriptWithinPySrc.getAbsolutePath(), port, clientPort);
        cmdLine = new String[] { "Internal Jython process (no command line)" };
        env = null;

    } else {
        env = SimpleRunner.createEnvWithPythonpath(pythonpathEnv, interpreter.getExecutableOrJar(),
                interpreterManager, nature);
        // Add in UMD settings
        String[] s = new String[env.length + 5];
        System.arraycopy(env, 0, s, 0, env.length);

        s[s.length - 5] = "PYDEV_ECLIPSE_PID=" + PlatformUtils.getPid();
        s[s.length - 4] = "PYTHONIOENCODING=" + encoding;
        s[s.length - 3] = "PYDEV_UMD_ENABLED="
                + Boolean.toString(InteractiveConsoleUMDPrefs.isUMDEnabled());
        s[s.length - 2] = "PYDEV_UMD_NAMELIST="
                + InteractiveConsoleUMDPrefs.getUMDExcludeModules();
        s[s.length - 1] = "PYDEV_UMD_VERBOSE="
                + Boolean.toString(InteractiveConsoleUMDPrefs.isUMDVerbose());
        env = s;
        cmdLine = commandLine;

        process = SimpleRunner.createProcess(commandLine, env, null);
    }

    IProcess newProcess = new PydevSpawnedInterpreterProcess(launch, process, interpreter.getNameForUI(), encoding);

    launch.addProcess(newProcess);

    return new PydevConsoleLaunchInfo(launch, process, clientPort, interpreter, null, cmdLine, env, encoding);
}
 
Example #11
Source File: LangLaunchConfigurationDelegate.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
protected ILaunch getLaunchForRunMode(ILaunchConfiguration configuration, String mode) throws CoreException {
	return new Launch(configuration, mode, null);
}
 
Example #12
Source File: LaunchUtil.java    From dartboard with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Passes a supplied file path to the Dart binary at a supplied SDK location.
 *
 * @param dartSdk  - The location of the Dart SDK that should be used for the
 *                 execution
 * @param dartFile - The path to a file that should be executed. Assumes correct
 *                 OS strings (e.g. correct separators). These can be obtained
 *                 from {@link File#separator}.
 */
public static void launchDartFile(String dartSdk, String dartFile) {
	Launch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
	DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
	launchDartFile(launch, dartSdk, dartFile);
}