Bug 19567 ProblemsLabelDecorator throws ResourceException when project not open
In the F2 build, org.eclipse.jdt.ui.ProblemsLabelDecorator throws a ResourceException if the IResource passed to decorateImage() is a Project that is closed. The exception is a result of calling findMarkers() on line 178 with the closed project. The fix is to change the first line of getErrorTicksFromMarkers() on line 164 from: if (res == null || !res.exists()) { to: if (res == null || !res.isAccessible()) { isAccessible() is the same as exists() except for projects it tests that the project is open. Thanks.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/ProblemsLabelDecorator.java
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.viewsupport.IProblemChangedListener;
import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry;
import org.eclipse.jdt.internal.ui.viewsupport.ImageImageDescriptor;
/**
 * LabelDecorator that decorates an element's image with error and warning overlays that represent the severity
 * of markers attached to the element's underlying resource.
 * To see a problem decoration for a marker, the marker needs to be a subtype of IMarker.PROBLEM.
 * Updating of images on marker change is currently only performed on elements in Java projects.
 */
public class ProblemsLabelDecorator implements ILabelDecorator {