From bcb38bee9e68d1b310b4c98fb87cb7790fdb9519 Mon Sep 17 00:00:00 2001 From: kasiaMarek Date: Mon, 3 Feb 2025 10:53:21 +0100 Subject: [PATCH] Update CompilerCachingSuite.scala --- .../tools/pc/tests/CompilerCachingSuite.scala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala index 5e13c07b9e5f..b2d837e2ff50 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala @@ -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 @@ -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()