aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-07-17 15:44:10 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-03 17:28:33 +0200
commit9d90361eeb76f3b090a96033e20ed1a272c3493c (patch)
tree1bc0b0e1cf37102e28fa72361e71a7a4e86ae83b /src
parent2cb905004b28707b4c127e5a1848084109ddb3db (diff)
downloaddotty-9d90361eeb76f3b090a96033e20ed1a272c3493c.tar.gz
dotty-9d90361eeb76f3b090a96033e20ed1a272c3493c.tar.bz2
dotty-9d90361eeb76f3b090a96033e20ed1a272c3493c.zip
Add showDcl method for SingleDenotations
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala8
-rw-r--r--src/dotty/tools/dotc/printing/PlainPrinter.scala10
-rw-r--r--src/dotty/tools/dotc/printing/Printer.scala5
3 files changed, 17 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 43fff62ec..022230ff8 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -619,7 +619,7 @@ object Denotations {
throw new StaleSymbol(msg)
}
- /** The period (interval of phases) for which there exists
+ /** The period (interval of phases) for which there exists
* a valid denotation in this flock.
*/
def coveredInterval(implicit ctx: Context): Period = {
@@ -641,11 +641,15 @@ object Denotations {
*/
def syncWithParents(implicit ctx: Context): SingleDenotation = this
+ /** Show declaration string; useful for showing declarations
+ * as seen from subclasses.
+ */
+ def showDcl(implicit ctx: Context): String = ctx.dclText(this).show
+
override def toString =
if (symbol == NoSymbol) symbol.toString
else s"<SingleDenotation of type $infoOrCompleter>"
-
def definedPeriodsString: String = {
var sb = new StringBuilder()
var cur = this
diff --git a/src/dotty/tools/dotc/printing/PlainPrinter.scala b/src/dotty/tools/dotc/printing/PlainPrinter.scala
index ec4a4db88..94b325996 100644
--- a/src/dotty/tools/dotc/printing/PlainPrinter.scala
+++ b/src/dotty/tools/dotc/printing/PlainPrinter.scala
@@ -2,7 +2,7 @@ package dotty.tools.dotc
package printing
import core._
-import Texts._, Types._, Flags._, Names._, Symbols._, NameOps._, Constants._
+import Texts._, Types._, Flags._, Names._, Symbols._, NameOps._, Constants._, Denotations._
import Contexts.Context, Scopes.Scope, Denotations.Denotation, Annotations.Annotation
import StdNames.nme
import ast.Trees._, ast.untpd
@@ -321,9 +321,13 @@ class PlainPrinter(_ctx: Context) extends Printer {
def annotsText(sym: Symbol): Text = Text(sym.annotations.map(toText))
- def dclText(sym: Symbol): Text =
+ def dclText(sym: Symbol): Text = dclTextWithInfo(sym, sym.unforcedInfo)
+
+ def dclText(d: SingleDenotation): Text = dclTextWithInfo(d.symbol, Some(d.info))
+
+ private def dclTextWithInfo(sym: Symbol, info: Option[Type]): Text =
(toTextFlags(sym) ~~ keyString(sym) ~~
- (varianceString(sym) ~ nameString(sym)) ~ toTextRHS(sym.unforcedInfo)).close
+ (varianceString(sym) ~ nameString(sym)) ~ toTextRHS(info)).close
def toText(sym: Symbol): Text =
(kindString(sym) ~~ {
diff --git a/src/dotty/tools/dotc/printing/Printer.scala b/src/dotty/tools/dotc/printing/Printer.scala
index 65162a10f..360874522 100644
--- a/src/dotty/tools/dotc/printing/Printer.scala
+++ b/src/dotty/tools/dotc/printing/Printer.scala
@@ -4,7 +4,7 @@ package printing
import core._
import Texts._, ast.Trees._
import Types.Type, Symbols.Symbol, Contexts.Context, Scopes.Scope, Constants.Constant,
- Names.Name, Denotations.Denotation, Annotations.Annotation
+ Names.Name, Denotations._, Annotations.Annotation
/** The base class of all printers
*/
@@ -59,6 +59,9 @@ abstract class Printer {
/** Textual representation of symbol's declaration */
def dclText(sym: Symbol): Text
+ /** Textual representation of single denotation's declaration */
+ def dclText(sd: SingleDenotation): Text
+
/** If symbol's owner is a printable class C, the text "in C", otherwise "" */
def locationText(sym: Symbol): Text