X-Git-Url: http://secure.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/views/outline/ProblemsLabelDecorator.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/views/outline/ProblemsLabelDecorator.java
index 72a211b..598ce41 100644
--- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/views/outline/ProblemsLabelDecorator.java
+++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/views/outline/ProblemsLabelDecorator.java
@@ -8,7 +8,7 @@
* Contributors:
* Christopher Lenz - initial implementation
*
- * $Id: ProblemsLabelDecorator.java,v 1.1 2004-09-02 18:26:28 jsurfer Exp $
+ * $Id: ProblemsLabelDecorator.java,v 1.3 2006-10-21 23:13:54 pombredanne Exp $
*/
package net.sourceforge.phpeclipse.ui.views.outline;
@@ -36,19 +36,17 @@ import org.eclipse.ui.texteditor.ITextEditor;
/**
* Label decorator for the outline page that adds error and warning overlay
- * icons to elements in the outline. The information is retrieved from the
+ * icons to elements in the outline. The information is retrieved from the
* annotation model corresponding to the input of the associated text editor.
*/
-public class ProblemsLabelDecorator extends LabelProvider
- implements ILabelDecorator {
+public class ProblemsLabelDecorator extends LabelProvider implements
+ ILabelDecorator {
// Constants ---------------------------------------------------------------
- private static final String ANNOTATION_TYPE_ERROR =
- "org.eclipse.ui.workbench.texteditor.error"; //$NON-NLS-1$
+ private static final String ANNOTATION_TYPE_ERROR = "org.eclipse.ui.workbench.texteditor.error"; //$NON-NLS-1$
- private static final String ANNOTATION_TYPE_WARNING =
- "org.eclipse.ui.workbench.texteditor.warning"; //$NON-NLS-1$
+ private static final String ANNOTATION_TYPE_WARNING = "org.eclipse.ui.workbench.texteditor.warning"; //$NON-NLS-1$
// Instance Variables ------------------------------------------------------
@@ -63,7 +61,8 @@ public class ProblemsLabelDecorator extends LabelProvider
/**
* Constructor.
*
- * @param editor the associated text editor
+ * @param editor
+ * the associated text editor
*/
public ProblemsLabelDecorator(ITextEditor editor) {
this.editor = editor;
@@ -71,7 +70,7 @@ public class ProblemsLabelDecorator extends LabelProvider
// ILabelDecorator Implementation ------------------------------------------
- /*
+ /*
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
*/
public void dispose() {
@@ -79,12 +78,11 @@ public class ProblemsLabelDecorator extends LabelProvider
registry.dispose();
}
- /*
+ /*
* @see ILabelDecorator#decorateImage(Image, Object)
*/
public Image decorateImage(Image image, Object element) {
- Annotation annotations[] =
- getAssociatedAnnotations((ISourceReference) element);
+ Annotation annotations[] = getAssociatedAnnotations((ISourceReference) element);
ImageDescriptor overlay = null;
for (int i = 0; i < annotations.length; i++) {
if (isError(annotations[i])) {
@@ -105,7 +103,7 @@ public class ProblemsLabelDecorator extends LabelProvider
return image;
}
- /*
+ /*
* @see ILabelDecorator#decorateText(String, Object)
*/
public String decorateText(String text, Object element) {
@@ -117,8 +115,8 @@ public class ProblemsLabelDecorator extends LabelProvider
/**
* Returns all annotations associated with the given model element.
*
- * @param element the model element for which annotations should be
- * collected
+ * @param element
+ * the model element for which annotations should be collected
* @return an array containing all annotations for the given element, or an
* empty array if no annotations are found
*/
@@ -126,13 +124,15 @@ public class ProblemsLabelDecorator extends LabelProvider
List retVal = new ArrayList();
if (editor != null) {
IEditorInput input = editor.getEditorInput();
- IAnnotationModel model =
- editor.getDocumentProvider().getAnnotationModel(input);
- for (Iterator i = model.getAnnotationIterator(); i.hasNext(); ) {
- Annotation annotation = (Annotation) i.next();
- Position pos = model.getPosition(annotation);
- if (pos!=null && isInside(pos.getOffset(), element)) {
- retVal.add(annotation);
+ IAnnotationModel model = editor.getDocumentProvider()
+ .getAnnotationModel(input);
+ if (model != null) { // bug #1120670
+ for (Iterator i = model.getAnnotationIterator(); i.hasNext();) {
+ Annotation annotation = (Annotation) i.next();
+ Position pos = model.getPosition(annotation);
+ if (pos != null && isInside(pos.getOffset(), element)) {
+ retVal.add(annotation);
+ }
}
}
}
@@ -142,7 +142,8 @@ public class ProblemsLabelDecorator extends LabelProvider
/**
* Determines whether the given annotation is an error.
*
- * @param annotation the annotation to check
+ * @param annotation
+ * the annotation to check
* @return true if the annotation is to be displayed as an error,
* false otherwise
*/
@@ -153,9 +154,10 @@ public class ProblemsLabelDecorator extends LabelProvider
/**
* Determines whether the given annotation is a warning.
*
- * @param annotation the annotation to check
- * @return true if the annotation is to be displayed as a warning,
- * false otherwise
+ * @param annotation
+ * the annotation to check
+ * @return true if the annotation is to be displayed as a
+ * warning, false otherwise
*/
private boolean isWarning(Annotation annotation) {
return ANNOTATION_TYPE_WARNING.equals(annotation.getType());
@@ -165,8 +167,10 @@ public class ProblemsLabelDecorator extends LabelProvider
* Tests if the given position is inside the source region of a model
* element.
*
- * @param pos the position to be tested
- * @param element the source element
+ * @param pos
+ * the position to be tested
+ * @param element
+ * the source element
* @return boolean true if position is located inside the
* element, otherwise false
*/
@@ -174,9 +178,9 @@ public class ProblemsLabelDecorator extends LabelProvider
IRegion region = element.getSourceRegion();
if (region != null) {
int offset = region.getOffset();
- return ((offset <= pos) && (offset + region.getLength() > pos));
+ return ((offset <= pos) && (offset + region.getLength() > pos));
}
return false;
}
-}
+}
\ No newline at end of file