xdebugger: 'jump to type source' action added

This commit is contained in:
nik
2013-09-06 17:31:05 +04:00
parent 1448c7dc0d
commit 683ece54e2
8 changed files with 119 additions and 26 deletions
@@ -891,7 +891,9 @@ action.XDebugger.CompareValueWithClipboard.description=Compare value of selected
action.XDebugger.CopyName.text=Copy Name
action.XDebugger.CopyName.description=Copy name of selected node to clipboard
action.XDebugger.JumpToSource.text=Jump To Source
action.XDebugger.JumpToSource.description=Open for the selected item
action.XDebugger.JumpToSource.description=Open source of the selected item
action.XDebugger.JumpToTypeSource.text=Jump To Type Source
action.XDebugger.JumpToTypeSource.description=Open source of the selected value's type
action.XDebugger.Inspect.text=Inspect...
action.XDebugger.AddToWatches.text=Add to Watches
action.XDebugger.RemoveWatch.text=Remove Watch
@@ -652,6 +652,7 @@
<action id="XDebugger.CopyName" class="com.intellij.xdebugger.impl.ui.tree.actions.XCopyNameAction"/>
<action id="XDebugger.Inspect" class="com.intellij.xdebugger.impl.ui.tree.actions.XInspectAction"/>
<action id="XDebugger.JumpToSource" class="com.intellij.xdebugger.impl.ui.tree.actions.XJumpToSourceAction"/>
<action id="XDebugger.JumpToTypeSource" class="com.intellij.xdebugger.impl.ui.tree.actions.XJumpToTypeSourceAction"/>
<action id="XDebugger.AddToWatches" class="com.intellij.xdebugger.impl.ui.tree.actions.XAddToWatchesAction" icon="AllIcons.Debugger.AddToWatch"/>
<action id="XDebugger.NewWatch" class="com.intellij.xdebugger.impl.frame.actions.XNewWatchAction" icon="AllIcons.Debugger.NewWatch"/>
<action id="XDebugger.EditWatch" class="com.intellij.xdebugger.impl.frame.actions.XEditWatchAction"/>
@@ -701,6 +702,7 @@
<group id="XDebugger.Variables.Tree.Popup">
<reference ref="XDebugger.ValueGroup"/>
<reference ref="XDebugger.JumpToSource"/>
<reference ref="XDebugger.JumpToTypeSource"/>
<reference ref="XDebugger.AddToWatches"/>
</group>
@@ -59,4 +59,22 @@ public abstract class XValue extends XValueContainer {
public void computeSourcePosition(@NotNull XNavigatable navigatable) {
navigatable.setSourcePosition(null);
}
/**
* Return {@code true} from this method and override {@link #computeTypeSourcePosition(XNavigatable)} if navigation to the value's type
* is supported for the value
* @return {@code true} if navigation to the value's type is supported
*/
public boolean canNavigateToTypeSource() {
return false;
}
/**
* Start computing source position of the value's type and call {@link XNavigatable#setSourcePosition(com.intellij.xdebugger.XSourcePosition)}
* when computation is finished.
* Note that this method is called from the Event Dispatch thread so it should return quickly.
*/
public void computeTypeSourcePosition(@NotNull XNavigatable navigatable) {
navigatable.setSourcePosition(null);
}
}
@@ -33,9 +33,11 @@ public interface XDebuggerActions {
@NonNls String RUN_TO_CURSOR = "RunToCursor";
@NonNls String FORCE_RUN_TO_CURSOR = "ForceRunToCursor";
@NonNls String EDIT_TYPE_SOURCE = "Debugger.EditTypeSource";
@NonNls String SHOW_EXECUTION_POINT = "ShowExecutionPoint";
@NonNls String JUMP_TO_SOURCE = "XDebugger.JumpToSource";
@NonNls String JUMP_TO_TYPE_SOURCE = "XDebugger.JumpToTypeSource";
@NonNls String EVALUATE_EXPRESSION = "EvaluateExpression";
@@ -229,6 +229,7 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
actionManager.getAction(XDebuggerActions.SET_VALUE).unregisterCustomShortcutSet(this);
actionManager.getAction(XDebuggerActions.COPY_VALUE).unregisterCustomShortcutSet(this);
actionManager.getAction(XDebuggerActions.JUMP_TO_SOURCE).unregisterCustomShortcutSet(this);
actionManager.getAction(XDebuggerActions.JUMP_TO_TYPE_SOURCE).unregisterCustomShortcutSet(this);
actionManager.getAction(XDebuggerActions.MARK_OBJECT).unregisterCustomShortcutSet(this);
}
@@ -238,6 +239,8 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), this);
actionManager.getAction(XDebuggerActions.COPY_VALUE).registerCustomShortcutSet(CommonShortcuts.getCopy(), this);
actionManager.getAction(XDebuggerActions.JUMP_TO_SOURCE).registerCustomShortcutSet(CommonShortcuts.getEditSource(), this);
Shortcut[] editTypeShortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(XDebuggerActions.EDIT_TYPE_SOURCE);
actionManager.getAction(XDebuggerActions.JUMP_TO_TYPE_SOURCE).registerCustomShortcutSet(new CustomShortcutSet(editTypeShortcuts), this);
actionManager.getAction(XDebuggerActions.MARK_OBJECT)
.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("ToggleBookmark")), this);
}
@@ -15,36 +15,15 @@
*/
package com.intellij.xdebugger.impl.ui.tree.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.ui.AppUIUtil;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.frame.XNavigatable;
import com.intellij.xdebugger.frame.XValue;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public class XJumpToSourceAction extends XDebuggerTreeActionBase {
protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) {
XValue value = node.getValueContainer();
value.computeSourcePosition(new XNavigatable() {
public void setSourcePosition(@Nullable final XSourcePosition sourcePosition) {
if (sourcePosition != null) {
AppUIUtil.invokeOnEdt(new Runnable() {
public void run() {
Project project = node.getTree().getProject();
if (project.isDisposed()) return;
sourcePosition.createNavigatable(project).navigate(true);
}
});
}
}
});
public class XJumpToSourceAction extends XJumpToSourceActionBase {
@Override
protected void startComputingSourcePosition(XValue value, XNavigatable navigatable) {
value.computeSourcePosition(navigatable);
}
}
@@ -0,0 +1,52 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.xdebugger.impl.ui.tree.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.ui.AppUIUtil;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.frame.XNavigatable;
import com.intellij.xdebugger.frame.XValue;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
*/
public abstract class XJumpToSourceActionBase extends XDebuggerTreeActionBase {
protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) {
XValue value = node.getValueContainer();
XNavigatable navigatable = new XNavigatable() {
public void setSourcePosition(@Nullable final XSourcePosition sourcePosition) {
if (sourcePosition != null) {
AppUIUtil.invokeOnEdt(new Runnable() {
public void run() {
Project project = node.getTree().getProject();
if (project.isDisposed()) return;
sourcePosition.createNavigatable(project).navigate(true);
}
});
}
}
};
startComputingSourcePosition(value, navigatable);
}
protected abstract void startComputingSourcePosition(XValue value, XNavigatable navigatable);
}
@@ -0,0 +1,35 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.xdebugger.impl.ui.tree.actions;
import com.intellij.xdebugger.frame.XNavigatable;
import com.intellij.xdebugger.frame.XValue;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
/**
* @author nik
*/
public class XJumpToTypeSourceAction extends XJumpToSourceActionBase {
@Override
protected void startComputingSourcePosition(XValue value, XNavigatable navigatable) {
value.computeTypeSourcePosition(navigatable);
}
@Override
protected boolean isEnabled(XValueNodeImpl node) {
return super.isEnabled(node) && node.getValueContainer().canNavigateToTypeSource();
}
}