<commit_before>/*******************************************************************************
 * Copyright (c) 2009 <NAME> and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: 
 *    <NAME> - initial API and implementation
 *******************************************************************************/
package clojuredev.launching;

import java.io.IOException;
import java.net.URL;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.jdt.launching.JavaLaunchDelegate;

import clojuredev.ClojuredevPlugin;


public class ClojureLaunchDelegate extends
        JavaLaunchDelegate {
	
    @Override
    public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
        launch.setAttribute(LaunchUtils.ATTR_CLOJURE_SERVER_LISTEN, 
                Integer.toString(configuration.getAttribute(
                        LaunchUtils.ATTR_CLOJURE_SERVER_LISTEN, 
                        LaunchUtils.DEFAULT_SERVER_PORT)));
        launch.setAttribute(LaunchUtils.ATTR_PROJECT_NAME, configuration.getAttribute(LaunchUtils.ATTR_PROJECT_NAME, (String) null));
        super.launch(configuration, mode, launch, monitor);
    }
    
	@Override
	public String getVMArguments(ILaunchConfiguration configuration) throws CoreException {
		return " -D" + "clojure.remote.server.port" + "=" + Integer.toString(configuration.getAttribute(LaunchUtils.ATTR_CLOJURE_SERVER_LISTEN, LaunchUtils.DEFAULT_SERVER_PORT))
			+ super.getVMArguments(configuration);
	}
	
	@Override
	public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
		String userProgramArguments = super.getProgramArguments(configuration);

		String filesToLaunchArguments = LaunchUtils.getFilesToLaunchAsCommandLineList(configuration);
		
		// Add serverrepl as a file to launch to install a remote server
		try {
			URL serverReplBundleUrl = ClojuredevPlugin.getDefault().getBundle().getResource("clojuredev/debug/serverrepl.clj");
			URL serverReplFileUrl = FileLocator.toFileURL(serverReplBundleUrl);
			String serverRepl = serverReplFileUrl.getFile(); 
			filesToLaunchArguments = "-i " + '\"' + serverRepl + "\" " + filesToLaunchArguments;
		} catch (IOException e) {
			e.printStackTrace();<commit_msg>patch from <NAME> correcting a bug in the Java launcher (impossible to properly add user VM arguments)<commit_after>/*******************************************************************************
 * Copyright (c) 2009 <NAME> and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: 
 *    <NAME> - initial API and implementation
 *******************************************************************************/
package clojuredev.launching;

import java.io.IOException;
import java.net.URL;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.jdt.launching.JavaLaunchDelegate;

import clojuredev.ClojuredevPlugin;


public class ClojureLaunchDelegate extends
        JavaLaunchDelegate {
	
    @Override
    public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
        launch.setAttribute(LaunchUtils.ATTR_CLOJURE_SERVER_LISTEN, 
                Integer.toString(configuration.getAttribute(
                        LaunchUtils.ATTR_CLOJURE_SERVER_LISTEN, 
                        LaunchUtils.DEFAULT_SERVER_PORT)));
        launch.setAttribute(LaunchUtils.ATTR_PROJECT_NAME, configuration.getAttribute(LaunchUtils.ATTR_PROJECT_NAME, (String) null));
        super.launch(configuration, mode, launch, monitor);
    }
    
	@Override
	public String getVMArguments(ILaunchConfiguration configuration) throws CoreException {
		return " -D" + "clojure.remote.server.port" + "=" + Integer.toString(configuration.getAttribute(LaunchUtils.ATTR_CLOJURE_SERVER_LISTEN, LaunchUtils.DEFAULT_SERVER_PORT))
			+ " " + super.getVMArguments(configuration);
	}
	
	@Override
	public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
		String userProgramArguments = super.getProgramArguments(configuration);

		String filesToLaunchArguments = LaunchUtils.getFilesToLaunchAsCommandLineList(configuration);
		
		// Add serverrepl as a file to launch to install a remote server
		try {
			URL serverReplBundleUrl = ClojuredevPlugin.getDefault().getBundle().getResource("clojuredev/debug/serverrepl.clj");
			URL serverReplFileUrl = FileLocator.toFileURL(serverReplBundleUrl);
			String serverRepl = serverReplFileUrl.getFile(); 
			filesToLaunchArguments = "-i " + '\"' + serverRepl + "\" " + filesToLaunchArguments;
		} catch (IOException e) {
			e.printStackTrace();
{'fraction_non_alphanumeric': 0.13899543378995433, 'fraction_numerical': 0.0029223744292237444, 'mean_word_length': 5.0175824175824175, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1455986', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1408, 'n_words': 313}