|
1 | 1 | package cz.jiripudil.intellij.nette.tester.configuration; |
2 | 2 |
|
3 | | -import com.intellij.execution.DefaultExecutionResult; |
4 | | -import com.intellij.execution.ExecutionException; |
5 | | -import com.intellij.execution.ExecutionResult; |
6 | | -import com.intellij.execution.Executor; |
| 3 | +import com.intellij.execution.*; |
7 | 4 | import com.intellij.execution.configurations.*; |
8 | 5 | import com.intellij.execution.process.ProcessHandler; |
9 | 6 | import com.intellij.execution.process.ProcessTerminatedListener; |
|
18 | 15 | import com.intellij.openapi.vfs.VirtualFile; |
19 | 16 | import com.intellij.util.PathUtil; |
20 | 17 | import com.intellij.util.xmlb.annotations.Attribute; |
| 18 | +import com.intellij.xdebugger.XDebugProcess; |
| 19 | +import com.intellij.xdebugger.XDebugSession; |
21 | 20 | import com.jetbrains.php.config.PhpProjectConfigurationFacade; |
22 | 21 | import com.jetbrains.php.config.commandLine.PhpCommandLinePathProcessor; |
23 | 22 | import com.jetbrains.php.config.commandLine.PhpCommandSettings; |
24 | 23 | import com.jetbrains.php.config.commandLine.PhpCommandSettingsBuilder; |
25 | 24 | import com.jetbrains.php.config.interpreters.PhpInterpreter; |
26 | | -import com.jetbrains.php.run.PhpCommandLineSettings; |
27 | | -import com.jetbrains.php.run.PhpExecutionUtil; |
28 | | -import com.jetbrains.php.run.PhpRefactoringListenerRunConfiguration; |
29 | | -import com.jetbrains.php.run.PhpRunUtil; |
| 25 | +import com.jetbrains.php.debug.common.PhpDebugProcessFactory; |
| 26 | +import com.jetbrains.php.debug.xdebug.debugger.XdebugDriver; |
| 27 | +import com.jetbrains.php.run.*; |
30 | 28 | import com.jetbrains.php.util.PhpConfigurationUtil; |
31 | 29 | import com.jetbrains.php.util.pathmapper.PhpPathMapper; |
32 | 30 | import cz.jiripudil.intellij.nette.tester.TesterBundle; |
|
36 | 34 | import org.jdom.Element; |
37 | 35 | import org.jetbrains.annotations.NotNull; |
38 | 36 | import org.jetbrains.annotations.Nullable; |
| 37 | +import org.jetbrains.debugger.DebuggableRunConfiguration; |
39 | 38 |
|
| 39 | +import java.net.InetAddress; |
| 40 | +import java.net.InetSocketAddress; |
40 | 41 | import java.util.Collections; |
41 | 42 | import java.util.List; |
42 | 43 | import java.util.Map; |
43 | 44 |
|
44 | | -public class TesterRunConfiguration extends PhpRefactoringListenerRunConfiguration<TesterSettings> implements LocatableConfiguration { |
| 45 | +public class TesterRunConfiguration extends PhpRefactoringListenerRunConfiguration<TesterSettings> implements LocatableConfiguration, DebuggableRunConfiguration { |
45 | 46 | private boolean isGenerated; |
| 47 | + private String host = null; |
46 | 48 |
|
47 | 49 | TesterRunConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory, String name) { |
48 | 50 | super(project, factory, name); |
@@ -105,7 +107,7 @@ public void checkConfiguration() throws RuntimeConfigurationException { |
105 | 107 | @Override |
106 | 108 | public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException { |
107 | 109 | try { |
108 | | - return this.getState(executionEnvironment, this.createCommand(Collections.emptyMap(), Collections.emptyList(), false)); |
| 110 | + return this.getState(executionEnvironment, this.createCommand(Collections.emptyMap(), Collections.emptyList(), true)); |
109 | 111 | } catch (CloneNotSupportedException e) { |
110 | 112 | return null; |
111 | 113 | } |
@@ -294,4 +296,20 @@ public void setValue(@Nullable String newName) { |
294 | 296 |
|
295 | 297 | return pathsToUpdate; |
296 | 298 | } |
| 299 | + |
| 300 | + @Override |
| 301 | + public @NotNull InetSocketAddress computeDebugAddress(RunProfileState state) throws ExecutionException { |
| 302 | + if (host == null) { |
| 303 | + return new InetSocketAddress(InetAddress.getLoopbackAddress(), 9000); |
| 304 | + } |
| 305 | + else { |
| 306 | + return new InetSocketAddress(host, 9000); |
| 307 | + } |
| 308 | + } |
| 309 | + |
| 310 | + @Override |
| 311 | + public @NotNull XDebugProcess createDebugProcess(@NotNull InetSocketAddress inetSocketAddress, @NotNull XDebugSession session, @Nullable ExecutionResult result, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException { |
| 312 | + //XdebugDriver |
| 313 | + return PhpDebugProcessFactory.forExternalConnection(session, inetSocketAddress.toString(), XdebugDriver.INSTANCE); |
| 314 | + } |
297 | 315 | } |
0 commit comments