mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
[309001] Too many debug hovers in Preferences
This commit is contained in:
parent
caa6d148db
commit
1e118a7e58
9 changed files with 231 additions and 27 deletions
|
@ -1081,10 +1081,19 @@
|
||||||
<hover
|
<hover
|
||||||
label="%DebugTextHover.label"
|
label="%DebugTextHover.label"
|
||||||
description="%DebugTextHover.description"
|
description="%DebugTextHover.description"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover"
|
class="org.eclipse.cdt.debug.internal.ui.editors.DelegatingDebugTextHover"
|
||||||
id="org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover">
|
id="org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover">
|
||||||
</hover>
|
</hover>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.core.runtime.adapters">
|
||||||
|
<factory
|
||||||
|
adaptableType="org.eclipse.cdt.debug.core.model.ICStackFrame"
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.editors.DebugTextHoverAdapterFactory">
|
||||||
|
<adapter type="org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover"/>
|
||||||
|
</factory>
|
||||||
|
</extension>
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.debug.core.statusHandlers">
|
point="org.eclipse.debug.core.statusHandlers">
|
||||||
<statusHandler
|
<statusHandler
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.editors;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICStackFrame;
|
||||||
|
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
|
import org.eclipse.core.runtime.IAdapterFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter factory adapting an {@link ICStackFrame} to an {@link ICEditorTextHover}.
|
||||||
|
*
|
||||||
|
* @since 7.0
|
||||||
|
*/
|
||||||
|
public class DebugTextHoverAdapterFactory implements IAdapterFactory {
|
||||||
|
|
||||||
|
private static final Class<?>[] TYPES = { ICEditorTextHover.class };
|
||||||
|
private static final Object fDebugTextHover= new DebugTextHover();
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||||
|
if (adaptableObject instanceof ICStackFrame) {
|
||||||
|
return fDebugTextHover;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public Class[] getAdapterList() {
|
||||||
|
return TYPES;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.editors;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
|
import org.eclipse.jface.text.IInformationControlCreator;
|
||||||
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
import org.eclipse.jface.text.ITextHoverExtension;
|
||||||
|
import org.eclipse.jface.text.ITextHoverExtension2;
|
||||||
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common debug text hover delegating to debugger specific implementations
|
||||||
|
* based on active debug context.
|
||||||
|
*
|
||||||
|
* @since 7.0
|
||||||
|
*/
|
||||||
|
public class DelegatingDebugTextHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2 {
|
||||||
|
|
||||||
|
private IEditorPart fEditor;
|
||||||
|
private ICEditorTextHover fDelegate;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
|
||||||
|
*/
|
||||||
|
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
|
||||||
|
fDelegate = getDelegate();
|
||||||
|
if (fDelegate != null) {
|
||||||
|
return fDelegate.getHoverRegion(viewer, offset);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
|
fDelegate = getDelegate();
|
||||||
|
if (fDelegate != null) {
|
||||||
|
return fDelegate.getHoverInfo(textViewer, hoverRegion);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
|
fDelegate = getDelegate();
|
||||||
|
if (fDelegate instanceof ITextHoverExtension2) {
|
||||||
|
return ((ITextHoverExtension2) fDelegate).getHoverInfo2(textViewer, hoverRegion);
|
||||||
|
}
|
||||||
|
// fall back to legacy method
|
||||||
|
if (fDelegate != null) {
|
||||||
|
return fDelegate.getHoverInfo(textViewer, hoverRegion);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
|
||||||
|
*/
|
||||||
|
public IInformationControlCreator getHoverControlCreator() {
|
||||||
|
if (fDelegate instanceof ITextHoverExtension) {
|
||||||
|
return ((ITextHoverExtension) fDelegate).getHoverControlCreator();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover#setEditor(org.eclipse.ui.IEditorPart)
|
||||||
|
*/
|
||||||
|
public final void setEditor(IEditorPart editor) {
|
||||||
|
fEditor = editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICEditorTextHover getDelegate() {
|
||||||
|
IAdaptable context = DebugUITools.getDebugContext();
|
||||||
|
if (context != null) {
|
||||||
|
ICEditorTextHover hover = (ICEditorTextHover) context.getAdapter(ICEditorTextHover.class);
|
||||||
|
if (hover != null) {
|
||||||
|
hover.setEditor(fEditor);
|
||||||
|
}
|
||||||
|
return hover;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,9 +24,6 @@ launchTab.sourceLookup.name=Source
|
||||||
launchTab.common.name=Common
|
launchTab.common.name=Common
|
||||||
launchTab.environment.name=Environment
|
launchTab.environment.name=Environment
|
||||||
|
|
||||||
editorTextHover.label=GDB Debugger
|
|
||||||
editorTextHover.description=Shows formatted value in debugger hover
|
|
||||||
|
|
||||||
breakpoints.property.filter=Filter
|
breakpoints.property.filter=Filter
|
||||||
tracepoints.property.common=Common
|
tracepoints.property.common=Common
|
||||||
tracepoints.property.actions=Actions
|
tracepoints.property.actions=Actions
|
||||||
|
|
|
@ -318,15 +318,6 @@
|
||||||
</initializer>
|
</initializer>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<extension
|
|
||||||
point="org.eclipse.cdt.ui.textHovers">
|
|
||||||
<hover
|
|
||||||
label="%editorTextHover.label"
|
|
||||||
description="%editorTextHover.description"
|
|
||||||
class="org.eclipse.cdt.dsf.gdb.internal.ui.GdbDebugTextHover"
|
|
||||||
id="org.eclipse.cdt.dsf.gdb.ui.GdbDebugTextHover">
|
|
||||||
</hover>
|
|
||||||
</extension>
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.debug.ui.contextViewBindings">
|
point="org.eclipse.debug.ui.contextViewBindings">
|
||||||
</extension>
|
</extension>
|
||||||
|
|
|
@ -58,6 +58,7 @@ import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.GdbViewModelAdapter;
|
||||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
||||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate;
|
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
|
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
import org.eclipse.core.runtime.IAdapterFactory;
|
import org.eclipse.core.runtime.IAdapterFactory;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.ILaunch;
|
import org.eclipse.debug.core.ILaunch;
|
||||||
|
@ -118,7 +119,8 @@ public class GdbAdapterFactory
|
||||||
final GdbStartTracingCommand fStartTracingTarget;
|
final GdbStartTracingCommand fStartTracingTarget;
|
||||||
final GdbStopTracingCommand fStopTracingTarget;
|
final GdbStopTracingCommand fStopTracingTarget;
|
||||||
final GdbSaveTraceDataCommand fSaveTraceDataTarget;
|
final GdbSaveTraceDataCommand fSaveTraceDataTarget;
|
||||||
|
final GdbDebugTextHover fDebugTextHover;
|
||||||
|
|
||||||
SessionAdapterSet(GdbLaunch launch) {
|
SessionAdapterSet(GdbLaunch launch) {
|
||||||
fLaunch = launch;
|
fLaunch = launch;
|
||||||
DsfSession session = launch.getSession();
|
DsfSession session = launch.getSession();
|
||||||
|
@ -196,6 +198,12 @@ public class GdbAdapterFactory
|
||||||
* session.
|
* session.
|
||||||
*/
|
*/
|
||||||
session.registerModelAdapter(ILaunch.class, fLaunch);
|
session.registerModelAdapter(ILaunch.class, fLaunch);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register debug hover adapter (bug 309001).
|
||||||
|
*/
|
||||||
|
fDebugTextHover = new GdbDebugTextHover();
|
||||||
|
session.registerModelAdapter(ICEditorTextHover.class, fDebugTextHover);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
@ -231,6 +239,8 @@ public class GdbAdapterFactory
|
||||||
session.unregisterModelAdapter(IStopTracingHandler.class);
|
session.unregisterModelAdapter(IStopTracingHandler.class);
|
||||||
session.unregisterModelAdapter(ISaveTraceDataHandler.class);
|
session.unregisterModelAdapter(ISaveTraceDataHandler.class);
|
||||||
|
|
||||||
|
session.unregisterModelAdapter(ICEditorTextHover.class);
|
||||||
|
|
||||||
fSteppingModeTarget.dispose();
|
fSteppingModeTarget.dispose();
|
||||||
fStepIntoCommand.dispose();
|
fStepIntoCommand.dispose();
|
||||||
fReverseStepIntoCommand.dispose();
|
fReverseStepIntoCommand.dispose();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2006, 2009 Wind River Systems and others.
|
# Copyright (c) 2006, 2010 Wind River Systems and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -58,6 +58,4 @@ StaleData.foreground.description=This color is used to indicate that a given ele
|
||||||
StaleData.background.label=Stale data background color
|
StaleData.background.label=Stale data background color
|
||||||
StaleData.background.description=This color is used to indicate that a given element of data in a view is stale. User should refresh the view to see current data. The background color is used only when the view is in no-columns mode.
|
StaleData.background.description=This color is used to indicate that a given element of data in a view is stale. User should refresh the view to see current data. The background color is used only when the view is in no-columns mode.
|
||||||
|
|
||||||
editorTextHover.label=Debugger
|
debugUpdateModes.label = Debug Update Modes
|
||||||
editorTextHover.description=Shows formatted value in debugger hover
|
|
||||||
debugUpdateModes.label = Debug Update Modes
|
|
||||||
|
|
|
@ -671,15 +671,6 @@
|
||||||
</description>
|
</description>
|
||||||
</colorDefinition>
|
</colorDefinition>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
|
||||||
point="org.eclipse.cdt.ui.textHovers">
|
|
||||||
<hover
|
|
||||||
label="%editorTextHover.label"
|
|
||||||
description="%editorTextHover.description"
|
|
||||||
class="org.eclipse.cdt.dsf.debug.ui.DsfDebugTextHover"
|
|
||||||
id="org.eclipse.cdt.dsf.debug.ui.DsfDebugTextHover">
|
|
||||||
</hover>
|
|
||||||
</extension>
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.activities">
|
point="org.eclipse.ui.activities">
|
||||||
<activity
|
<activity
|
||||||
|
@ -749,4 +740,16 @@
|
||||||
</toggleTargetFactory>
|
</toggleTargetFactory>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
<!-- Adpater factory for common DSF debug text hover support.
|
||||||
|
This can be overridden by inidividual session adapters.
|
||||||
|
-->
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.core.runtime.adapters">
|
||||||
|
<factory
|
||||||
|
adaptableType="org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext"
|
||||||
|
class="org.eclipse.cdt.dsf.debug.internal.ui.DebugTextHoverAdapterFactory">
|
||||||
|
<adapter type="org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover"/>
|
||||||
|
</factory>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.debug.internal.ui;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.DsfDebugTextHover;
|
||||||
|
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||||
|
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
|
import org.eclipse.core.runtime.IAdapterFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapter factory adapting an {@link IDMVMContext} to an {@link ICEditorTextHover}.
|
||||||
|
*
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class DebugTextHoverAdapterFactory implements IAdapterFactory {
|
||||||
|
|
||||||
|
private static final Class<?>[] TYPES = { ICEditorTextHover.class };
|
||||||
|
private static final Object fDebugTextHover= new DsfDebugTextHover();
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||||
|
if (adaptableObject instanceof IDMVMContext) {
|
||||||
|
IDMContext dmc = ((IDMVMContext) adaptableObject).getDMContext();
|
||||||
|
// try session specific hover
|
||||||
|
Object sessionHover = dmc.getAdapter(adapterType);
|
||||||
|
if (sessionHover != null) {
|
||||||
|
return sessionHover;
|
||||||
|
}
|
||||||
|
// use default
|
||||||
|
IFrameDMContext frameDmc = DMContexts.getAncestorOfType(dmc, IFrameDMContext.class);
|
||||||
|
if (frameDmc != null) {
|
||||||
|
return fDebugTextHover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public Class[] getAdapterList() {
|
||||||
|
return TYPES;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue