Skip to content

Commit

Permalink
Update CompilerCachingSuite.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Feb 3, 2025
1 parent c2f6143 commit bcb38be
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import dotty.tools.pc.ScalaPresentationCompiler
import org.junit.{Before, Test}

import scala.language.unsafeNulls
import scala.meta.internal.metals.EmptyCancelToken
import scala.meta.internal.metals.CompilerOffsetParams
import scala.meta.internal.metals.EmptyCancelToken
import scala.meta.internal.metals.EmptyReportContext
import scala.meta.internal.metals.PcQueryContext
import scala.meta.pc.OffsetParams
import scala.concurrent.Future
import scala.concurrent.Await
Expand All @@ -26,20 +28,22 @@ class CompilerCachingSuite extends BasePCSuite:
private def checkCompilationCount(expected: Int): Unit =
presentationCompiler match
case pc: ScalaPresentationCompiler =>
val compilations = pc.compilerAccess.withNonInterruptableCompiler(None)(-1, EmptyCancelToken) { driver =>
val compilations = pc.compilerAccess.withNonInterruptableCompiler(-1, EmptyCancelToken) { driver =>
driver.compiler().currentCtx.runId
}.get(timeout.length, timeout.unit)
}(emptyQueryContext).get(timeout.length, timeout.unit)
assertEquals(expected, compilations, s"Expected $expected compilations but got $compilations")
case _ => throw IllegalStateException("Presentation compiler should always be of type of ScalaPresentationCompiler")

private def getContext(): Context =
presentationCompiler match
case pc: ScalaPresentationCompiler =>
pc.compilerAccess.withNonInterruptableCompiler(None)(null, EmptyCancelToken) { driver =>
pc.compilerAccess.withNonInterruptableCompiler(null, EmptyCancelToken) { driver =>
driver.compiler().currentCtx
}.get(timeout.length, timeout.unit)
}(emptyQueryContext).get(timeout.length, timeout.unit)
case _ => throw IllegalStateException("Presentation compiler should always be of type of ScalaPresentationCompiler")

private def emptyQueryContext = PcQueryContext(None, () => "")(using EmptyReportContext)

@Before
def beforeEach: Unit =
presentationCompiler.restart()
Expand Down

0 comments on commit bcb38be

Please sign in to comment.