<commit_before>package org.jetbrains.plugins.scala
package worksheet.server


import java.io._
import java.net._
import org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode
import com.intellij.util.{Base64Converter, PathUtil}
import org.jetbrains.plugins.scala.compiler.ScalaApplicationSettings
import org.jetbrains.jps.incremental.scala.remote._
import com.intellij.openapi.module.Module
import org.jetbrains.plugins.scala
import org.jetbrains.plugin.scala.compiler.IncrementalType
import com.intellij.openapi.roots.{ModuleRootManager, OrderEnumerator}
import org.jetbrains.plugins.scala.config.ScalaFacet
import org.jetbrains.jps.incremental.scala.Client
import org.jetbrains.jps.incremental.scala.data.SbtData
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.jps.incremental.messages.BuildMessage.Kind
import org.jetbrains.plugins.scala.worksheet.server.RemoteServerConnector.{OuterCompilerInterface, DummyClient}
import com.intellij.openapi.progress.{ProgressManager, ProgressIndicator}
import com.intellij.openapi.project.Project
import com.intellij.compiler.CompilerMessageImpl
import org.jetbrains.jps.incremental.messages.BuildMessage
import org.jetbrains.plugins.scala.worksheet.processor.WorksheetSourceProcessor
import com.intellij.openapi.compiler.{CompilerPaths, CompilerMessageCategory}
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.compiler.progress.CompilerTask
import org.jetbrains.plugins.scala.worksheet.ui.WorksheetEditorPrinter

/**
  * User: <NAME>
 * Date: 1/28/14
 */
class RemoteServerConnector(module: Module, worksheet: File, output: File) extends RemoteResourceOwner {
  protected val address = InetAddress.getByName(null)
  
  protected val port = 
    try 
      Integer parseInt ScalaApplicationSettings.getInstance().COMPILE_SERVER_PORT 
    catch {
      case e: NumberFormatException => 
        throw new IllegalArgumentException("Bad port: " + ScalaApplicationSettings.getInstance().COMPILE_SERVER_PORT , e)
    }
  
  private val libRoot = new File(PathUtil.getJarPathForClass(getClass)).getParentFile 
  
  private val libCanonicalPath = PathUtil.getCanonicalPath(libRoot.getPath)
  
  private val sbtData = SbtData.from(
    new URLClassLoader(Array(new URL("jar:file:/" + libCanonicalPath + "/jps/sbt-interface.jar!/")), getClass.getClassLoader),
    new File(libRoot, "jps"),
    new File(System.getProperty("user.home"), ".idea-build"),
    System.getProperty("java.class.version") 
  ) match {
    case Left(msg) => throw new IllegalArgumentException(msg)
    case Right(data) => data
  }
  
  private val scalaParameters = facet.compilerParameters
  
  private val javaParameters = Array.empty[String]


  /**
   *     Seq(
      fileToPath(sbtData.interfaceJar),<commit_msg>Problem with slash in URL (for Mac\Linux) fixed<commit_after>package org.jetbrains.plugins.scala
package worksheet.server


import java.io._
import java.net._
import org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode
import com.intellij.util.{Base64Converter, PathUtil}
import org.jetbrains.plugins.scala.compiler.ScalaApplicationSettings
import org.jetbrains.jps.incremental.scala.remote._
import com.intellij.openapi.module.Module
import org.jetbrains.plugins.scala
import org.jetbrains.plugin.scala.compiler.IncrementalType
import com.intellij.openapi.roots.{ModuleRootManager, OrderEnumerator}
import org.jetbrains.plugins.scala.config.ScalaFacet
import org.jetbrains.jps.incremental.scala.Client
import org.jetbrains.jps.incremental.scala.data.SbtData
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.jps.incremental.messages.BuildMessage.Kind
import org.jetbrains.plugins.scala.worksheet.server.RemoteServerConnector.{OuterCompilerInterface, DummyClient}
import com.intellij.openapi.progress.{ProgressManager, ProgressIndicator}
import com.intellij.openapi.project.Project
import com.intellij.compiler.CompilerMessageImpl
import org.jetbrains.jps.incremental.messages.BuildMessage
import org.jetbrains.plugins.scala.worksheet.processor.WorksheetSourceProcessor
import com.intellij.openapi.compiler.{CompilerPaths, CompilerMessageCategory}
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.compiler.progress.CompilerTask
import org.jetbrains.plugins.scala.worksheet.ui.WorksheetEditorPrinter

/**
  * User: <NAME>
 * Date: 1/28/14
 */
class RemoteServerConnector(module: Module, worksheet: File, output: File) extends RemoteResourceOwner {
  protected val address = InetAddress.getByName(null)
  
  protected val port = 
    try 
      Integer parseInt ScalaApplicationSettings.getInstance().COMPILE_SERVER_PORT 
    catch {
      case e: NumberFormatException => 
        throw new IllegalArgumentException("Bad port: " + ScalaApplicationSettings.getInstance().COMPILE_SERVER_PORT , e)
    }
  
  private val libRoot = new File(PathUtil.getJarPathForClass(getClass)).getParentFile 
  
  private val libCanonicalPath = PathUtil.getCanonicalPath(libRoot.getPath)
  
  private val sbtData = SbtData.from(
    new URLClassLoader(Array(new URL("jar:file:" + (if (libCanonicalPath startsWith "/") "" else "/" ) + libCanonicalPath + "/jps/sbt-interface.jar!/")), getClass.getClassLoader),
    new File(libRoot, "jps"),
    new File(System.getProperty("user.home"), ".idea-build"),
    System.getProperty("java.class.version") 
  ) match {
    case Left(msg) => throw new IllegalArgumentException(msg)
    case Right(data) => data
  }
  
  private val scalaParameters = facet.compilerParameters
  
  private val javaParameters = Array.empty[String]


  /**
   *     Seq(
      fileToPath(sbtData.interfaceJar),
{'fraction_non_alphanumeric': 0.1008028545941124, 'fraction_numerical': 0.0024977698483496878, 'mean_word_length': 5.305961754780652, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5219967', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1679, 'n_words': 286}