// Path: org.eclipse.ec4e/src/main/java/org/eclipse/ec4e/internal/validation/marker/MarkerUtils.java
// public class MarkerUtils {
// 
// 	private static final String EC_ATTRIBUTE_OPTION_TYPE = "ecOptionType"; //$NON-NLS-1$
// 	private static final String EC_PROBLEM_MARKER_TYPE = "org.eclipse.ec4e.problem"; //$NON-NLS-1$
// 
// 	public static PropertyType<?> getOptionType(IMarker marker) throws CoreException {
// 		return (PropertyType<?>) marker.getAttribute(EC_ATTRIBUTE_OPTION_TYPE);
// 	}
// 
// 	public static boolean isOptionType(IMarker marker, String name) throws CoreException {
// 		PropertyType<?> type = getOptionType(marker);
// 		return type != null && type.getName().equals(name);
// 	}
// 
// 	public static void setOptionType(IMarker marker, PropertyType<?> type) throws CoreException {
// 		marker.setAttribute(EC_ATTRIBUTE_OPTION_TYPE, type);
// 	}
// 
// 	public static boolean isEditorConfigMarker(IMarker marker) {
// 		try {
// 			return EC_PROBLEM_MARKER_TYPE.equals(marker.getType());
// 		} catch (CoreException e) {
// 			return false;
// 		}
// 	}
// 
// 	public static List<IMarker> findEditorConfigMarkers(IResource resource) throws CoreException {
// 		return Arrays.asList(resource.findMarkers(EC_PROBLEM_MARKER_TYPE, false, IResource.DEPTH_ONE));
// 	}
// 
// 	public static IMarker createEditorConfigMarker(IResource resource) throws CoreException {
// 		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);
// 		}
// 		if (manager != null) {
// 			manager.endCompoundChange();
// 		}
// 	}
// }


import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.ec4j.core.ide.IdeSupportService;
import org.ec4j.core.parser.EditorConfigHandler;
import org.ec4j.core.parser.EditorConfigParser;
import org.ec4j.core.parser.ErrorEvent;
import org.ec4j.core.parser.ErrorHandler;
import org.ec4j.core.parser.ParseContext;
import org.ec4j.core.parser.ValidatingHandler;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.filebuffers.LocationKind;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ec4e.internal.validation.marker.MarkerUtils;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.reconciler.DirtyRegion;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
import org.eclipse.ui.texteditor.MarkerUtilities;

package org.eclipse.ec4e.internal.validation;




public class ValidateEditorConfigStrategy
		implements IReconcilingStrategy, IReconcilingStrategyExtension, IReconciler {

	private ITextViewer textViewer;

	private IResource resource;

	public ValidateEditorConfigStrategy(IResource resource) {
		this.resource = resource;
	}

	@Override
	public void setProgressMonitor(IProgressMonitor monitor) {

	}

	@Override
	public void initialReconcile() {

	}

	@Override
	public void setDocument(IDocument document) {

	}

	@Override
	public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
		if (textViewer == null) {
			return;
		}
		try {
			IDocument document = textViewer.getDocument();

// Path: org.eclipse.ec4e/src/main/java/org/eclipse/ec4e/internal/validation/marker/MarkerUtils.java
// public class MarkerUtils {
// 
// 	private static final String EC_ATTRIBUTE_OPTION_TYPE = "ecOptionType"; //$NON-NLS-1$
// 	private static final String EC_PROBLEM_MARKER_TYPE = "org.eclipse.ec4e.problem"; //$NON-NLS-1$
// 
// 	public static PropertyType<?> getOptionType(IMarker marker) throws CoreException {
// 		return (PropertyType<?>) marker.getAttribute(EC_ATTRIBUTE_OPTION_TYPE);
// 	}
// 
// 	public static boolean isOptionType(IMarker marker, String name) throws CoreException {
// 		PropertyType<?> type = getOptionType(marker);
// 		return type != null && type.getName().equals(name);
// 	}
// 
// 	public static void setOptionType(IMarker marker, PropertyType<?> type) throws CoreException {
// 		marker.setAttribute(EC_ATTRIBUTE_OPTION_TYPE, type);
// 	}
// 
// 	public static boolean isEditorConfigMarker(IMarker marker) {
// 		try {
// 			return EC_PROBLEM_MARKER_TYPE.equals(marker.getType());
// 		} catch (CoreException e) {
// 			return false;
// 		}
// 	}
// 
// 	public static List<IMarker> findEditorConfigMarkers(IResource resource) throws CoreException {
// 		return Arrays.asList(resource.findMarkers(EC_PROBLEM_MARKER_TYPE, false, IResource.DEPTH_ONE));
// 	}
// 
// 	public static IMarker createEditorConfigMarker(IResource resource) throws CoreException {
// 		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);
// 		}
// 		if (manager != null) {
// 			manager.endCompoundChange();
// 		}
// 	}
// }


// Path: org.eclipse.ec4e/src/main/java/org/eclipse/ec4e/internal/validation/ValidateEditorConfigStrategy.java
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.ec4j.core.ide.IdeSupportService;
import org.ec4j.core.parser.EditorConfigHandler;
import org.ec4j.core.parser.EditorConfigParser;
import org.ec4j.core.parser.ErrorEvent;
import org.ec4j.core.parser.ErrorHandler;
import org.ec4j.core.parser.ParseContext;
import org.ec4j.core.parser.ValidatingHandler;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.filebuffers.LocationKind;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ec4e.internal.validation.marker.MarkerUtils;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.reconciler.DirtyRegion;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
import org.eclipse.ui.texteditor.MarkerUtilities;

package org.eclipse.ec4e.internal.validation;




public class ValidateEditorConfigStrategy
		implements IReconcilingStrategy, IReconcilingStrategyExtension, IReconciler {

	private ITextViewer textViewer;

	private IResource resource;

	public ValidateEditorConfigStrategy(IResource resource) {
		this.resource = resource;
	}

	@Override
	public void setProgressMonitor(IProgressMonitor monitor) {

	}

	@Override
	public void initialReconcile() {

	}

	@Override
	public void setDocument(IDocument document) {

	}

	@Override
	public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
		if (textViewer == null) {
			return;
		}
		try {
			IDocument document = textViewer.getDocument();

			Set<IMarker> remainingMarkers = MarkerUtils.findEditorConfigMarkers(resource).stream().filter(marker -> {
