-
Notifications
You must be signed in to change notification settings - Fork 315
/
BaseInlayHintsSuite.scala
62 lines (52 loc) 路 1.55 KB
/
BaseInlayHintsSuite.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package tests
import java.net.URI
import scala.meta.internal.jdk.CollectionConverters._
import scala.meta.internal.metals.CompilerInlayHintsParams
import scala.meta.internal.metals.CompilerRangeParams
import munit.Location
import munit.TestOptions
class BaseInlayHintsSuite extends BasePCSuite {
def check(
name: TestOptions,
base: String,
expected: String,
compat: Map[String, String] = Map.empty,
showInferredType: Boolean = true,
showTypeArguments: Boolean = true,
showImplicitArguments: Boolean = true,
showImplicitConversions: Boolean = true,
showContextBounds: Boolean = true
)(implicit location: Location): Unit =
test(name) {
def pkgWrap(text: String) =
if (text.contains("package")) text
else s"package ${scala.meta.Term.Name(name.name)}\n$text"
val withPkg = pkgWrap(base)
val rangeParams = CompilerRangeParams(
URI.create("file:/InlayHints.scala"),
withPkg,
0,
withPkg.length()
)
val pcParams = CompilerInlayHintsParams(
rangeParams,
showInferredType,
showTypeArguments,
showImplicitArguments,
showImplicitConversions,
showContextBounds
)
val inlayHints = presentationCompiler
.inlayHints(
pcParams
)
.get()
.asScala
.toList
val obtained = TestInlayHints.applyInlayHints(withPkg, inlayHints)
assertEquals(
obtained,
pkgWrap(getExpected(expected, compat, scalaVersion))
)
}
}