PY-21325 Add option to configure debugger port

GitOrigin-RevId: 312da6bbb2aafadc9600c0d5cc36a07052d52886
This commit is contained in:
Andrey Lisin
2024-09-25 20:59:53 +02:00
committed by intellij-monorepo-bot
parent 2250726971
commit 95e95ad914
5 changed files with 56 additions and 8 deletions

View File

@@ -1032,6 +1032,7 @@ form.debugger.collect.run.time.types.information.for.code.insight=Collect run-ti
form.debugger.gevent.compatible=Gevent compatible
form.debugger.drop.into.debugger.on.failed.tests=Drop into debugger on failed tests
form.debugger.pyqt.compatible=PyQt compatible
form.debugger.debugger.port=Debugger port:
form.debugger.remote.interpreter.docker.default.interpreter.path=python
form.data.viewer.current.slice=Current slice
form.data.viewer.dialog.show.svn.map.table.header.column.format.title=Format

View File

@@ -160,7 +160,7 @@ public class PyDebugRunner implements ProgramRunner<RunnerSettings> {
RunProfile profile = environment.getRunProfile();
if (Registry.is("python.debug.use.single.port")) {
int port = Registry.intValue("python.debugger.port");
int port = PyDebuggerOptionsProvider.getInstance(environment.getProject()).getDebuggerPort();
TargetEnvironment.TargetPortBinding targetPortBinding =
new TargetEnvironment.TargetPortBinding(port, port);
return Promises

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.jetbrains.python.debugger.PyDebuggerConfigurable">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="735" height="303"/>
@@ -8,10 +8,10 @@
<properties/>
<border type="none"/>
<children>
<grid id="62c2a" layout-manager="GridLayoutManager" row-count="5" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="62c2a" layout-manager="GridLayoutManager" row-count="6" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -94,16 +94,33 @@
<text resource-bundle="messages/PyBundle" key="form.debugger.drop.into.debugger.on.failed.tests"/>
</properties>
</component>
<component id="25bd0" class="com.intellij.ui.components.JBLabel" binding="myDebuggerPortLabel" custom-create="true">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/PyBundle" key="form.debugger.debugger.port"/>
</properties>
</component>
<component id="32b9c" class="com.intellij.ui.JBIntSpinner" binding="myDebuggerPort" custom-create="true">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<max value="65535"/>
<min value="0"/>
</properties>
</component>
</children>
</grid>
<vspacer id="5915a">
<constraints>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="2" column="1" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="ffb0f" class="com.intellij.ui.components.JBLabel" binding="myAttachFilterLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="79ca8"/>
@@ -115,7 +132,7 @@
</component>
<component id="79ca8" class="com.intellij.ui.components.JBTextField" binding="myAttachProcessFilter" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
@@ -126,7 +143,7 @@
</component>
<hspacer id="8e2cc">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="2" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>

View File

@@ -9,7 +9,9 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.JBIntSpinner;
import com.intellij.ui.TooltipWithClickableLinks;
import com.intellij.ui.components.ActionLink;
import com.intellij.ui.components.JBCheckBox;
@@ -37,6 +39,8 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con
private ActionLink myActionLink;
private JBTextField myAttachProcessFilter;
private JBLabel myAttachFilterLabel;
private JBLabel myDebuggerPortLabel;
private JBIntSpinner myDebuggerPort;
private enum PyQtBackend {
AUTO(PyBundle.messagePointer("python.debugger.qt.backend.auto")),
@@ -63,6 +67,11 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con
private final Supplier<@Nls String> myDisplayNameSupplier;
}
private static final class PortRange {
public static final int MIN = 0;
public static final int MAX = 65535;
}
private final Project myProject;
public PyDebuggerConfigurable(Project project) {
@@ -109,6 +118,7 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con
mySupportQt.isSelected() != settings.isSupportQtDebugging() ||
(myPyQtBackend.getSelectedItem() != null &&
!StringUtil.toLowerCase((((PyQtBackend)myPyQtBackend.getSelectedItem()).name())).equals(settings.getPyQtBackend())) ||
myDebuggerPort.getNumber() != settings.getDebuggerPort() ||
!myAttachProcessFilter.getText().equals(settings.getAttachProcessFilter());
}
@@ -126,6 +136,8 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con
settings.setPyQtBackend(StringUtil.toLowerCase(((PyQtBackend)selectedBackend).name()));
}
settings.setDebuggerPort(myDebuggerPort.getNumber());
settings.setAttachProcessFilter(myAttachProcessFilter.getText());
}
@@ -138,6 +150,7 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con
myDropIntoDebuggerOnFailedTests.setSelected(settings.isDropIntoDebuggerOnFailedTest());
mySupportQt.setSelected(settings.isSupportQtDebugging());
myPyQtBackend.setSelectedItem(PyQtBackend.valueOf(StringUtil.toUpperCase(settings.getPyQtBackend())));
myDebuggerPort.setNumber(settings.getDebuggerPort());
myAttachProcessFilter.setText(settings.getAttachProcessFilter());
}
@@ -159,5 +172,12 @@ public final class PyDebuggerConfigurable implements SearchableConfigurable, Con
}
Messages.showInfoMessage(myProject, message, PyBundle.message("debugger.delete.signature.cache"));
});
myDebuggerPortLabel = new JBLabel(PyBundle.message("form.debugger.debugger.port"));
myDebuggerPort = new JBIntSpinner(0, PortRange.MIN, PortRange.MAX);
if (!Registry.is("python.debug.use.single.port")) {
myDebuggerPortLabel.setVisible(false);
myDebuggerPort.setVisible(false);
}
}
}

View File

@@ -3,6 +3,7 @@ package com.jetbrains.python.debugger;
import com.intellij.openapi.components.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.jetbrains.python.PyBundle;
import org.jetbrains.annotations.NonNls;
@@ -39,6 +40,7 @@ public final class PyDebuggerOptionsProvider implements PersistentStateComponent
public boolean myDropIntoDebuggerOnFailedTests = false;
public boolean mySupportQtDebugging = true;
public @NonNls String myPyQtBackend = "auto";
public int myDebuggerPort = Registry.intValue("python.debugger.port");
public @NonNls String myAttachProcessFilter = "python";
}
@@ -93,6 +95,14 @@ public final class PyDebuggerOptionsProvider implements PersistentStateComponent
myState.myPyQtBackend = backend;
}
int getDebuggerPort() {
return myState.myDebuggerPort;
}
void setDebuggerPort(int port) {
myState.myDebuggerPort = port;
}
public String getAttachProcessFilter() {
return myState.myAttachProcessFilter;
}