
package com.coala.core.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
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.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;

public class RemoveMarkers extends AbstractHandler {
	
	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IFile file = ((IFileEditorInput) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActiveEditor().getEditorInput()).getFile();
		removeAllMarkers(file);
		return null;
	}
	
	public void removeAllMarkers(IFile file) {
		IMarker[] problems = null;
		IResource resource = (IResource) file;
		int depth = IResource.DEPTH_INFINITE;
		try {
			problems = resource.findMarkers(IMarker.PROBLEM, true, depth);

		} catch (CoreException e) {
			e.printStackTrace();
		}
		for (IMarker m : problems) {
			try {
				if (m.getType().equals("com.coala.core.coolproblem"))
					m.delete();
			} catch (CoreException e) {
				e.printStackTrace();
			}
		}
	}
}

@@ -630,16 +630,32 @@
 kbench()
+%0A%09%09%09%09%09%09%09%09%09%09%09%09   
 .getActi
@@ -673,16 +673,32 @@
 Window()
+%0A%09%09%09%09%09%09%09%09%09%09%09%09   
 .getActi
@@ -710,16 +710,27 @@
 e()%0A%09%09%09%09
+%09%09%09%09%09%09%09%09   
 .getActi
@@ -739,16 +739,32 @@
 Editor()
+%0A%09%09%09%09%09%09%09%09%09%09%09%09   
 .getEdit
@@ -1301,10 +1301,11 @@
 %0A%09%09%7D%0A%09%7D%0A
+%0A
 %7D%0A

Refactor line length