Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unnecessarily storing document in actions #607

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
import org.eclipse.jface.resource.ResourceLocator;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IFindReplaceTarget;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextOperationTarget;
Expand Down Expand Up @@ -580,8 +581,9 @@ public <T> T getAdapter(Class<T> required) {
if (fColumnSupport == null)
fColumnSupport = createColumnSupport();
return (T) fColumnSupport;
} else if (IDocument.class.equals(required)) {
return (T) getDocument();
}

return super.getAdapter(required);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ protected IAction createAction(IDisassemblyPart disassemblyPart, IVerticalRulerI
if (fDelegate != null) {
fDelegate.dispose();
}
return fDelegate = new ToggleBreakpointAction(disassemblyPart, disassemblyPart.getTextViewer().getDocument(),
rulerInfo);
return fDelegate = new ToggleBreakpointAction(disassemblyPart, null, rulerInfo);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IWorkbenchPart;
Expand All @@ -36,11 +35,9 @@ public class RulerToggleBreakpointHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
if (part instanceof IDisassemblyPart) {
IDisassemblyPart disassemblyPart = (IDisassemblyPart) part;
IDocument document = disassemblyPart.getTextViewer().getDocument();
final IVerticalRulerInfo rulerInfo = part.getAdapter(IVerticalRulerInfo.class);
if (rulerInfo != null) {
final ToggleBreakpointAction toggleBpAction = new ToggleBreakpointAction(part, document, rulerInfo);
final ToggleBreakpointAction toggleBpAction = new ToggleBreakpointAction(part, null, rulerInfo);
try {
toggleBpAction.update();
if (toggleBpAction.isEnabled()) {
Expand Down