diff options
author | odersky <odersky@gmail.com> | 2017-02-21 17:10:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 17:10:14 +0100 |
commit | 355232690d96e458764159a66f3fed0135c059a3 (patch) | |
tree | c6183190768ead9ddaa5e5103dad7f5007b9c182 /compiler/src/dotty/tools/dotc/printing | |
parent | 6189ffe415c8905cc5802f0505d837b4142999db (diff) | |
parent | 7c4a9ec39ad3c6302767442de34f53c28cc3bebb (diff) | |
download | dotty-355232690d96e458764159a66f3fed0135c059a3.tar.gz dotty-355232690d96e458764159a66f3fed0135c059a3.tar.bz2 dotty-355232690d96e458764159a66f3fed0135c059a3.zip |
Merge pull request #1974 from dotty-staging/fix/ctx-capture
Avoid accidental captures of Context
Diffstat (limited to 'compiler/src/dotty/tools/dotc/printing')
-rw-r--r-- | compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala | 12 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/printing/Printer.scala | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 1c3ff8ea0..0d1068b8c 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -7,6 +7,7 @@ import Contexts.Context, Scopes.Scope, Denotations.Denotation, Annotations.Annot import StdNames.{nme, tpnme} import ast.Trees._, ast._ import typer.Implicits._ +import typer.ImportInfo import config.Config import java.lang.Integer.toOctalString import config.Config.summarizeDepth @@ -503,6 +504,17 @@ class PlainPrinter(_ctx: Context) extends Printer { "?Unknown Implicit Result?" } + def toText(importInfo: ImportInfo): Text = { + val siteStr = importInfo.site.show + val exprStr = if (siteStr endsWith ".type") siteStr dropRight 5 else siteStr + val selectorStr = importInfo.selectors match { + case Ident(name) :: Nil => name.show + case _ => "{...}" + } + s"import $exprStr.$selectorStr" + } + + private var maxSummarized = Int.MaxValue def summarized[T](depth: Int)(op: => T): T = { diff --git a/compiler/src/dotty/tools/dotc/printing/Printer.scala b/compiler/src/dotty/tools/dotc/printing/Printer.scala index 506773a4b..e163a83f3 100644 --- a/compiler/src/dotty/tools/dotc/printing/Printer.scala +++ b/compiler/src/dotty/tools/dotc/printing/Printer.scala @@ -6,6 +6,7 @@ import Texts._, ast.Trees._ import Types.Type, Symbols.Symbol, Contexts.Context, Scopes.Scope, Constants.Constant, Names.Name, Denotations._, Annotations.Annotation import typer.Implicits.SearchResult +import typer.ImportInfo /** The base class of all printers */ @@ -98,6 +99,9 @@ abstract class Printer { /** Textual representation of implicit search result */ def toText(result: SearchResult): Text + /** Textual representation of info relating to an import clause */ + def toText(result: ImportInfo): Text + /** Perform string or text-producing operation `op` so that only a * summarized text with given recursion depth is shown */ |