Skip to content

Commit

Permalink
probably hopeless attempt to fix leaking library loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
jastice authored and teamcityserver committed Nov 5, 2017
1 parent cb18bb7 commit 63d2fd9
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
import org.jetbrains.plugins.scala.debugger.Scala_2_10$;
import org.jetbrains.plugins.scala.util.TestUtils;
import scala.collection.Seq;
import scala.collection.immutable.Vector$;
import scala.collection.mutable.Buffer;
import scala.collection.mutable.Buffer$;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* @author Alexander Podkhalyuzin
Expand Down Expand Up @@ -71,21 +72,21 @@ public Module module() {

@Override
public Seq<LibraryLoader> librariesLoaders() {
return scala.collection.JavaConverters.asScalaBuffer(librariesLoadersAdapter());
}

private List<LibraryLoader> librariesLoadersAdapter() {
Module module = module();
ArrayList<LibraryLoader> back = new ArrayList<>();

ArrayList<LibraryLoader> result = new ArrayList<LibraryLoader>();
result.add(new ScalaLibraryLoader(isIncludeReflectLibrary(), module));
ScalaLibraryLoader scalaLoader = new ScalaLibraryLoader(isIncludeReflectLibrary(), module);
back.add(scalaLoader);

String path = rootPath();
if (path != null) {
result.add(new SourcesLoader(path, module));
back.add(new SourcesLoader(path, module));
}

result.addAll(Arrays.asList(additionalLibraries()));
Buffer<LibraryLoader> result = scala.collection.JavaConverters.asScalaBuffer(back);
Seq addLibs = additionalLibraries();
//noinspection unchecked (because variance)
result.$plus$plus$eq(addLibs);

return result;
}
Expand Down Expand Up @@ -120,8 +121,8 @@ protected boolean isIncludeReflectLibrary() {
return false;
}

protected ThirdPartyLibraryLoader[] additionalLibraries() {
return EMPTY_LOADERS_ARRAY;
protected Seq<ThirdPartyLibraryLoader> additionalLibraries() {
return Vector$.MODULE$.empty();
}

protected VirtualFile getVFileAdapter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.junit.experimental.categories.Category
@Category(Array(classOf[PerfCycleTests]))
class Postgres extends FailedResolveTest("postgresql") {

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(PostgresLoader()(module))
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
Seq(PostgresLoader()(module))

def testSCL8556(): Unit = doTest()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.junit.experimental.categories.Category
@Category(Array(classOf[PerfCycleTests]))
class ScalazTest extends FailedResolveTest("scalaz") {

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(ScalaZCoreLoader()(module))
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
Seq(ScalaZCoreLoader()(module))

def testSCL7213(): Unit = doTest()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import org.junit.experimental.categories.Category
@Category(Array(classOf[PerfCycleTests]))
class ScalaZTest extends TypeInferenceTestBase {

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(ScalaZCoreLoader()(module))
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
Seq(ScalaZCoreLoader()(module))

def testSCL5706(): Unit = {
doTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.junit.experimental.categories.Category
@Category(Array(classOf[PerfCycleTests]))
class Specs2ToScalaCheckImplicitTest extends TypeInferenceTestBase {

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(Specs2Loader("2.4.15")(module), ScalaZCoreLoader()(module))
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
Seq(Specs2Loader("2.4.15")(module), ScalaZCoreLoader()(module))

def testSCL8864(): Unit = doTest {
s"""object Main extends App {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class AdjustTypesTests extends AdjustTypesTestBase {

class AdjustCatsTypeTest extends AdjustTypesTestBase {

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(CatsLoader()(module))
override protected def additionalLibraries(): Seq[CatsLoader] =
Seq(CatsLoader()(module))

def testSCL10006(): Unit = doTest()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class MonocleLensesTest extends ScalaLightPlatformCodeInsightTestCaseAdapter {

override implicit val version: ScalaVersion = Scala_2_12

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] = {
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] = {
import MonocleLensesTest._

implicit val module: Module = getModuleAdapter
Array(MonocleCoreLoader(), MonocleMacroLoader(), MonocleGeneric())
Seq(MonocleCoreLoader(), MonocleMacroLoader(), MonocleGeneric())
}

protected def folderPath: String = TestUtils.getTestDataPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import org.junit.experimental.categories.Category
@Category(Array(classOf[SlowTests]))
class TypeInferenceCatsTest extends TypeInferenceTestBase {

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(CatsLoader()(module))
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
Seq(CatsLoader()(module))

override protected def folderPath: String = super.folderPath + "cats/"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class TypeInferenceScalazTest extends TypeInferenceTestBase {
//This class was generated by build script, please don't change this
override def folderPath: String = super.folderPath + "scalaz/"

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(ScalaZCoreLoader()(module))
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
Seq(ScalaZCoreLoader()(module))

def testSCL3819() {
doTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class TypeInferenceSlickTest extends TypeInferenceTestBase {
//This class was generated by build script, please don't change this
override def folderPath: String = super.folderPath + "slick/"

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(SlickLoader()(module))
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
Seq(SlickLoader()(module))

def testSCL9261(): Unit = doTest()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class TypeInferenceSprayTest extends TypeInferenceTestBase {
//This class was generated by build script, please don't change this
override def folderPath: String = super.folderPath + "spray/"

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
Array(SprayLoader()(module))
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
Seq(SprayLoader()(module))

def testSCL8274(): Unit = doTest()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait ScalaMetaLibrariesOwner extends ScalaSdkOwner {

import ScalaMetaLibrariesOwner._

protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] = Array(
protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] = Seq(
MetaCommonLoader(),
MetaDialectsLoader(),
MetaInlineLoader(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import scala.meta.ScalaMetaLibrariesOwner

abstract class QuasiQuoteTypeInferenceTestBase extends TypeInferenceTestBase with ScalaMetaLibrariesOwner {

override protected def additionalLibraries(): Array[ThirdPartyLibraryLoader] =
super.additionalLibraries()
override protected def additionalLibraries(): Seq[ThirdPartyLibraryLoader] =
super[ScalaMetaLibrariesOwner].additionalLibraries()

override protected def doTest(fileText: String): Unit =
super.doTest(
Expand Down

0 comments on commit 63d2fd9

Please sign in to comment.