diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java index c896bc2b53b..9ddfdec8f60 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2006 QNX Software Systems and others. + * Copyright (c) 2002, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -361,23 +361,6 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB } CEditorTextHoverDescriptor[] getContributedHovers() { - CEditorTextHoverDescriptor[] hoverDescriptors= CUIPlugin.getDefault().getCEditorTextHoverDescriptors(); - - // Move Best Match hover to front - - boolean done= false; - for (int i= 0; !done && i < hoverDescriptors.length; i++) { - if (PreferenceConstants.ID_BESTMATCH_HOVER.equals(hoverDescriptors[i].getId())) { - // Swap with first one - CEditorTextHoverDescriptor tmpHover= hoverDescriptors[0]; - hoverDescriptors[0]= hoverDescriptors[i]; - hoverDescriptors[i]= tmpHover; - return hoverDescriptors; - } - - } - - // return unchanged array if best match hover can't be found return CUIPlugin.getDefault().getCEditorTextHoverDescriptors(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index b1b2c1ab70b..6a217fdd747 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -734,25 +734,38 @@ public class CUIPlugin extends AbstractUIPlugin { CEditorTextHoverDescriptor hoverDescriptor= null; - if (first > -1 && problemHoverIndex > -1 && problemHoverIndex != first) { + if (first > -1 && problemHoverIndex > -1 && problemHoverIndex > first) { // move problem hover to beginning - hoverDescriptor= fCEditorTextHoverDescriptors[first]; - fCEditorTextHoverDescriptors[first]= fCEditorTextHoverDescriptors[problemHoverIndex]; - fCEditorTextHoverDescriptors[problemHoverIndex]= hoverDescriptor; + hoverDescriptor= fCEditorTextHoverDescriptors[problemHoverIndex]; + System.arraycopy(fCEditorTextHoverDescriptors, first, fCEditorTextHoverDescriptors, first+1, problemHoverIndex - first); + fCEditorTextHoverDescriptors[first]= hoverDescriptor; // update annotation hover index if needed - if (annotationHoverIndex == first) - annotationHoverIndex= problemHoverIndex; + if (annotationHoverIndex > first && annotationHoverIndex < problemHoverIndex) + annotationHoverIndex++; } - if (annotationHoverIndex > -1 && annotationHoverIndex != last) { + if (annotationHoverIndex > -1 && annotationHoverIndex < last) { // move annotation hover to end - hoverDescriptor= fCEditorTextHoverDescriptors[last]; - fCEditorTextHoverDescriptors[last]= fCEditorTextHoverDescriptors[annotationHoverIndex]; - fCEditorTextHoverDescriptors[annotationHoverIndex]= hoverDescriptor; + hoverDescriptor= fCEditorTextHoverDescriptors[annotationHoverIndex]; + System.arraycopy(fCEditorTextHoverDescriptors, annotationHoverIndex+1, fCEditorTextHoverDescriptors, annotationHoverIndex, last - annotationHoverIndex); + fCEditorTextHoverDescriptors[last]= hoverDescriptor; + } + + // Move Best Match hover to front + for (int i= 0; i < length; i++) { + if (PreferenceConstants.ID_BESTMATCH_HOVER.equals(fCEditorTextHoverDescriptors[i].getId())) { + if (i > 0) { + // move to top + CEditorTextHoverDescriptor bestMatchHover= fCEditorTextHoverDescriptors[i]; + System.arraycopy(fCEditorTextHoverDescriptors, 0, fCEditorTextHoverDescriptors, 1, i); + fCEditorTextHoverDescriptors[0]= bestMatchHover; + } + break; + } + } } - return fCEditorTextHoverDescriptors; }