A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / java / hover / AnnotationHover.java
index 499e8db..55579c3 100644 (file)
@@ -35,54 +35,67 @@ import org.eclipse.ui.texteditor.AnnotationPreference;
 import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 
-
 public class AnnotationHover extends AbstractJavaEditorTextHover {
 
-       private IPreferenceStore fStore= PHPeclipsePlugin.getDefault().getPreferenceStore();
-       private DefaultMarkerAnnotationAccess fAnnotationAccess= new DefaultMarkerAnnotationAccess();
+       private IPreferenceStore fStore = PHPeclipsePlugin.getDefault()
+                       .getPreferenceStore();
+
+       private DefaultMarkerAnnotationAccess fAnnotationAccess = new DefaultMarkerAnnotationAccess();
+
        private PHPTextHover fPHPTextHover = null;
+
        /*
         * 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, message); //HTMLPrinter.convertToHTMLContent(message));
+               HTMLPrinter.addParagraph(buffer, message); // 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());
-               String message= null;
+
+               IDocumentProvider provider = PHPeclipsePlugin.getDefault()
+                               .getCompilationUnitDocumentProvider();
+               IAnnotationModel model = provider.getAnnotationModel(getEditor()
+                               .getEditorInput());
+               String message = null;
                if (model != null) {
-                       Iterator e= new JavaAnnotationIterator(model, true);
-                       int layer= -1;
-                       
+                       Iterator e = new JavaAnnotationIterator(model, true);
+                       int layer = -1;
+
                        while (e.hasNext()) {
-                               Annotation a= (Annotation) e.next();
+                               Annotation a = (Annotation) e.next();
 
-                               AnnotationPreference preference= getAnnotationPreference(a);
-                               if (preference == null || !(fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
+                               AnnotationPreference preference = getAnnotationPreference(a);
+                               if (preference == 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;
                                        }
                                }
                        }
@@ -90,15 +103,15 @@ public class AnnotationHover extends AbstractJavaEditorTextHover {
                                return formatMessage(message);
                }
                // Added as long as the above doesn't work
-               if (fPHPTextHover!=null) {
-                 message = fPHPTextHover.getHoverInfo(textViewer, hoverRegion);
-                 if (message!=null) {
-                   return formatMessage(message);
-                 }
+               if (fPHPTextHover != null) {
+                       message = fPHPTextHover.getHoverInfo(textViewer, hoverRegion);
+                       if (message != null) {
+                               return formatMessage(message);
+                       }
                }
                return null;
        }
-       
+
        /*
         * @see IJavaEditorTextHover#setEditor(IEditorPart)
         */
@@ -111,7 +124,7 @@ public class AnnotationHover extends AbstractJavaEditorTextHover {
                                        try {
                                                IFile f = ((IFileEditorInput) editorInput).getFile();
                                                fPHPTextHover = new PHPTextHover(f.getProject());
-                                           return;
+                                               return;
                                        } catch (NullPointerException e) {
                                                // this exception occurs, if getTextHover is called by
                                                // preference pages !
@@ -126,15 +139,17 @@ public class AnnotationHover extends AbstractJavaEditorTextHover {
 
        /**
         * Returns the annotation preference for the given annotation.
-        *
-        * @param annotation the annotation
+        * 
+        * @param annotation
+        *            the annotation
         * @return the annotation preference or <code>null</code> if none
-        */     
+        */
        private AnnotationPreference getAnnotationPreference(Annotation annotation) {
-               
+
                if (annotation.isMarkedDeleted())
                        return null;
-               return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
+               return EditorsUI.getAnnotationPreferenceLookup()
+                               .getAnnotationPreference(annotation);
        }
 
        static boolean isJavaProblemHover(String id) {