-
Notifications
You must be signed in to change notification settings - Fork 315
/
RefinedDotcPrinter.scala
30 lines (26 loc) 路 1.03 KB
/
RefinedDotcPrinter.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
package scala.meta.internal.pc.printer
import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Flags._
import dotty.tools.dotc.core.StdNames._
import dotty.tools.dotc.core.Types._
import dotty.tools.dotc.printing.RefinedPrinter
import dotty.tools.dotc.printing.Texts.Text
/* In 3.4.x some changes were made to printer,
but haven't managed to port all of them yet to the LTS */
abstract class RefinedDotcPrinter(_ctx: Context) extends RefinedPrinter(_ctx):
def toTextPrefix(tp: Type) =
tp match
case tp: NamedType => super.toTextPrefixOf(tp)
case tp => Text()
override def toText(tp: Type): Text =
tp match
case tp: TermRef
if !tp.denotationIsCurrent && !homogenizedView ||
tp.symbol.is(Module) || tp.symbol.name == nme.IMPORT =>
toTextPrefix(tp.prefix) ~ selectionString(tp) ~ ".type"
case tp: TermRef =>
toTextPrefix(tp.prefix) ~ selectionString(tp)
case tr: TypeRef =>
super.toText(tr)
case _ => super.toText(tp)
end RefinedDotcPrinter