Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2012 itemis AG (http://www.itemis.eu) 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 /
 
 package org.eclipse.xtext.ui.validation;
 
import  org.eclipse.core.resources.IFile;
import  org.eclipse.core.resources.IResource;
import  org.eclipse.core.runtime.CoreException;
import  org.eclipse.core.runtime.IProgressMonitor;
Can delete validation markers in IFile corresponding to the given CheckMode

Author(s):
Dennis Huebner - Initial contribution and API
Since:
2.3
public class MarkerEraser {
	private final static Logger LOG = Logger.getLogger(MarkerEraser.class);
	public void deleteValidationMarkers(IFile fileCheckMode checkMode, IProgressMonitor monitor) {
		if (shouldProcess(file)) {
			try {
				deleteMarkers(filecheckModemonitor);
catch (CoreException ex) {
				.error(ex.getMessage(), ex);
			}
		}
	}

Checks if a IFile should/can be processed

Returns:
true if file is accessible and not hidden
	public final boolean shouldProcess(final IFile file) {
		return file.isAccessible() && file.getProject().isAccessible() && !file.getProject().isHidden();
	}

Deletes IFile's markers which type matches the given CheckTypes represented by the CheckMode.

See also:
CheckType
CheckMode.shouldCheck(CheckType)
MarkerTypes.forCheckType(CheckType)
	public final void deleteMarkers(final IFile filefinal CheckMode checkModefinal IProgressMonitor monitor)
			throws CoreException {
		for (CheckType chkType : CheckType.values()) {
			if (checkMode.shouldCheck(chkType)) {
				String markerType = MarkerTypes.forCheckType(chkType);
				file.deleteMarkers(markerTypetrue, IResource.DEPTH_ZERO);
			}
		}
	}
New to GrepCode? Check out our FAQ X