@@ -23,19 +23,19 @@ class CompilerCachingSuite extends BasePCSuite:
2323
2424 val timeout = 5 .seconds
2525
26- private def checkCompilationCount (params : VirtualFileParams , expected : Int ): Unit =
26+ private def checkCompilationCount (expected : Int ): Unit =
2727 presentationCompiler match
2828 case pc : ScalaPresentationCompiler =>
29- val compilations = pc.compilerAccess.withNonInterruptableCompiler(Some (params) )(- 1 , EmptyCancelToken ) { driver =>
29+ val compilations = pc.compilerAccess.withNonInterruptableCompiler(None )(- 1 , EmptyCancelToken ) { driver =>
3030 driver.compiler().currentCtx.runId
3131 }.get(timeout.length, timeout.unit)
3232 assertEquals(expected, compilations, s " Expected $expected compilations but got $compilations" )
3333 case _ => throw IllegalStateException (" Presentation compiler should always be of type of ScalaPresentationCompiler" )
3434
35- private def getContext (params : VirtualFileParams ): Context =
35+ private def getContext (): Context =
3636 presentationCompiler match
3737 case pc : ScalaPresentationCompiler =>
38- pc.compilerAccess.withNonInterruptableCompiler(Some (params) )(null , EmptyCancelToken ) { driver =>
38+ pc.compilerAccess.withNonInterruptableCompiler(None )(null , EmptyCancelToken ) { driver =>
3939 driver.compiler().currentCtx
4040 }.get(timeout.length, timeout.unit)
4141 case _ => throw IllegalStateException (" Presentation compiler should always be of type of ScalaPresentationCompiler" )
@@ -44,76 +44,73 @@ class CompilerCachingSuite extends BasePCSuite:
4444 def beforeEach : Unit =
4545 presentationCompiler.restart()
4646
47- // We want to run art least one compilation, so runId points at 3.
47+ // We want to run at least one compilation, so runId points at 3.
4848 // This will ensure that we use the same driver, not recreate fresh one on each call
4949 val dryRunParams = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " dryRun" , 1 , EmptyCancelToken )
50- checkCompilationCount(dryRunParams, 2 )
51- val freshContext = getContext(dryRunParams )
50+ checkCompilationCount(2 )
51+ val freshContext = getContext()
5252 presentationCompiler.complete(dryRunParams).get(timeout.length, timeout.unit)
53- checkCompilationCount(dryRunParams, 3 )
54- val dryRunContext = getContext(dryRunParams )
53+ checkCompilationCount(3 )
54+ val dryRunContext = getContext()
5555 assert(freshContext != dryRunContext)
5656
5757
5858 @ Test
5959 def `cursor-compilation-does-not-corrupt-cache` : Unit =
60+ val contextPreCompilation = getContext()
6061
61- val fakeParamsCursor = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = new" , 15 , EmptyCancelToken )
6262 val fakeParams = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = ne" , 14 , EmptyCancelToken )
63-
64- val contextPreCompilation = getContext(fakeParams)
65-
6663 presentationCompiler.complete(fakeParams).get(timeout.length, timeout.unit)
67- val contextPostFirst = getContext(fakeParams )
64+ val contextPostFirst = getContext()
6865 assert(contextPreCompilation != contextPostFirst)
69- checkCompilationCount(fakeParams, 4 )
66+ checkCompilationCount(4 )
7067
68+ val fakeParamsCursor = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = new" , 15 , EmptyCancelToken )
7169 presentationCompiler.complete(fakeParamsCursor).get(timeout.length, timeout.unit)
72- val contextPostCursor = getContext(fakeParamsCursor )
70+ val contextPostCursor = getContext()
7371 assert(contextPreCompilation != contextPostCursor)
7472 assert(contextPostFirst == contextPostCursor)
75- checkCompilationCount(fakeParamsCursor, 4 )
73+ checkCompilationCount(4 )
7674
7775 presentationCompiler.complete(fakeParams).get(timeout.length, timeout.unit)
78- val contextPostSecond = getContext(fakeParams )
76+ val contextPostSecond = getContext()
7977 assert(contextPreCompilation != contextPostSecond)
8078 assert(contextPostFirst == contextPostCursor)
8179 assert(contextPostCursor == contextPostSecond)
82- checkCompilationCount(fakeParamsCursor, 4 )
80+ checkCompilationCount(4 )
8381
8482 @ Test
8583 def `compilation-for-same-snippet-is-cached` : Unit =
86- val fakeParams = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = ne" , 14 , EmptyCancelToken )
87-
88- val contextPreCompilation = getContext(fakeParams)
84+ val contextPreCompilation = getContext()
8985
86+ val fakeParams = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = ne" , 14 , EmptyCancelToken )
9087 presentationCompiler.complete(fakeParams).get(timeout.length, timeout.unit)
91- val contextPostFirst = getContext(fakeParams )
88+ val contextPostFirst = getContext()
9289 assert(contextPreCompilation != contextPostFirst)
93- checkCompilationCount(fakeParams, 4 )
90+ checkCompilationCount(4 )
9491
9592 presentationCompiler.complete(fakeParams).get(timeout.length, timeout.unit)
96- val contextPostSecond = getContext(fakeParams )
93+ val contextPostSecond = getContext()
9794 assert(contextPreCompilation != contextPostFirst)
9895 assert(contextPostSecond == contextPostFirst)
99- checkCompilationCount(fakeParams, 4 )
96+ checkCompilationCount(4 )
10097
10198 @ Test
10299 def `compilation-for-different-snippet-is-not-cached` : Unit =
103100
104- val fakeParams = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = prin" , 16 , EmptyCancelToken )
105- val fakeParams2 = CompilerOffsetParams (Paths .get(" Test2.scala" ).toUri(), " def hello = prin" , 16 , EmptyCancelToken )
106- val fakeParams3 = CompilerOffsetParams (Paths .get(" Test2.scala" ).toUri(), " def hello = print" , 17 , EmptyCancelToken )
107101
108- checkCompilationCount(fakeParams, 3 )
102+ checkCompilationCount(3 )
103+ val fakeParams = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = prin" , 16 , EmptyCancelToken )
109104 presentationCompiler.complete(fakeParams).get(timeout.length, timeout.unit)
110- checkCompilationCount(fakeParams, 4 )
105+ checkCompilationCount(4 )
111106
107+ val fakeParams2 = CompilerOffsetParams (Paths .get(" Test2.scala" ).toUri(), " def hello = prin" , 16 , EmptyCancelToken )
112108 presentationCompiler.complete(fakeParams2).get(timeout.length, timeout.unit)
113- checkCompilationCount(fakeParams2, 5 )
109+ checkCompilationCount(5 )
114110
111+ val fakeParams3 = CompilerOffsetParams (Paths .get(" Test2.scala" ).toUri(), " def hello = print" , 17 , EmptyCancelToken )
115112 presentationCompiler.complete(fakeParams3).get(timeout.length, timeout.unit)
116- checkCompilationCount(fakeParams3, 6 )
113+ checkCompilationCount(6 )
117114
118115
119116 private val testFunctions : List [OffsetParams => CompletableFuture [_]] = List (
@@ -137,14 +134,14 @@ class CompilerCachingSuite extends BasePCSuite:
137134 @ Test
138135 def `different-api-calls-reuse-cache` : Unit =
139136 val fakeParams = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = ne" , 13 , EmptyCancelToken )
140-
141137 presentationCompiler.complete(fakeParams).get(timeout.length, timeout.unit)
142- val contextBefore = getContext(fakeParams)
138+
139+ val contextBefore = getContext()
143140
144141 val differentContexts = testFunctions.map: f =>
145142 f(fakeParams).get(timeout.length, timeout.unit)
146- checkCompilationCount(fakeParams, 4 )
147- getContext(fakeParams )
143+ checkCompilationCount(4 )
144+ getContext()
148145 .toSet
149146
150147 assert(differentContexts == Set (contextBefore))
@@ -155,12 +152,12 @@ class CompilerCachingSuite extends BasePCSuite:
155152 import scala .concurrent .ExecutionContext .Implicits .global
156153
157154 val fakeParams = CompilerOffsetParams (Paths .get(" Test.scala" ).toUri(), " def hello = ne" , 13 , EmptyCancelToken )
158-
159155 presentationCompiler.complete(fakeParams).get(timeout.length, timeout.unit)
160- val contextBefore = getContext(fakeParams)
156+
157+ val contextBefore = getContext()
161158
162159 val futures = testFunctions.map: f =>
163- f(fakeParams).asScala.map(_ => getContext(fakeParams ))
160+ f(fakeParams).asScala.map(_ => getContext())
164161
165162 val res = Await .result(Future .sequence(futures), timeout).toSet
166163 assert(res == Set (contextBefore))
0 commit comments