Skip to content

Commit f2bff03

Browse files
committed
Rename Reflection.{Comment => Documentation}
The name of the concept does not suggest that these are the documentation string. It also suggests that the comments can be accessed which is not the case.
1 parent 9b9c9f8 commit f2bff03

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,11 +2241,11 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext:
22412241

22422242
def localContext: Context =
22432243
if self.exists then ctx.withOwner(self) else ctx
2244-
def comment: Option[Comment] =
2244+
def documentation: Option[Documentation] =
22452245
import dotc.core.Comments.CommentsContext
22462246
val docCtx = ctx.docCtx.getOrElse {
22472247
throw new RuntimeException(
2248-
"DocCtx could not be found and comments are unavailable. This is a compiler-internal error."
2248+
"DocCtx could not be found and documentations are unavailable. This is a compiler-internal error."
22492249
)
22502250
}
22512251
docCtx.docstring(self)
@@ -2528,18 +2528,18 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext:
25282528
def warning(msg: => String, sourceFile: SourceFile, start: Int, end: Int): Unit =
25292529
dotc.report.error(msg, dotc.util.SourcePosition(sourceFile, dotc.util.Spans.Span(start, end)))
25302530

2531-
type Comment = dotc.core.Comments.Comment
2531+
type Documentation = dotc.core.Comments.Comment
25322532

2533-
object Comment extends CommentModule
2533+
object Documentation extends DocumentationModule
25342534

2535-
object CommentMethodsImpl extends CommentMethods:
2536-
extension (self: Comment):
2535+
object DocumentationMethodsImpl extends DocumentationMethods:
2536+
extension (self: Documentation):
25372537
def raw: String = self.raw
25382538
def expanded: Option[String] = self.expanded
25392539
def usecases: List[(String, Option[DefDef])] =
25402540
self.usecases.map { uc => (uc.code, uc.tpdCode) }
25412541
end extension
2542-
end CommentMethodsImpl
2542+
end DocumentationMethodsImpl
25432543

25442544
private def optional[T <: dotc.ast.Trees.Tree[?]](tree: T): Option[tree.type] =
25452545
if tree.isEmpty then None else Some(tree)

library/src/scala/tasty/Reflection.scala

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ import scala.tasty.reflect._
107107
*
108108
* +- Position
109109
*
110-
* +- Comment
110+
* +- Documentation
111111
*
112112
* +- Constant
113113
*
@@ -2575,8 +2575,8 @@ trait Reflection { reflection =>
25752575

25762576
def localContext: Context
25772577

2578-
/** The comment for this symbol, if any */
2579-
def comment: Option[Comment]
2578+
/** The documentation for this symbol, if any */
2579+
def documentation: Option[Documentation]
25802580

25812581
/** Tree of this definition
25822582
*
@@ -3162,28 +3162,26 @@ trait Reflection { reflection =>
31623162
/** Emits a warning at a specific range of a file */
31633163
def warning(msg: => String, source: SourceFile, start: Int, end: Int): Unit
31643164

3165-
//////////////
3166-
// COMMENTS //
3167-
//////////////
3168-
3169-
// TODO: misnomer. Rename to `Documentation`
3165+
///////////////////
3166+
// DOCUMENTATION //
3167+
///////////////////
31703168

31713169
/** Attachment representing the documentation of a definition */
3172-
type Comment <: AnyRef
3170+
type Documentation <: AnyRef
31733171

3174-
val Comment: CommentModule
3172+
val Documentation: DocumentationModule
31753173

3176-
trait CommentModule { this: Comment.type => }
3174+
trait DocumentationModule { this: Documentation.type => }
31773175

3178-
given CommentMethods as CommentMethods = CommentMethodsImpl
3179-
protected val CommentMethodsImpl: CommentMethods
3176+
given DocumentationMethods as DocumentationMethods = DocumentationMethodsImpl
3177+
protected val DocumentationMethodsImpl: DocumentationMethods
31803178

3181-
trait CommentMethods {
3182-
extension (self: Comment):
3183-
/** Raw comment string */
3179+
trait DocumentationMethods {
3180+
extension (self: Documentation):
3181+
/** Raw documentation string */
31843182
def raw: String
31853183

3186-
/** Expanded comment string, if any */
3184+
/** Expanded documentation string, if any */
31873185
def expanded: Option[String]
31883186

31893187
/** List of usecases and their corresponding trees, if any */

0 commit comments

Comments
 (0)