From 1fdeb54befd0332f2984fa788ab3a7e85046b4fb Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Wed, 26 Jun 2019 17:09:29 +0300 Subject: [PATCH] IDEA-207228 - show information hint on the first 3 invocations GitOrigin-RevId: 310c3d8afefd3ee00ec9f811d9cd0d3b362ff469 --- .../src/messages/XDebuggerBundle.properties | 4 +++- .../XDebuggerSmartStepIntoHandler.java | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties index c3ee1a8fe900..372501a52d4e 100644 --- a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties +++ b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties @@ -177,4 +177,6 @@ settings.run.to.cursor.gesture=Click line number to perform run to cursor message.confirm.breakpoint.removal.title=Confirm Removal message.confirm.breakpoint.removal.message=Breakpoint contains message.confirm.breakpoint.removal.message.condition=
condition:
{0}
-message.confirm.breakpoint.removal.message.log=
log expression:
{0}
\ No newline at end of file +message.confirm.breakpoint.removal.message.log=
log expression:
{0}
+ +message.smart.step="Choose a method to step into with arrow keys.\nTo exit the smart step into mode, press Esc." diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XDebuggerSmartStepIntoHandler.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XDebuggerSmartStepIntoHandler.java index 1bed90fb1f4e..08cc42510a9a 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XDebuggerSmartStepIntoHandler.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XDebuggerSmartStepIntoHandler.java @@ -3,8 +3,12 @@ package com.intellij.xdebugger.impl.actions.handlers; import com.intellij.codeInsight.highlighting.HighlightManager; import com.intellij.codeInsight.highlighting.HighlightManagerImpl; +import com.intellij.codeInsight.hint.HintManager; +import com.intellij.codeInsight.hint.HintManagerImpl; +import com.intellij.codeInsight.hint.HintUtil; import com.intellij.codeInsight.unwrap.ScopeHighlighter; import com.intellij.execution.impl.EditorHyperlinkSupport; +import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Caret; @@ -26,6 +30,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.IdeFocusManager; +import com.intellij.ui.LightweightHint; import com.intellij.ui.ListActions; import com.intellij.ui.components.JBList; import com.intellij.ui.popup.list.ListPopupImpl; @@ -34,6 +39,7 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XDebugSessionListener; +import com.intellij.xdebugger.XDebuggerBundle; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.impl.actions.XDebuggerActions; import com.intellij.xdebugger.impl.actions.XDebuggerSuspendedActionHandler; @@ -62,6 +68,7 @@ import java.util.List; public class XDebuggerSmartStepIntoHandler extends XDebuggerSuspendedActionHandler { private static final Ref SHOW_AD = new Ref<>(true); private static final Logger LOG = Logger.getInstance(XDebuggerSmartStepIntoHandler.class); + private static final String COUNTER_PROPERTY = "debugger.smart.chooser.counter"; @Override protected boolean isEnabled(@NotNull XDebugSession session, DataContext dataContext) { @@ -216,6 +223,8 @@ public class XDebuggerSmartStepIntoHandler extends XDebuggerSuspendedActionHandl session.updateExecutionPosition(); IdeFocusManager.getGlobalInstance().requestFocus(editor.getContentComponent(), true); + showInfoHint(editor, data); + session.addSessionListener(new XDebugSessionListener() { void onAnyEvent() { session.removeSessionListener(this); @@ -254,6 +263,20 @@ public class XDebuggerSmartStepIntoHandler extends XDebuggerSuspendedActionHandl }); } + private static void showInfoHint(Editor editor, SmartStepData data) { + PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); + int counter = propertiesComponent.getInt(COUNTER_PROPERTY, 0); + if (counter < 3) { + LightweightHint hint = new LightweightHint(HintUtil.createInformationLabel(XDebuggerBundle.message("message.smart.step"))); + JComponent component = HintManagerImpl.getExternalComponent(editor); + Point convertedPoint = SwingUtilities.convertPoint(editor.getContentComponent(), data.myCurrentVariant.myStartPoint, component); + HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, convertedPoint, HintManager.HIDE_BY_TEXT_CHANGE | + HintManager.HIDE_BY_SCROLLING, + 0, false, HintManager.ABOVE); + propertiesComponent.setValue(COUNTER_PROPERTY, counter + 1, 0); + } + } + static final Key SMART_STEP_INPLACE_DATA = Key.create("SMART_STEP_INPLACE_DATA"); static class SmartStepData {