package com.intellij.remoteServer.ir;

import com.intellij.execution.Platform;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.process.ProcessHandler;

import java.util.List;
import java.util.Map;

public class IR {

  public interface PathId {
  }

  public interface PortId {
    int getRemotePort();
  }

  public interface RemoteRunner {
    Platform getRemotePlatform();

    RemoteEnvironmentRequest createRequest();

    RemoteEnvironment prepareRemoteEnvironment(RemoteEnvironmentRequest request) throws Exception;
  }

  public interface RemoteEnvironment {
    Platform getPlatform();

    Map<String, String> getEnvVars();

    String findRemotePath(PathId pathId);

    ProcessHandler createProcessHandler(NewCommandLine commandLine);
  }

  public interface RemoteEnvironmentRequest {
    PathId requestTransfer(String localPath);

    PathId requestRemoteFile(String remotePath);

    PortId requestPortMapping(int remotePort);
  }

  public interface NewCommandLine {

    /**
     * {@link GeneralCommandLine#getPreparedCommandLine()}
     */
    List<String> prepareCommandLine(RemoteEnvironment target);

    void setExePath(PathId path);

    void setWorkingDirectory(PathId path);

    void addPathParameter(String name, PathId value);

    void addEnvVar(String name, PathId value);
  }
}

@@ -190,16 +190,58 @@
 Handler;
+%0Aimport org.jetbrains.annotations.NotNull;
 %0A%0Aimport
@@ -453,24 +453,128 @@
 ePlatform();
+%0A    %0A    RemoteValue createPathValue(@NotNull String path);%0A%0A    RemoteValue createPortValue(int port);
 %0A%0A    Remote
@@ -817,24 +817,70 @@
 EnvVars();%0A%0A
+    // todo: string or remoteValue or pathId?%0A
     String f
@@ -897,21 +897,19 @@
 ath(
-PathId
+String
  path
-Id
 );%0A%0A
@@ -1169,32 +1169,455 @@
 motePort);%0A  %7D%0A%0A
+  public interface RemoteValue %7B%0A    @NotNull%0A    String toString(@NotNull RemoteEnvironment environment);%0A  %7D%0A%0A  public class StringRemoteValue implements RemoteValue %7B%0A    private final String myString;%0A%0A    public StringRemoteValue(@NotNull String string) %7B%0A      myString = string;%0A    %7D%0A%0A    @Override%0A    @NotNull%0A    public String toString(@NotNull RemoteEnvironment environment) %7B%0A      return myString;%0A    %7D%0A  %7D%0A%0A
   public interfa
@@ -1748,16 +1748,25 @@
 andLine(
+@NotNull 
 RemoteEn
@@ -1805,24 +1805,32 @@
 ExePath(
-PathId p
+RemoteValue exeP
 ath);%0A%0A 
@@ -1861,19 +1861,36 @@
 ory(
-PathId path
+RemoteValue workingDirectory
 );%0A%0A
@@ -1907,20 +1907,16 @@
 ddPa
-thPa
 rameter(
 Stri
@@ -1915,33 +1915,29 @@
 ter(
-String name, PathId value
+RemoteValue parameter
 );%0A%0A
@@ -1951,19 +1951,32 @@
 d addEnv
-Var
+ironmentVariable
 (String 
@@ -1981,22 +1981,27 @@
 g name, 
-PathId
+RemoteValue
  value);

Update API