<commit_before>package edu.wpi.first.wpilib.plugins.core;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

import edu.wpi.first.wpilib.plugins.core.ant.AntPropertiesParser;
import edu.wpi.first.wpilib.plugins.core.installer.ToolsInstaller;
import edu.wpi.first.wpilib.plugins.core.preferences.PreferenceConstants;

/**
 * The activator class controls the plug-in life cycle
 */
public class WPILibCore extends AbstractUIPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "edu.wpi.first.wpilib.plugins.core"; //$NON-NLS-1$

	// The shared instance
	private static WPILibCore plugin;

	/**
	 * The constructor
	 */
	public WPILibCore() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
	 * )
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;

		new ToolsInstaller(getDefaultVersion()).installIfNecessary();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
	 * )
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	/**
	 * Returns the shared instance
	 * 
	 * @return the shared instance
	 */
	public static WPILibCore getDefault() {
		return plugin;
	}

	/**
	 * Returns an image descriptor for the image file at the given plug-in
	 * relative path
	 * 
	 * @param path
	 *            the path
	 * @return the image descriptor
	 */
	public static ImageDescriptor getImageDescriptor(String path) {
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
	}

	public Properties getProjectProperties(IProject project) {
		List<InputStream> streams = new ArrayList<InputStream>();
		try {
			if (project != null) {
				try {
					streams.add(project.getFile("build.properties")
							.getContents());
				} catch (CoreException e) {
				} // No properties file
			}
			File file = new File(getWPILibBaseDir() + "/wpilib.properties");
			streams.add(new FileInputStream(file));
			return new AntPropertiesParser(streams).getProperties();
		} catch (Exception e) {
            WPILibCore.logError("Error loading project properties.", e);
			return new Properties();
		}
	}

	public void saveGlobalProperties(Properties props) {
		try {<commit_msg>Add version=current to global wpilib.properties file on any property save<commit_after>package edu.wpi.first.wpilib.plugins.core;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

import edu.wpi.first.wpilib.plugins.core.ant.AntPropertiesParser;
import edu.wpi.first.wpilib.plugins.core.installer.ToolsInstaller;
import edu.wpi.first.wpilib.plugins.core.preferences.PreferenceConstants;

/**
 * The activator class controls the plug-in life cycle
 */
public class WPILibCore extends AbstractUIPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "edu.wpi.first.wpilib.plugins.core"; //$NON-NLS-1$

	// The shared instance
	private static WPILibCore plugin;

	/**
	 * The constructor
	 */
	public WPILibCore() {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
	 * )
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;

		new ToolsInstaller(getDefaultVersion()).installIfNecessary();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
	 * )
	 */
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}

	/**
	 * Returns the shared instance
	 * 
	 * @return the shared instance
	 */
	public static WPILibCore getDefault() {
		return plugin;
	}

	/**
	 * Returns an image descriptor for the image file at the given plug-in
	 * relative path
	 * 
	 * @param path
	 *            the path
	 * @return the image descriptor
	 */
	public static ImageDescriptor getImageDescriptor(String path) {
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
	}

	public Properties getProjectProperties(IProject project) {
		List<InputStream> streams = new ArrayList<InputStream>();
		try {
			if (project != null) {
				try {
					streams.add(project.getFile("build.properties")
							.getContents());
				} catch (CoreException e) {
				} // No properties file
			}
			File file = new File(getWPILibBaseDir() + "/wpilib.properties");
			streams.add(new FileInputStream(file));
			return new AntPropertiesParser(streams).getProperties();
		} catch (Exception e) {
            WPILibCore.logError("Error loading project properties.", e);
			return new Properties();
		}
	}

	public void saveGlobalProperties(Properties props) {
		try {
			props.setProperty("version", "current");
{'fraction_non_alphanumeric': 0.11496090973702915, 'fraction_numerical': 0.00035536602700781805, 'mean_word_length': 3.942054433713784, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1896287', 'n_tokens_mistral': 1859, 'n_tokens_neox': 1702, 'n_words': 385}