X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/AbstractAnnotationHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/AbstractAnnotationHover.java index d87878c..64fc808 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/AbstractAnnotationHover.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/hover/AbstractAnnotationHover.java @@ -30,75 +30,90 @@ import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess; import org.eclipse.ui.texteditor.IDocumentProvider; - /** * Abstract super class for annotation hovers. * * @since 3.0 */ -public abstract class AbstractAnnotationHover extends AbstractJavaEditorTextHover { +public abstract class AbstractAnnotationHover extends + AbstractJavaEditorTextHover { + + private IPreferenceStore fStore = PHPeclipsePlugin.getDefault() + .getCombinedPreferenceStore(); + + private DefaultMarkerAnnotationAccess fAnnotationAccess = new DefaultMarkerAnnotationAccess(); - private IPreferenceStore fStore= PHPeclipsePlugin.getDefault().getCombinedPreferenceStore(); - private DefaultMarkerAnnotationAccess fAnnotationAccess= new DefaultMarkerAnnotationAccess(); private boolean fAllAnnotations; - - + public AbstractAnnotationHover(boolean allAnnotations) { - fAllAnnotations= allAnnotations; + fAllAnnotations = allAnnotations; } - + /* * Formats a message as HTML text. */ private String formatMessage(String message) { - StringBuffer buffer= new StringBuffer(); + StringBuffer buffer = new StringBuffer(); HTMLPrinter.addPageProlog(buffer); - HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message)); + HTMLPrinter.addParagraph(buffer, HTMLPrinter + .convertToHTMLContent(message)); HTMLPrinter.addPageEpilog(buffer); return buffer.toString(); } - + /* * @see ITextHover#getHoverInfo(ITextViewer, IRegion) */ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { - + if (getEditor() == null) return null; - - IDocumentProvider provider= PHPeclipsePlugin.getDefault().getCompilationUnitDocumentProvider(); - IAnnotationModel model= provider.getAnnotationModel(getEditor().getEditorInput()); - + + IDocumentProvider provider = PHPeclipsePlugin.getDefault() + .getCompilationUnitDocumentProvider(); + IAnnotationModel model = provider.getAnnotationModel(getEditor() + .getEditorInput()); + if (model != null) { - Iterator e= new JavaAnnotationIterator(model, true, fAllAnnotations); - int layer= -1; - String message= null; + Iterator e = new JavaAnnotationIterator(model, true, + fAllAnnotations); + int layer = -1; + String message = null; while (e.hasNext()) { - Annotation a= (Annotation) e.next(); + Annotation a = (Annotation) e.next(); - AnnotationPreference preference= getAnnotationPreference(a); - if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey())))) + AnnotationPreference preference = getAnnotationPreference(a); + if (preference == null + || !(preference.getTextPreferenceKey() != null + && fStore.getBoolean(preference + .getTextPreferenceKey()) || (preference + .getHighlightPreferenceKey() != null && fStore + .getBoolean(preference + .getHighlightPreferenceKey())))) continue; - Position p= model.getPosition(a); - - int l= fAnnotationAccess.getLayer(a); - - if (l > layer && p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) { - String msg= a.getText(); + Position p = model.getPosition(a); + + int l = fAnnotationAccess.getLayer(a); + + if (l > layer + && p != null + && p.overlapsWith(hoverRegion.getOffset(), hoverRegion + .getLength())) { + String msg = a.getText(); if (msg != null && msg.trim().length() > 0) { - message= msg; - layer= l; + message = msg; + layer = l; } } } if (layer > -1) return formatMessage(message); } - + return null; } - + /* * @see IJavaEditorTextHover#setEditor(IEditorPart) */ @@ -111,14 +126,16 @@ public abstract class AbstractAnnotationHover extends AbstractJavaEditorTextHove /** * Returns the annotation preference for the given annotation. - * - * @param annotation the annotation + * + * @param annotation + * the annotation * @return the annotation preference or null if none - */ + */ private AnnotationPreference getAnnotationPreference(Annotation annotation) { - + if (annotation.isMarkedDeleted()) return null; - return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation); + return EditorsUI.getAnnotationPreferenceLookup() + .getAnnotationPreference(annotation); } }