From abb54e75568f38bcc3f731de137b67e59752e4d7 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Tue, 17 Jan 2017 09:51:11 +0100 Subject: Add distinction between `var` and `val` --- doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala | 5 ++++- doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala | 1 + doc-tool/src/dotty/tools/dottydoc/model/entities.scala | 8 +------- doc-tool/src/dotty/tools/dottydoc/model/internal.scala | 1 + 4 files changed, 7 insertions(+), 8 deletions(-) (limited to 'doc-tool/src/dotty/tools') diff --git a/doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala b/doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala index ed31eeb05..cc47144fc 100644 --- a/doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala +++ b/doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala @@ -63,12 +63,14 @@ class DocASTPhase extends Phase { }.toList val vals = sym.info.fields.filterNot(_.symbol.is(Flags.Private | Flags.Synthetic)).map { value => + val kind = if (value.symbol.is(Flags.Mutable)) "var" else "val" ValImpl( value.symbol, annotations(value.symbol), value.symbol.name.show, Nil, path(value.symbol), returnType(value.info), + kind, implicitlyAddedFrom = Some(returnType(value.symbol.owner.info)) ) } @@ -115,7 +117,8 @@ class DocASTPhase extends Phase { /** val */ case v: ValDef if !v.symbol.is(Flags.ModuleVal) => - ValImpl(v.symbol, annotations(v.symbol), v.name.decode.toString, flags(v), path(v.symbol), returnType(v.tpt.tpe)) + val kind = if (v.symbol.is(Flags.Mutable)) "var" else "val" + ValImpl(v.symbol, annotations(v.symbol), v.name.decode.toString, flags(v), path(v.symbol), returnType(v.tpt.tpe), kind) case x => { //dottydoc.println(s"Found unwanted entity: $x (${x.pos},\n${x.show}") diff --git a/doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala b/doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala index 80e2929f7..d87cdf098 100644 --- a/doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala +++ b/doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala @@ -179,6 +179,7 @@ object transform { vl.modifiers, vl.path, vl.returnValue, + vl.kind, vl.comment, vl.implicitlyAddedFrom ) diff --git a/doc-tool/src/dotty/tools/dottydoc/model/entities.scala b/doc-tool/src/dotty/tools/dottydoc/model/entities.scala index 6f6e8d3e8..295b6568a 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/entities.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/entities.scala @@ -108,13 +108,7 @@ trait Def extends Entity with Modifiers with TypeParams with ReturnValue with Im def paramLists: List[ParamList] } -trait Val extends Entity with Modifiers with ReturnValue with ImplicitlyAddedEntity { - val kind = "val" -} - -trait Var extends Entity with Modifiers with ReturnValue { - val kind = "var" -} +trait Val extends Entity with Modifiers with ReturnValue with ImplicitlyAddedEntity trait NonEntity extends Entity { val annotations = Nil diff --git a/doc-tool/src/dotty/tools/dottydoc/model/internal.scala b/doc-tool/src/dotty/tools/dottydoc/model/internal.scala index dd592c2e1..5bc410706 100644 --- a/doc-tool/src/dotty/tools/dottydoc/model/internal.scala +++ b/doc-tool/src/dotty/tools/dottydoc/model/internal.scala @@ -100,6 +100,7 @@ object internal { modifiers: List[String], path: List[String], returnValue: Reference, + kind: String, var comment: Option[Comment] = None, implicitlyAddedFrom: Option[Reference] = None ) extends Val with Impl -- cgit v1.2.3