diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-01-17 09:51:11 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-01-31 14:32:38 +0100 |
commit | abb54e75568f38bcc3f731de137b67e59752e4d7 (patch) | |
tree | 336ca828ac323c4bc19f0144f9cbcfffc680d29a /doc-tool/src/dotty | |
parent | 9a581bc15aa300f665428c804611453609955f60 (diff) | |
download | dotty-abb54e75568f38bcc3f731de137b67e59752e4d7.tar.gz dotty-abb54e75568f38bcc3f731de137b67e59752e4d7.tar.bz2 dotty-abb54e75568f38bcc3f731de137b67e59752e4d7.zip |
Add distinction between `var` and `val`
Diffstat (limited to 'doc-tool/src/dotty')
4 files changed, 7 insertions, 8 deletions
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 |