Skip to content

Commit 0deb456

Browse files
author
Bartlomiej Laczkowski
committed
ZSTD-4870 Improve the relation between settings of debuggers and related
owners (part 2)
1 parent 97938ac commit 0deb456

File tree

1 file changed

+39
-20
lines changed
  • zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.debug.core/src/org/zend/php/zendserver/deployment/debug/core

1 file changed

+39
-20
lines changed

zendserver-deployment-eclipse/org.zend.php.zendserver.deployment.debug.core/src/org/zend/php/zendserver/deployment/debug/core/DebugModeManager.java

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.eclipse.php.internal.debug.core.preferences.PHPDebugCorePreferenceNames;
1818
import org.eclipse.php.internal.debug.core.preferences.PHPDebuggersRegistry;
1919
import org.eclipse.php.internal.debug.core.zend.communication.DebuggerCommunicationDaemon;
20+
import org.eclipse.php.internal.debug.core.zend.debugger.ZendDebuggerSettingsUtil;
2021
import org.eclipse.php.internal.server.core.Server;
2122
import org.zend.php.server.core.utils.ServerUtils;
2223
import org.zend.sdklib.SdkException;
@@ -45,9 +46,6 @@ public class DebugModeManager {
4546

4647
public static final String FILTER_SEPARATOR = ","; //$NON-NLS-1$
4748

48-
private static final String CLIENT_HOST_KEY = "org.eclipse.php.debug.coreclient_ip"; //$NON-NLS-1$
49-
private static final String DEBUG_PLUGIN_ID = "org.eclipse.php.debug.core"; //$NON-NLS-1$
50-
5149
private static DebugModeManager manager;
5250

5351
private Map<IZendTarget, Boolean> targets;
@@ -67,22 +65,17 @@ public IStatus startDebugMode(IZendTarget target) {
6765
ZendDebugMode debugMode = new ZendDebugMode(target.getId());
6866
Map<String, String> options = new HashMap<String, String>();
6967
debugMode.setFilters(getFilters(target));
70-
AbstractDebuggerConfiguration debuggerConfiguration = PHPDebuggersRegistry
71-
.getDebuggerConfiguration(DebuggerCommunicationDaemon.ZEND_DEBUGGER_ID);
72-
if (debuggerConfiguration != null) {
73-
int port = debuggerConfiguration.getPort();
74-
options.put(DEBUG_PORT, String.valueOf(port));
75-
options.put(DEBUG_HOST, getDebugHosts(target));
76-
Server server = ServerUtils.getServer(target);
77-
if (server != null) {
78-
if (shouldStopAtFirstLine()) {
79-
options.put(DEBUG_STOP, "1"); //$NON-NLS-1$
80-
}
81-
} else {
68+
options.put(DEBUG_PORT, String.valueOf(getDebugPort(target)));
69+
options.put(DEBUG_HOST, getDebugHosts(target));
70+
Server server = ServerUtils.getServer(target);
71+
if (server != null) {
72+
if (shouldStopAtFirstLine()) {
8273
options.put(DEBUG_STOP, "1"); //$NON-NLS-1$
8374
}
84-
debugMode.setOptions(options);
75+
} else {
76+
options.put(DEBUG_STOP, "1"); //$NON-NLS-1$
8577
}
78+
debugMode.setOptions(options);
8679
State result = State.ERROR;
8780
try {
8881
result = debugMode.start();
@@ -165,13 +158,39 @@ private String getDebugHosts(IZendTarget target) {
165158
return LOCALHOST;
166159
}
167160
IEclipsePreferences prefs = InstanceScope.INSTANCE
168-
.getNode(DEBUG_PLUGIN_ID);
169-
String clientHosts = prefs.get(CLIENT_HOST_KEY, (String) null);
161+
.getNode(PHPDebugPlugin.ID);
162+
String clientHosts = prefs.get(PHPDebugCorePreferenceNames.CLIENT_IP,
163+
(String) null);
170164
if (clientHosts == null) {
171165
IEclipsePreferences defaultPrefs = DefaultScope.INSTANCE
172-
.getNode(DEBUG_PLUGIN_ID);
173-
clientHosts = defaultPrefs.get(CLIENT_HOST_KEY, (String) null);
166+
.getNode(PHPDebugPlugin.ID);
167+
clientHosts = defaultPrefs.get(
168+
PHPDebugCorePreferenceNames.CLIENT_IP, (String) null);
174169
}
170+
Server server = ServerUtils.getServer(target);
171+
// Get server individual hosts list if any
172+
String customHosts = ZendDebuggerSettingsUtil.getDebugHosts(server);
173+
if (customHosts != null)
174+
clientHosts = customHosts;
175+
return clientHosts;
176+
}
177+
178+
private int getDebugPort(IZendTarget target) {
179+
IEclipsePreferences prefs = InstanceScope.INSTANCE
180+
.getNode(PHPDebugPlugin.ID);
181+
int clientHosts = prefs.getInt(
182+
PHPDebugCorePreferenceNames.ZEND_DEBUG_PORT, -1);
183+
if (clientHosts == -1) {
184+
IEclipsePreferences defaultPrefs = DefaultScope.INSTANCE
185+
.getNode(PHPDebugPlugin.ID);
186+
clientHosts = defaultPrefs.getInt(
187+
PHPDebugCorePreferenceNames.ZEND_DEBUG_PORT, -1);
188+
}
189+
Server server = ServerUtils.getServer(target);
190+
// Get server individual hosts list if any
191+
int customPort = ZendDebuggerSettingsUtil.getDebugPort(server);
192+
if (customPort != -1)
193+
clientHosts = customPort;
175194
return clientHosts;
176195
}
177196

0 commit comments

Comments
 (0)