int length= fJavaEditorTextHoverDescriptors.length; int first= -1; int last= length - 1; int problemHoverIndex= -1; int annotationHoverIndex= -1; for (int i= 0; i < length; i++) { if (!fJavaEditorTextHoverDescriptors[i].getId().startsWith(JavaUI.ID_PLUGIN)) { if (problemHoverIndex == -1 || annotationHoverIndex == -1) continue; last= i - 1; break; } if (first == -1) first= i;  if (fJavaEditorTextHoverDescriptors[i].getId().equals("org.eclipse.jdt.ui.AnnotationHover")) { annotationHoverIndex= i; continue; } if (fJavaEditorTextHoverDescriptors[i].getId().equals("org.eclipse.jdt.ui.ProblemHover")) { problemHoverIndex= i; continue; } }  JavaEditorTextHoverDescriptor hoverDescriptor= null;  if (first > -1 && problemHoverIndex > -1 && problemHoverIndex != first) {  hoverDescriptor= fJavaEditorTextHoverDescriptors[first]; fJavaEditorTextHoverDescriptors[first]= fJavaEditorTextHoverDescriptors[problemHoverIndex]; fJavaEditorTextHoverDescriptors[problemHoverIndex]= hoverDescriptor;   if (annotationHoverIndex == first) annotationHoverIndex= problemHoverIndex; }  if (annotationHoverIndex > -1 && annotationHoverIndex != last) {  hoverDescriptor= fJavaEditorTextHoverDescriptors[last]; fJavaEditorTextHoverDescriptors[last]= fJavaEditorTextHoverDescriptors[annotationHoverIndex]; fJavaEditorTextHoverDescriptors[annotationHoverIndex]= hoverDescriptor; }
	public JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() {		if (fJavaEditorTextHoverDescriptors == null) {			fJavaEditorTextHoverDescriptors= JavaEditorTextHoverDescriptor.getContributedHovers();			ConfigurationElementSorter sorter= new ConfigurationElementSorter() {				/*				 * @see org.eclipse.ui.texteditor.ConfigurationElementSorter#getConfigurationElement(java.lang.Object)				 */				public IConfigurationElement getConfigurationElement(Object object) {					return ((JavaEditorTextHoverDescriptor)object).getConfigurationElement();				}			};			sorter.sort(fJavaEditorTextHoverDescriptors);					// The Problem hover has to be the first and the Annotation hover has to be the last one in the JDT UI's hover list			int length= fJavaEditorTextHoverDescriptors.length;			int first= -1;			int last= length - 1;			int problemHoverIndex= -1;			int annotationHoverIndex= -1;			for (int i= 0; i < length; i++) {				if (!fJavaEditorTextHoverDescriptors[i].getId().startsWith(JavaUI.ID_PLUGIN)) {					if (problemHoverIndex == -1 || annotationHoverIndex == -1)						continue;					last= i - 1;					break;				}				if (first == -1)					first= i;								if (fJavaEditorTextHoverDescriptors[i].getId().equals("org.eclipse.jdt.ui.AnnotationHover")) { //$NON-NLS-1$					annotationHoverIndex= i;					continue;				}				if (fJavaEditorTextHoverDescriptors[i].getId().equals("org.eclipse.jdt.ui.ProblemHover")) { //$NON-NLS-1$					problemHoverIndex= i;					continue;				}			}				JavaEditorTextHoverDescriptor hoverDescriptor= null;						if (first > -1 && problemHoverIndex > -1 && problemHoverIndex != first) {				// move problem hover to beginning				hoverDescriptor= fJavaEditorTextHoverDescriptors[first];				fJavaEditorTextHoverDescriptors[first]= fJavaEditorTextHoverDescriptors[problemHoverIndex];				fJavaEditorTextHoverDescriptors[problemHoverIndex]= hoverDescriptor;				// update annotation hover index if needed				if (annotationHoverIndex == first)					annotationHoverIndex= problemHoverIndex;			}						if (annotationHoverIndex > -1 && annotationHoverIndex != last) {				// move annotation hover to end				hoverDescriptor= fJavaEditorTextHoverDescriptors[last];				fJavaEditorTextHoverDescriptors[last]= fJavaEditorTextHoverDescriptors[annotationHoverIndex];				fJavaEditorTextHoverDescriptors[annotationHoverIndex]= hoverDescriptor;			}						// Move Best Match hover to front			for (int i= 0; i < fJavaEditorTextHoverDescriptors.length - 1; i++) {				if (PreferenceConstants.ID_BESTMATCH_HOVER.equals(fJavaEditorTextHoverDescriptors[i].getId())) {					hoverDescriptor= fJavaEditorTextHoverDescriptors[i];					for (int j= i; j > 0; j--)						fJavaEditorTextHoverDescriptors[j]= fJavaEditorTextHoverDescriptors[j-1];					fJavaEditorTextHoverDescriptors[0]= hoverDescriptor;					break;				}							}		}				return fJavaEditorTextHoverDescriptors;	} 