Skip to content

Commit cf304cb

Browse files
committed
Implement CommentOps in kernel
1 parent 80028d9 commit cf304cb

File tree

6 files changed

+13
-24
lines changed

6 files changed

+13
-24
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/CommentOpsImpl.scala

Lines changed: 0 additions & 10 deletions
This file was deleted.

compiler/src/dotty/tools/dotc/tastyreflect/CoreImpl.scala

Lines changed: 0 additions & 8 deletions
This file was deleted.

compiler/src/dotty/tools/dotc/tastyreflect/KernelImpl.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,10 @@ class KernelImpl(val rootContext: core.Contexts.Context, val rootPosition: util.
13131313

13141314
type Comment = core.Comments.Comment
13151315

1316+
def Comment_raw(self: Comment): String = self.raw
1317+
def Comment_expanded(self: Comment): Option[String] = self.expanded
1318+
def Comment_usecases(self: Comment): List[(String, Option[DefDef])] = self.usecases.map { uc => (uc.code, uc.tpdCode) }
1319+
13161320
//
13171321
// CONSTANTS
13181322
//

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object ReflectionImpl {
99
apply(rootContext, SourcePosition(rootContext.source, Spans.NoSpan))
1010

1111
def apply(rootContext: Contexts.Context, rootPosition: SourcePosition): scala.tasty.Reflection { val kernel: KernelImpl } = {
12-
class ReflectionImpl(val kernel: KernelImpl) extends scala.tasty.Reflection with CoreImpl with CommentOpsImpl
12+
class ReflectionImpl(val kernel: KernelImpl) extends scala.tasty.Reflection
1313
new ReflectionImpl(new KernelImpl(rootContext, rootPosition))
1414
}
1515

library/src/scala/tasty/reflect/CommentOps.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ package scala.tasty.reflect
22

33
trait CommentOps extends Core {
44

5-
trait CommentAPI {
5+
implicit class CommentAPI(self: Comment) {
66

77
/** Raw comment string */
8-
def raw: String
8+
def raw: String = kernel.Comment_raw(self)
99

1010
/** Expanded comment string, if any */
11-
def expanded: Option[String]
11+
def expanded: Option[String] = kernel.Comment_expanded(self)
1212

1313
/** List of usecases and their corresponding trees, if any */
14-
def usecases: List[(String, Option[DefDef])]
14+
def usecases: List[(String, Option[DefDef])] = kernel.Comment_usecases(self)
1515

1616
}
17-
implicit def CommentDeco(comment: Comment): CommentAPI
1817

1918
}

library/src/scala/tasty/reflect/Kernel.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,10 @@ trait Kernel {
10721072
/** Comment */
10731073
type Comment <: AnyRef
10741074

1075+
def Comment_raw(self: Comment): String
1076+
def Comment_expanded(self: Comment): Option[String]
1077+
def Comment_usecases(self: Comment): List[(String, Option[DefDef])]
1078+
10751079
//
10761080
// CONSTANTS
10771081
//

0 commit comments

Comments
 (0)