Search in sources :

Example 1 with GeneratorMarkerSupport

use of org.eclipse.n4js.ui.generator.GeneratorMarkerSupport in project n4js by eclipse.

the class BuildInstruction method shouldGenerate.

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);
                // 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.getInstance(GeneratorMarkerSupport.class);
                    generatorMarkerSupport.deleteMarker(resource);
                    // 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);
    }
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) GeneratorMarkerSupport(org.eclipse.n4js.ui.generator.GeneratorMarkerSupport) IStorage(org.eclipse.core.resources.IStorage) IProject(org.eclipse.core.resources.IProject) Pair(org.eclipse.xtext.util.Pair)

Aggregations

IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IStorage (org.eclipse.core.resources.IStorage)1 CoreException (org.eclipse.core.runtime.CoreException)1 WrappedException (org.eclipse.emf.common.util.WrappedException)1 GeneratorMarkerSupport (org.eclipse.n4js.ui.generator.GeneratorMarkerSupport)1 Pair (org.eclipse.xtext.util.Pair)1