// Path: org.eclipse.ec4e/src/main/java/org/eclipse/ec4e/EditorConfigPlugin.java
// public class EditorConfigPlugin extends AbstractUIPlugin {
// 
// 	// The plug-in ID
// 	public static final String PLUGIN_ID = "org.eclipse.ec4e"; //$NON-NLS-1$
// 
// 	// The shared instance
// 	private static EditorConfigPlugin plugin;
// 
// 	/**
// 	 * The constructor
// 	 */
// 	public EditorConfigPlugin() {
// 	}
// 
// 	@Override
// 	public void start(BundleContext context) throws Exception {
// 		super.start(context);
// 		plugin = this;
// 		IDEEditorConfigManager.getInstance().init();
// 	}
// 
// 	@Override
// 	public void stop(BundleContext context) throws Exception {
// 		IDEEditorConfigManager.getInstance().dispose();
// 		plugin = null;
// 		super.stop(context);
// 	}
// 
// 	/**
// 	 * Returns the shared instance
// 	 *
// 	 * @return the shared instance
// 	 */
// 	public static EditorConfigPlugin getDefault() {
// 		return plugin;
// 	}
// 
// 	/**
// 	 * Utility method to log errors.
// 	 *
// 	 * @param thr
// 	 *            The exception through which we noticed the error
// 	 */
// 	public static void logError(final Throwable thr) {
// 		getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, 0, thr.getMessage(), thr));
// 	}
// 
// 	/**
// 	 * Utility method to log errors.
// 	 *
// 	 * @param message
// 	 *            User comprehensible message
// 	 * @param thr
// 	 *            The exception through which we noticed the error
// 	 */
// 	public static void logError(final String message, final Throwable thr) {
// 		getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, 0, message, thr));
// 	}
// 
// 	@Override
// 	protected void initializeImageRegistry(ImageRegistry registry) {
// 		EditorConfigImages.initalize(registry);
// 	}
// }


import java.util.Arrays;
import java.util.List;
import org.ec4j.core.model.PropertyType;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ec4e.EditorConfigPlugin;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.RewriteSessionEditProcessor;
import org.eclipse.text.edits.MalformedTreeException;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.undo.DocumentUndoManagerRegistry;
import org.eclipse.text.undo.IDocumentUndoManager;

		return resource.createMarker(EC_PROBLEM_MARKER_TYPE);
	}

	public static int getSeverity(org.ec4j.core.parser.ErrorEvent.ErrorType errorType) {
		return errorType.isSyntaxError() ?  IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING;
	}

	/**
	 * Method will apply all edits to document as single modification. Needs to
	 * be executed in UI thread.
	 *
	 * @param document
	 *            document to modify
	 * @param edits
	 *            list of LSP TextEdits
	 */
	public static void applyEdits(IDocument document, TextEdit edit) {
		if (document == null) {
			return;
		}

		IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
		if (manager != null) {
			manager.beginCompoundChange();
		}
		try {
			RewriteSessionEditProcessor editProcessor = new RewriteSessionEditProcessor(document, edit,
					org.eclipse.text.edits.TextEdit.NONE);
			editProcessor.performEdits();
		} catch (MalformedTreeException | BadLocationException e) {

// Path: org.eclipse.ec4e/src/main/java/org/eclipse/ec4e/EditorConfigPlugin.java
// public class EditorConfigPlugin extends AbstractUIPlugin {
// 
// 	// The plug-in ID
// 	public static final String PLUGIN_ID = "org.eclipse.ec4e"; //$NON-NLS-1$
// 
// 	// The shared instance
// 	private static EditorConfigPlugin plugin;
// 
// 	/**
// 	 * The constructor
// 	 */
// 	public EditorConfigPlugin() {
// 	}
// 
// 	@Override
// 	public void start(BundleContext context) throws Exception {
// 		super.start(context);
// 		plugin = this;
// 		IDEEditorConfigManager.getInstance().init();
// 	}
// 
// 	@Override
// 	public void stop(BundleContext context) throws Exception {
// 		IDEEditorConfigManager.getInstance().dispose();
// 		plugin = null;
// 		super.stop(context);
// 	}
// 
// 	/**
// 	 * Returns the shared instance
// 	 *
// 	 * @return the shared instance
// 	 */
// 	public static EditorConfigPlugin getDefault() {
// 		return plugin;
// 	}
// 
// 	/**
// 	 * Utility method to log errors.
// 	 *
// 	 * @param thr
// 	 *            The exception through which we noticed the error
// 	 */
// 	public static void logError(final Throwable thr) {
// 		getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, 0, thr.getMessage(), thr));
// 	}
// 
// 	/**
// 	 * Utility method to log errors.
// 	 *
// 	 * @param message
// 	 *            User comprehensible message
// 	 * @param thr
// 	 *            The exception through which we noticed the error
// 	 */
// 	public static void logError(final String message, final Throwable thr) {
// 		getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, 0, message, thr));
// 	}
// 
// 	@Override
// 	protected void initializeImageRegistry(ImageRegistry registry) {
// 		EditorConfigImages.initalize(registry);
// 	}
// }


// Path: org.eclipse.ec4e/src/main/java/org/eclipse/ec4e/internal/validation/marker/MarkerUtils.java
import java.util.Arrays;
import java.util.List;
import org.ec4j.core.model.PropertyType;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ec4e.EditorConfigPlugin;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.RewriteSessionEditProcessor;
import org.eclipse.text.edits.MalformedTreeException;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.undo.DocumentUndoManagerRegistry;
import org.eclipse.text.undo.IDocumentUndoManager;

		return resource.createMarker(EC_PROBLEM_MARKER_TYPE);
	}

	public static int getSeverity(org.ec4j.core.parser.ErrorEvent.ErrorType errorType) {
		return errorType.isSyntaxError() ?  IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING;
	}

	/**
	 * Method will apply all edits to document as single modification. Needs to
	 * be executed in UI thread.
	 *
	 * @param document
	 *            document to modify
	 * @param edits
	 *            list of LSP TextEdits
	 */
	public static void applyEdits(IDocument document, TextEdit edit) {
		if (document == null) {
			return;
		}

		IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
		if (manager != null) {
			manager.beginCompoundChange();
		}
		try {
			RewriteSessionEditProcessor editProcessor = new RewriteSessionEditProcessor(document, edit,
					org.eclipse.text.edits.TextEdit.NONE);
			editProcessor.performEdits();
		} catch (MalformedTreeException | BadLocationException e) {

			EditorConfigPlugin.logError(e);
