Java Code Examples for org.eclipse.core.resources.IFile#findMaxProblemSeverity()

The following examples show how to use org.eclipse.core.resources.IFile#findMaxProblemSeverity() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: n4js   File:    License: Eclipse Public License 1.0 6 votes vote down vote up
private boolean shouldGenerate(Resource resource, IProject aProject) {
	try {
		Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(resource.getURI());
		for (Pair<IStorage, IProject> pair : storages) {
			if (pair.getFirst() instanceof IFile && pair.getSecond().equals(aProject)) {
				IFile file = (IFile) pair.getFirst();
				int findMaxProblemSeverity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
				// If the generator itself placed an error marker on the resource, we have to ignore that error.
				// Easiest way here is to remove that error marker-type and look for other severe errors once more:
				if (findMaxProblemSeverity == IMarker.SEVERITY_ERROR) {
					// clean
					GeneratorMarkerSupport generatorMarkerSupport = injector
					// and recompute:
					findMaxProblemSeverity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
				// the final decision to build:
				return findMaxProblemSeverity != IMarker.SEVERITY_ERROR;
		return false;
	} catch (CoreException exc) {
		throw new WrappedException(exc);
Example 2
public void assertNoErrorMarker(IFile file) throws CoreException {
	int severity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
	if (severity != -1) {
		StringBuilder errors = new StringBuilder();
		for (IMarker marker : file.findMarkers(null, true, IResource.DEPTH_INFINITE)) {
		fail("Expected no error but got" + errors.toString());