2323import com .intellij .debugger .engine .JavaDebugProcess ;
2424import com .intellij .debugger .impl .DebuggerSession ;
2525import com .intellij .debugger .ui .tree .render .BatchEvaluator ;
26- import com .intellij .execution .DefaultExecutionResult ;
2726import com .intellij .execution .ExecutionException ;
2827import com .intellij .execution .ExecutionResult ;
2928import com .intellij .execution .configurations .RemoteConnection ;
3029import com .intellij .execution .configurations .RunProfile ;
3130import com .intellij .execution .configurations .RunProfileState ;
3231import com .intellij .execution .configurations .RunnerSettings ;
32+ import com .intellij .execution .executors .DefaultDebugExecutor ;
33+ import com .intellij .execution .executors .DefaultRunExecutor ;
3334import com .intellij .execution .runners .ExecutionEnvironment ;
3435import com .intellij .execution .runners .GenericProgramRunner ;
3536import com .intellij .execution .runners .RunContentBuilder ;
3839import com .intellij .xdebugger .XDebugProcessStarter ;
3940import com .intellij .xdebugger .XDebugSession ;
4041import com .intellij .xdebugger .XDebuggerManager ;
41- import com .intellij .xdebugger .impl .XDebugSessionImpl ;
4242import org .jetbrains .annotations .NotNull ;
4343import org .jetbrains .annotations .Nullable ;
4444
4545public class RoboVmRunner extends GenericProgramRunner <RunnerSettings > {
4646
47- public static final String DEBUG_EXECUTOR = "Debug" ;
48- public static final String RUN_EXECUTOR = "Run" ;
49-
5047 @ NotNull
5148 @ Override
5249 public String getRunnerId () {
@@ -55,22 +52,22 @@ public String getRunnerId() {
5552
5653 @ Override
5754 public boolean canRun (@ NotNull String executorId , @ NotNull RunProfile profile ) {
58- return (executorId .equals (DEBUG_EXECUTOR ) || executorId .equals (RUN_EXECUTOR )) && profile instanceof RoboVmRunConfiguration ;
55+ return (executorId .equals (DefaultDebugExecutor . EXECUTOR_ID ) || executorId .equals (DefaultRunExecutor . EXECUTOR_ID )) && profile instanceof RoboVmRunConfiguration ;
5956 }
6057
6158 @ Override
6259 protected void execute (@ NotNull ExecutionEnvironment environment , @ Nullable Callback callback , @ NotNull RunProfileState state ) {
6360 // we need to pass the run profile info to the compiler so
6461 // we can decide if this is a debug or release build
6562 RoboVmRunConfiguration runConfig = (RoboVmRunConfiguration )environment .getRunProfile ();
66- runConfig .setDebug (DEBUG_EXECUTOR .equals (environment .getExecutor ().getId ()));
63+ runConfig .setDebug (DefaultDebugExecutor . EXECUTOR_ID .equals (environment .getExecutor ().getId ()));
6764 super .execute (environment , callback , state );
6865 }
6966
7067 @ Nullable
7168 @ Override
7269 protected RunContentDescriptor doExecute (@ NotNull RunProfileState state , @ NotNull ExecutionEnvironment environment ) throws ExecutionException {
73- if (DEBUG_EXECUTOR .equals (environment .getExecutor ().getId ())) {
70+ if (DefaultDebugExecutor . EXECUTOR_ID .equals (environment .getExecutor ().getId ())) {
7471 RoboVmRunConfiguration runConfig = (RoboVmRunConfiguration )environment .getRunProfile ();
7572 RemoteConnection connection = new RemoteConnection (true , "127.0.0.1" , "" + runConfig .getDebugPort (), false );
7673 connection .setServerMode (true );
@@ -104,18 +101,16 @@ protected RunContentDescriptor attachVirtualMachine(RunProfileState state,
104101 // which is an expensive operation when executed first time
105102 debugProcess .putUserData (BatchEvaluator .REMOTE_SESSION_KEY , Boolean .TRUE );
106103
107- return XDebuggerManager . getInstance ( env . getProject ()). startSession ( env , new XDebugProcessStarter () {
104+ XDebugProcessStarter starter = new XDebugProcessStarter () {
108105 @ Override
109- @ NotNull
110- public XDebugProcess start (@ NotNull XDebugSession session ) {
111- XDebugSessionImpl sessionImpl = (XDebugSessionImpl )session ;
112- ExecutionResult executionResult = debugProcess .getExecutionResult ();
113- sessionImpl .addExtraActions (executionResult .getActions ());
114- if (executionResult instanceof DefaultExecutionResult ) {
115- sessionImpl .addRestartActions (((DefaultExecutionResult )executionResult ).getRestartActions ());
116- }
106+ public @ NotNull XDebugProcess start (final @ NotNull XDebugSession session ) {
117107 return JavaDebugProcess .create (session , debuggerSession );
118108 }
119- }).getRunContentDescriptor ();
109+ };
110+ // TODO: startSession is deprecated and causes exception
111+ // java.lang.Throwable: [Split debugger] RunContentDescriptor should not be used in split mode from XDebugSession.
112+ // but replacement is marked as not stabled and can't be used yet
113+ return XDebuggerManager .getInstance (env .getProject ()).startSession (env , starter )
114+ .getRunContentDescriptor ();
120115 }
121116}
0 commit comments