Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 151904 Details for
Bug 294812
[hover] Improper hover order prevents using the right hover
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Small tweak to previous fix
zpatch.hover.txt (text/plain), 5.77 KB, created by
Marc Khouzam
on 2009-11-10 21:21:22 EST
(
hide
)
Description:
Small tweak to previous fix
Filename:
MIME Type:
Creator:
Marc Khouzam
Created:
2009-11-10 21:21:22 EST
Size:
5.77 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.ui >Index: src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java,v >retrieving revision 1.9 >diff -u -r1.9 BestMatchHover.java >--- src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java 17 Apr 2008 13:43:54 -0000 1.9 >+++ src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java 11 Nov 2009 02:24:00 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2002, 2008 QNX Software Systems and others. >+ * Copyright (c) 2009 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 >@@ -8,6 +8,7 @@ > * Contributors: > * QNX Software Systems - Initial API and implementation > * Anton Leherbauer (Wind River Systems) >+ * ERicsson - Fix improper hover order (Bug 294812) > *******************************************************************************/ > > package org.eclipse.cdt.internal.ui.text.c.hover; >@@ -16,9 +17,6 @@ > import java.util.Iterator; > import java.util.List; > >-import org.eclipse.cdt.ui.CUIPlugin; >-import org.eclipse.cdt.ui.PreferenceConstants; >-import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover; > import org.eclipse.jface.text.IInformationControlCreator; > import org.eclipse.jface.text.IRegion; > import org.eclipse.jface.text.ITextHover; >@@ -28,14 +26,23 @@ > import org.eclipse.jface.text.information.IInformationProviderExtension2; > import org.eclipse.ui.IEditorPart; > >+import org.eclipse.cdt.ui.CUIPlugin; >+import org.eclipse.cdt.ui.PreferenceConstants; >+import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover; >+ > /** > * BestMatchHover >+ * This is not a real hover, but instead, it is always the first hover used >+ * and it will choose the best of the real hovers. To choose the best hover, >+ * we simply find the first hover that returns some text. This implies >+ * that the order of hovers is important and must be preserved. (Bug 294812) > */ > public class BestMatchHover extends AbstractCEditorTextHover { > > private List<CEditorTextHoverDescriptor> fTextHoverSpecifications; >- private List<ITextHover> fInstantiatedTextHovers; >+ private ITextHover[] fInstantiatedTextHovers; > private ITextHover fBestHover; >+ private int fNullEntryCount; > > public BestMatchHover() { > installTextHovers(); >@@ -50,13 +57,13 @@ > * Installs all text hovers. > */ > private void installTextHovers() { >+ CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors(); > > // initialize lists - indicates that the initialization happened >- fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(2); >- fInstantiatedTextHovers= new ArrayList<ITextHover>(2); >+ fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(hoverDescs.length-1); >+ fInstantiatedTextHovers= new ITextHover[hoverDescs.length-1]; > > // populate list >- CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors(); > for (int i= 0; i < hoverDescs.length; i++) { > // ensure that we don't add ourselves to the list > if (!PreferenceConstants.ID_BESTMATCH_HOVER.equals(hoverDescs[i].getId())) >@@ -68,21 +75,36 @@ > if (fTextHoverSpecifications.size() == 0) > return; > >- for (Iterator<CEditorTextHoverDescriptor> iterator= new ArrayList<CEditorTextHoverDescriptor>(fTextHoverSpecifications).iterator(); iterator.hasNext(); ) { >+ fNullEntryCount= 0; >+ for (Iterator<CEditorTextHoverDescriptor> iterator= fTextHoverSpecifications.iterator(); iterator.hasNext(); ) { > CEditorTextHoverDescriptor spec= iterator.next(); > > ICEditorTextHover hover= spec.createTextHover(); > if (hover != null) { > hover.setEditor(getEditor()); >- addTextHover(hover); >- fTextHoverSpecifications.remove(spec); >+ iterator.remove(); >+ } >+ // Add the hover, even if it is null, so that we keep a spot >+ // for the missing hovers, for later. This is to preserve their >+ // order, which is important in determining the best hover >+ addTextHover(hover); >+ if (hover == null) { >+ fNullEntryCount++; > } > } > } > > protected void addTextHover(ITextHover hover) { >- if (!fInstantiatedTextHovers.contains(hover)) >- fInstantiatedTextHovers.add(hover); >+ int nullCount= 0; >+ for (int i= 0; i < fInstantiatedTextHovers.length; i++) { >+ if (fInstantiatedTextHovers[i] == null) { >+ if (fNullEntryCount == nullCount) { >+ fInstantiatedTextHovers[i]= hover; >+ return; >+ } >+ nullCount++; >+ } >+ } > } > > /* >@@ -98,8 +120,8 @@ > if (fInstantiatedTextHovers == null) > return null; > >- for (Iterator<ITextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) { >- ITextHover hover= iterator.next(); >+ for (ITextHover hover : fInstantiatedTextHovers) { >+ if (hover == null) continue; > > String s= hover.getHoverInfo(textViewer, hoverRegion); > if (s != null && s.trim().length() > 0) { >@@ -124,9 +146,9 @@ > if (fInstantiatedTextHovers == null) > return null; > >- for (Iterator<ITextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) { >- ITextHover hover= iterator.next(); >- >+ for (ITextHover hover : fInstantiatedTextHovers) { >+ if (hover == null) continue; >+ > if (hover instanceof ITextHoverExtension2) { > Object info= ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion); > if (info != null) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
marc.khouzam
:
iplog-
Actions:
View
|
Diff
Attachments on
bug 294812
:
151880
|
151904
|
151932
|
151941