IDEA-159444 Improve value tooltip presentation in debugger - show shortcut only if shown from keyboard

This commit is contained in:
Egor.Ushakov
2017-04-12 15:51:32 +03:00
parent 8fecbece75
commit b2c10570b8
3 changed files with 9 additions and 6 deletions
@@ -82,7 +82,7 @@ public class XQuickEvaluateHandler extends QuickEvaluateHandler {
resultPromise.setResult(null);
return;
}
resultPromise.setResult(new XValueHint(project, editor, point, type, expressionInfo, evaluator, session));
resultPromise.setResult(new XValueHint(project, editor, point, type, expressionInfo, evaluator, session, false));
});
return resultPromise;
});
@@ -78,6 +78,7 @@ public class XValueHint extends AbstractValueHint {
private final XDebuggerEvaluator myEvaluator;
private final XDebugSession myDebugSession;
private final boolean myFromKeyboard;
private final String myExpression;
private final String myValueName;
private final @Nullable XSourcePosition myExpressionPosition;
@@ -88,11 +89,12 @@ public class XValueHint extends AbstractValueHint {
public XValueHint(@NotNull Project project, @NotNull Editor editor, @NotNull Point point, @NotNull ValueHintType type,
@NotNull ExpressionInfo expressionInfo, @NotNull XDebuggerEvaluator evaluator,
@NotNull XDebugSession session) {
@NotNull XDebugSession session, boolean fromKeyboard) {
super(project, editor, point, type, expressionInfo.getTextRange());
myEvaluator = evaluator;
myDebugSession = session;
myFromKeyboard = fromKeyboard;
myExpression = XDebuggerEvaluateActionHandler.getExpressionText(expressionInfo, editor.getDocument());
myValueName = XDebuggerEvaluateActionHandler.getDisplayText(expressionInfo, editor.getDocument());
myExpressionInfo = expressionInfo;
@@ -126,7 +128,8 @@ public class XValueHint extends AbstractValueHint {
public void actionPerformed(@NotNull AnActionEvent e) {
hideHint();
final Point point = new Point(myPoint.x, myPoint.y + getEditor().getLineHeight());
new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession).invokeHint();
new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession,
true).invokeHint();
}
}.registerCustomShortcutSet(shortcut, getEditor().getContentComponent(), myDisposable);
}
@@ -208,7 +211,7 @@ public class XValueHint extends AbstractValueHint {
}
}
else {
if (getType() == ValueHintType.MOUSE_OVER_HINT) {
if (getType() == ValueHintType.MOUSE_OVER_HINT && myFromKeyboard) {
text.insert(0, "(" + KeymapUtil.getFirstKeyboardShortcutText("ShowErrorDescription") + ") ",
SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -193,7 +193,7 @@ public abstract class XVariablesViewBase extends XDebugView {
int offset = range.getStartOffset();
LogicalPosition pos = myEditor.offsetToLogicalPosition(offset);
Point point = myEditor.logicalPositionToXY(pos);
new XValueHint(myProject, myEditor, point, ValueHintType.MOUSE_OVER_HINT, info, evaluator, session).invokeHint();
new XValueHint(myProject, myEditor, point, ValueHintType.MOUSE_OVER_HINT, info, evaluator, session, true).invokeHint();
}
}
}