mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 18:25:40 +02:00
Avoid unnecessarily storing document in actions (#607)
With the first part of the fix in #603 we recreate the document regularly (on each context change) therefore we need to let any consumers of the document fetch the current version of the document from the editor (by calling getAdapter(IDocument.class)) when it is needed, rather than caching it. Fixes #603
This commit is contained in:
parent
27bee70634
commit
08abfa2957
3 changed files with 5 additions and 7 deletions
|
@ -109,6 +109,7 @@ import org.eclipse.jface.resource.JFaceResources;
|
||||||
import org.eclipse.jface.resource.ResourceLocator;
|
import org.eclipse.jface.resource.ResourceLocator;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.BadPositionCategoryException;
|
import org.eclipse.jface.text.BadPositionCategoryException;
|
||||||
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.IFindReplaceTarget;
|
import org.eclipse.jface.text.IFindReplaceTarget;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.ITextOperationTarget;
|
import org.eclipse.jface.text.ITextOperationTarget;
|
||||||
|
@ -580,8 +581,9 @@ public abstract class DisassemblyPart extends WorkbenchPart
|
||||||
if (fColumnSupport == null)
|
if (fColumnSupport == null)
|
||||||
fColumnSupport = createColumnSupport();
|
fColumnSupport = createColumnSupport();
|
||||||
return (T) fColumnSupport;
|
return (T) fColumnSupport;
|
||||||
|
} else if (IDocument.class.equals(required)) {
|
||||||
|
return (T) getDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getAdapter(required);
|
return super.getAdapter(required);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,7 @@ public class RulerToggleBreakpointActionDelegate extends AbstractDisassemblyRule
|
||||||
if (fDelegate != null) {
|
if (fDelegate != null) {
|
||||||
fDelegate.dispose();
|
fDelegate.dispose();
|
||||||
}
|
}
|
||||||
return fDelegate = new ToggleBreakpointAction(disassemblyPart, disassemblyPart.getTextViewer().getDocument(),
|
return fDelegate = new ToggleBreakpointAction(disassemblyPart, null, rulerInfo);
|
||||||
rulerInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
|
import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
|
||||||
import org.eclipse.jface.text.IDocument;
|
|
||||||
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
||||||
import org.eclipse.swt.widgets.Event;
|
import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
@ -36,11 +35,9 @@ public class RulerToggleBreakpointHandler extends AbstractHandler {
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
|
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
|
||||||
if (part instanceof IDisassemblyPart) {
|
if (part instanceof IDisassemblyPart) {
|
||||||
IDisassemblyPart disassemblyPart = (IDisassemblyPart) part;
|
|
||||||
IDocument document = disassemblyPart.getTextViewer().getDocument();
|
|
||||||
final IVerticalRulerInfo rulerInfo = part.getAdapter(IVerticalRulerInfo.class);
|
final IVerticalRulerInfo rulerInfo = part.getAdapter(IVerticalRulerInfo.class);
|
||||||
if (rulerInfo != null) {
|
if (rulerInfo != null) {
|
||||||
final ToggleBreakpointAction toggleBpAction = new ToggleBreakpointAction(part, document, rulerInfo);
|
final ToggleBreakpointAction toggleBpAction = new ToggleBreakpointAction(part, null, rulerInfo);
|
||||||
try {
|
try {
|
||||||
toggleBpAction.update();
|
toggleBpAction.update();
|
||||||
if (toggleBpAction.isEnabled()) {
|
if (toggleBpAction.isEnabled()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue