mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Enable hovers for information presenter, related to bug 282495
This commit is contained in:
parent
6cd02fdd00
commit
024efc1e22
2 changed files with 10 additions and 33 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2010 Wind River Systems, Inc. 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
|
||||
|
@ -10,18 +10,14 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
|
||||
import org.eclipse.jface.text.IInformationControl;
|
||||
import org.eclipse.jface.text.IInformationControlCreator;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.text.ITextViewer;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.part.IWorkbenchPartOrientation;
|
||||
|
||||
/**
|
||||
* A hover to explore macro expansion.
|
||||
|
@ -30,8 +26,6 @@ import org.eclipse.ui.IEditorPart;
|
|||
*/
|
||||
public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||
|
||||
private Reference<CMacroExpansionInput> fCache;
|
||||
|
||||
@Override
|
||||
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
||||
Object hoverInfo= getHoverInfo2(textViewer, hoverRegion);
|
||||
|
@ -66,30 +60,13 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
|||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||
return new IInformationControlCreator() {
|
||||
public IInformationControl createInformationControl(Shell parent) {
|
||||
return new CMacroExpansionExplorationControl(parent, getCachedMacroExpansionInput());
|
||||
IEditorPart editor= getEditor();
|
||||
int orientation= SWT.NONE;
|
||||
if (editor instanceof IWorkbenchPartOrientation)
|
||||
orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
|
||||
return new SourceViewerInformationControl(parent, true, orientation, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected CMacroExpansionInput getCachedMacroExpansionInput() {
|
||||
if (fCache == null) {
|
||||
return null;
|
||||
}
|
||||
CMacroExpansionInput input= fCache.get();
|
||||
fCache= null;
|
||||
if (input == null) {
|
||||
IEditorPart editor= getEditor();
|
||||
if (editor != null) {
|
||||
ISelectionProvider provider= editor.getSite().getSelectionProvider();
|
||||
ISelection selection= provider.getSelection();
|
||||
if (selection instanceof ITextSelection) {
|
||||
ITextSelection textSelection= (ITextSelection) selection;
|
||||
IRegion region= new Region(textSelection.getOffset(), textSelection.getLength());
|
||||
input= CMacroExpansionInput.create(editor, region, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2002, 2010 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
|
||||
|
@ -834,7 +834,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
|||
int orientation= SWT.NONE;
|
||||
if (editor instanceof IWorkbenchPartOrientation)
|
||||
orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
|
||||
return new SourceViewerInformationControl(parent, true, orientation, getTooltipAffordanceString());
|
||||
return new SourceViewerInformationControl(parent, true, orientation, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue