/
Compat.scala
58 lines (47 loc) 路 1.68 KB
/
Compat.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
package scala.meta.internal.pc
import java.{util => ju}
import scala.reflect.internal.Reporter
import scala.tools.nsc.reporters.StoreReporter
import scala.meta.internal.jdk.CollectionConverters._
import scala.meta.pc.OutlineFiles
import scala.meta.pc.VirtualFileParams
trait Compat { this: MetalsGlobal =>
def metalsFunctionArgTypes(tpe: Type): List[Type] =
definitions.functionOrPfOrSamArgTypes(tpe)
val AssignOrNamedArg: NamedArgExtractor = NamedArg
def storeReporter(r: Reporter): Option[StoreReporter] =
r match {
case s: StoreReporter => Some(s)
case _ => None
}
def isAliasCompletion(m: Member): Boolean = false
def constantType(c: ConstantType): ConstantType =
if (c.value.isSuitableLiteralType) LiteralType(c.value) else c
def runOutline(files: OutlineFiles): Unit = {
this.settings.Youtline.value = true
runOutline(files.files)
if (files.isFirstCompileSubstitute()) {
// if first compilation substitute we compile all files twice
// first to emit symbols, second so signatures have information about those symbols
// this isn't a perfect strategy but much better than single compile
runOutline(files.files, forceNewUnit = true)
}
this.settings.Youtline.value = false
}
private def runOutline(
files: ju.List[VirtualFileParams],
forceNewUnit: Boolean = false
): Unit = {
files.asScala.foreach { params =>
val unit = this.addCompilationUnit(
params.text(),
params.uri.toString(),
cursor = None,
isOutline = true,
forceNew = forceNewUnit
)
this.typeCheck(unit)
this.richCompilationCache.put(params.uri().toString(), unit)
}
}
}