@Override
  public void patchParameters(SimpleJavaParameters parameters, XsltRunConfiguration configuration, UserDataHolder extensionData) throws CantRunException {
    final Sdk jdk = configuration.getEffectiveJDK();
    assert jdk != null;
    final JavaVersion version = JavaVersion.tryParse(jdk.getVersionString());
    if (version == null || version.feature < 5) {
      throw new CantRunException(XsltDebuggerBundle.message("dialog.message.xslt.debugger.requires.java.to.run"));
    }

    // TODO: fix and remove
    if (configuration.getOutputType() != XsltRunConfiguration.OutputType.CONSOLE) {
      throw new CantRunException(XsltDebuggerBundle.message("dialog.message.xslt.debugger.requires.output.type.console"));
    }

    try {
      final int port = NetUtils.findAvailableSocketPort();
      parameters.getVMParametersList().defineProperty("xslt.debugger.port", String.valueOf(port));
      extensionData.putUserData(PORT, port);
    } catch (IOException e) {
      LOG.info(e);
      throw new CantRunException(XsltDebuggerBundle.message("dialog.message.unable.to.find.free.network.port"));
    }

    String token = UUID.randomUUID().toString();
    parameters.getVMParametersList().defineProperty("xslt.debugger.token", token);
    extensionData.putUserData(ACCESS_TOKEN, token);

    Path xsltDebuggerClassesRoot = Paths.get(PathUtil.getJarPathForClass(getClass()));
    if (!Files.isDirectory(xsltDebuggerClassesRoot)) {
      Path libDirectory = xsltDebuggerClassesRoot.getParent();
      addPathToClasspath(parameters, libDirectory.resolve("xslt-debugger-rt.jar"));
      addPathToClasspath(parameters, libDirectory.resolve("rmi-stubs.jar"));
      addPathToClasspath(parameters, libDirectory.resolve("rt/xslt-debugger-impl-rt.jar"));
    }
    else {
      //running from sources
      Path outProductionDir = xsltDebuggerClassesRoot.getParent();
      addPathToClasspath(parameters, outProductionDir.resolve("intellij.xslt.debugger.rt"));
      addPathToClasspath(parameters, outProductionDir.resolve("intellij.xslt.debugger.impl.rt"));
      addPathToClasspath(parameters, getPluginEngineDirInSources().resolve("lib/rmi-stubs.jar"));
    }

    String type = parameters.getVMParametersList().getPropertyValue("xslt.transformer.type"); //NON-NLS
    if ("saxon".equalsIgnoreCase(type)) {
      addPathToClasspath(parameters, findSaxonJar(xsltDebuggerClassesRoot, SAXON_6_JAR));
    }
    else if ("saxon9".equalsIgnoreCase(type)) {
      addPathToClasspath(parameters, findSaxonJar(xsltDebuggerClassesRoot, SAXON_9_JAR));
    }
    else if ("xalan".equalsIgnoreCase(type)) {
      final Boolean xalanPresent = isValidXalanPresent(parameters);
      if (xalanPresent == null) {
        addXalan(parameters, xsltDebuggerClassesRoot);
      }
      else if (!xalanPresent) {
        throw new CantRunException(XsltDebuggerBundle.message("dialog.message.unsupported.xalan.version.present.in.classpath"));
      }
    }
    else if (type != null) {
      throw new CantRunException(XsltDebuggerBundle.message("dialog.message.unsupported.transformer.type", type));
    }
    else if (StringUtil.toLowerCase(parameters.getClassPath().getPathsString()).contains("xalan")) {
      if (isValidXalanPresent(parameters) == Boolean.TRUE) {
        parameters.getVMParametersList().defineProperty("xslt.transformer.type", "xalan");
      }
    }

    final VirtualFile xsltFile = configuration.findXsltFile();
    final PsiManager psiManager = PsiManager.getInstance(configuration.getProject());
    final XsltChecker.LanguageLevel level;
    if (xsltFile != null) {
      level = XsltSupport.getXsltLanguageLevel(psiManager.findFile(xsltFile));
    }
    else {
      level = XsltChecker.LanguageLevel.V1;
    }
    extensionData.putUserData(VERSION, level);

    if (!parameters.getVMParametersList().hasProperty("xslt.transformer.type")) {
      // add saxon for backward-compatibility
      if (level == XsltChecker.LanguageLevel.V2) {
        parameters.getVMParametersList().defineProperty("xslt.transformer.type", "saxon9");
        addPathToClasspath(parameters, findSaxonJar(xsltDebuggerClassesRoot, SAXON_9_JAR));
      } else {
        parameters.getVMParametersList().defineProperty("xslt.transformer.type", "saxon");
        addPathToClasspath(parameters, findSaxonJar(xsltDebuggerClassesRoot, SAXON_6_JAR));
      }
    }

    parameters.getVMParametersList().defineProperty("xslt.main", "org.intellij.plugins.xsltDebugger.rt.XSLTDebuggerMain");
  }
@Override
  public void patchParameters(SimpleJavaParameters parameters, XsltRunConfiguration configuration, UserDataHolder extensionData)