Skip to content

Commit abb54e7

Browse files
committed
Add distinction between var and val
1 parent 9a581bc commit abb54e7

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

doc-tool/src/dotty/tools/dottydoc/core/DocASTPhase.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ class DocASTPhase extends Phase {
6363
}.toList
6464

6565
val vals = sym.info.fields.filterNot(_.symbol.is(Flags.Private | Flags.Synthetic)).map { value =>
66+
val kind = if (value.symbol.is(Flags.Mutable)) "var" else "val"
6667
ValImpl(
6768
value.symbol,
6869
annotations(value.symbol),
6970
value.symbol.name.show,
7071
Nil, path(value.symbol),
7172
returnType(value.info),
73+
kind,
7274
implicitlyAddedFrom = Some(returnType(value.symbol.owner.info))
7375
)
7476
}
@@ -115,7 +117,8 @@ class DocASTPhase extends Phase {
115117

116118
/** val */
117119
case v: ValDef if !v.symbol.is(Flags.ModuleVal) =>
118-
ValImpl(v.symbol, annotations(v.symbol), v.name.decode.toString, flags(v), path(v.symbol), returnType(v.tpt.tpe))
120+
val kind = if (v.symbol.is(Flags.Mutable)) "var" else "val"
121+
ValImpl(v.symbol, annotations(v.symbol), v.name.decode.toString, flags(v), path(v.symbol), returnType(v.tpt.tpe), kind)
119122

120123
case x => {
121124
//dottydoc.println(s"Found unwanted entity: $x (${x.pos},\n${x.show}")

doc-tool/src/dotty/tools/dottydoc/core/MiniPhaseTransform.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ object transform {
179179
vl.modifiers,
180180
vl.path,
181181
vl.returnValue,
182+
vl.kind,
182183
vl.comment,
183184
vl.implicitlyAddedFrom
184185
)

doc-tool/src/dotty/tools/dottydoc/model/entities.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,7 @@ trait Def extends Entity with Modifiers with TypeParams with ReturnValue with Im
108108
def paramLists: List[ParamList]
109109
}
110110

111-
trait Val extends Entity with Modifiers with ReturnValue with ImplicitlyAddedEntity {
112-
val kind = "val"
113-
}
114-
115-
trait Var extends Entity with Modifiers with ReturnValue {
116-
val kind = "var"
117-
}
111+
trait Val extends Entity with Modifiers with ReturnValue with ImplicitlyAddedEntity
118112

119113
trait NonEntity extends Entity {
120114
val annotations = Nil

doc-tool/src/dotty/tools/dottydoc/model/internal.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ object internal {
100100
modifiers: List[String],
101101
path: List[String],
102102
returnValue: Reference,
103+
kind: String,
103104
var comment: Option[Comment] = None,
104105
implicitlyAddedFrom: Option[Reference] = None
105106
) extends Val with Impl

0 commit comments

Comments
 (0)