"Jump To Cursor" action isn't visible, when non-Python configuration selected (PY-27227)

This commit is contained in:
Elizaveta Shashkova
2017-11-30 20:11:33 +03:00
parent f26af18f70
commit 869ec0b322
3 changed files with 10 additions and 17 deletions
@@ -15,9 +15,6 @@
*/
package com.jetbrains.python.debugger;
import com.intellij.execution.RunManager;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
@@ -26,9 +23,10 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerManager;
import com.jetbrains.python.PyTokenTypes;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.run.AbstractPythonRunConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -118,15 +116,10 @@ public class PyDebugSupportUtils {
return false;
}
public static boolean isPythonConfigurationSelected(Project project) {
if (project != null) {
RunnerAndConfigurationSettings settings = RunManager.getInstance(project).getSelectedConfiguration();
if (settings != null) {
RunConfiguration runConfiguration = settings.getConfiguration();
if (runConfiguration instanceof AbstractPythonRunConfiguration) {
return true;
}
}
public static boolean isCurrentPythonDebugProcess(Project project) {
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
if (session != null && session.getDebugProcess() instanceof PyDebugProcess) {
return true;
}
return false;
}
@@ -63,7 +63,7 @@ class PySetNextStatementAction : XDebuggerActionBase(true) {
}
override fun isEnabled(project: Project, event: AnActionEvent): Boolean {
return super.isEnabled(project, event) && PyDebugSupportUtils.isPythonConfigurationSelected(project)
return super.isEnabled(project, event) && PyDebugSupportUtils.isCurrentPythonDebugProcess(project)
}
}
}
@@ -71,7 +71,7 @@ class PySetNextStatementAction : XDebuggerActionBase(true) {
override fun getHandler(debuggerSupport: DebuggerSupport) = setNextStatementActionHandler
override fun isHidden(event: AnActionEvent): Boolean {
return !PyDebugSupportUtils.isPythonConfigurationSelected(event.getData(CommonDataKeys.PROJECT))
return !PyDebugSupportUtils.isCurrentPythonDebugProcess(event.getData(CommonDataKeys.PROJECT))
}
companion object {
@@ -45,7 +45,7 @@ public class PyStepIntoMyCodeAction extends XDebuggerActionBase {
@Override
public boolean isEnabled(@NotNull Project project, AnActionEvent event) {
return super.isEnabled(project, event) && PyDebugSupportUtils.isPythonConfigurationSelected(project);
return super.isEnabled(project, event) && PyDebugSupportUtils.isCurrentPythonDebugProcess(project);
}
};
}
@@ -58,6 +58,6 @@ public class PyStepIntoMyCodeAction extends XDebuggerActionBase {
@Override
protected boolean isHidden(AnActionEvent event) {
return !PyDebugSupportUtils.isPythonConfigurationSelected(event.getData(CommonDataKeys.PROJECT));
return !PyDebugSupportUtils.isCurrentPythonDebugProcess(event.getData(CommonDataKeys.PROJECT));
}
}