Skip to content

Commit ca71bd8

Browse files
committed
Store whether comment is expanded in TASTY
1 parent f1431ce commit ca71bd8

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

compiler/src/dotty/tools/dotc/core/tasty/CommentPickler.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class CommentPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Option[Addr]
2121
buf.writeAddr(addr)
2222
buf.writeNat(length)
2323
buf.writeBytes(bytes, length)
24+
buf.writeBoolean(cmt.isExpanded)
2425
case other =>
2526
()
2627
}

compiler/src/dotty/tools/dotc/core/tasty/CommentUnpickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class CommentUnpickler(reader: TastyReader) {
1919
val length = readNat()
2020
if (length > 0) {
2121
val bytes = readBytes(length)
22+
val expanded = readBoolean()
2223
val rawComment = new String(bytes, Charset.forName("UTF-8"))
23-
comments(addr) = Comment(Positions.NoPosition, rawComment)
24+
comments(addr) = Comment(Positions.NoPosition, rawComment, expanded = expanded)
2425
}
2526
}
2627
comments.toMap

compiler/src/dotty/tools/dotc/core/tasty/TastyBuffer.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class TastyBuffer(initialSize: Int) {
4848

4949
// -- Output routines --------------------------------------------
5050

51+
/** Write a boolean value. */
52+
def writeBoolean(b: Boolean): Unit =
53+
writeByte(if (b) 1 else 0)
54+
5155
/** Write a byte of data. */
5256
def writeByte(b: Int): Unit = {
5357
if (length >= bytes.length)

compiler/src/dotty/tools/dotc/core/tasty/TastyReader.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class TastyReader(val bytes: Array[Byte], start: Int, end: Int, val base: Int =
4141
def subReader(start: Addr, end: Addr): TastyReader =
4242
new TastyReader(bytes, index(start), index(end), base)
4343

44+
/** Read a boolean value. */
45+
def readBoolean(): Boolean =
46+
readByte() == 1
47+
4448
/** Read a byte of data. */
4549
def readByte(): Int = {
4650
val result = bytes(bp) & 0xff

0 commit comments

Comments
 (0)