-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove Documentation type from Reflect #10608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2316,14 +2316,14 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler | |||||
def pos: Option[Position] = | ||||||
if self.exists then Some(self.sourcePos) else None | ||||||
|
||||||
def documentation: Option[Documentation] = | ||||||
def docstring: Option[String] = | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
import dotc.core.Comments.CommentsContext | ||||||
val docCtx = ctx.docCtx.getOrElse { | ||||||
throw new RuntimeException( | ||||||
"DocCtx could not be found and documentations are unavailable. This is a compiler-internal error." | ||||||
) | ||||||
} | ||||||
docCtx.docstring(self) | ||||||
docCtx.docstring(self).map(_.raw) | ||||||
|
||||||
def tree: Tree = FromSymbol.definitionFromSym(self) | ||||||
|
||||||
|
@@ -2652,19 +2652,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler | |||||
|
||||||
end report | ||||||
|
||||||
type Documentation = dotc.core.Comments.Comment | ||||||
|
||||||
object Documentation extends DocumentationModule | ||||||
|
||||||
given DocumentationMethods: DocumentationMethods with | ||||||
extension (self: Documentation): | ||||||
def raw: String = self.raw | ||||||
def expanded: Option[String] = self.expanded | ||||||
def usecases: List[(String, Option[DefDef])] = | ||||||
self.usecases.map { uc => (uc.code, uc.tpdCode) } | ||||||
end extension | ||||||
end DocumentationMethods | ||||||
|
||||||
private def optional[T <: dotc.ast.Trees.Tree[?]](tree: T): Option[tree.type] = | ||||||
if tree.isEmpty then None else Some(tree) | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -174,8 +174,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |||||
* | ||||||
* +- SourceFile | ||||||
* | ||||||
* +- Documentation | ||||||
* | ||||||
* +- Constant | ||||||
* | ||||||
* +- Symbol | ||||||
|
@@ -3089,7 +3087,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |||||
def pos: Option[Position] | ||||||
|
||||||
/** The documentation for this symbol, if any */ | ||||||
def documentation: Option[Documentation] | ||||||
def docstring: Option[String] | ||||||
nicolasstucki marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
/** Tree of this definition | ||||||
* | ||||||
|
@@ -3752,36 +3750,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => | |||||
} | ||||||
|
||||||
|
||||||
/////////////////// | ||||||
// DOCUMENTATION // | ||||||
/////////////////// | ||||||
|
||||||
/** Attachment representing the documentation of a definition */ | ||||||
type Documentation <: AnyRef | ||||||
|
||||||
/** Module object of `type Documentation` */ | ||||||
val Documentation: DocumentationModule | ||||||
|
||||||
/** Methods of the module object `val Documentation` */ | ||||||
trait DocumentationModule { this: Documentation.type => } | ||||||
|
||||||
/** Makes extension methods on `Documentation` available without any imports */ | ||||||
given DocumentationMethods: DocumentationMethods | ||||||
|
||||||
/** Extension methods of `Documentation` */ | ||||||
trait DocumentationMethods { | ||||||
extension (self: Documentation): | ||||||
/** Raw documentation string */ | ||||||
def raw: String | ||||||
|
||||||
/** Expanded documentation string, if any */ | ||||||
def expanded: Option[String] | ||||||
|
||||||
/** List of usecases and their corresponding trees, if any */ | ||||||
def usecases: List[(String, Option[DefDef])] | ||||||
|
||||||
end extension | ||||||
} | ||||||
|
||||||
/////////////// | ||||||
// UTILS // | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -34,9 +34,9 @@ trait BasicSupport: | |||||
|
||||||
|
||||||
extension (sym: Symbol): | ||||||
def documentation = sym.documentation match | ||||||
case Some(comment) => | ||||||
Map(ctx.sourceSet -> parseComment(comment, sym.tree)) | ||||||
def documentation = sym.docstring match | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
case Some(docstring) => | ||||||
Map(ctx.sourceSet -> parseComment(docstring, sym.tree)) | ||||||
case None => | ||||||
Map.empty | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,8 +21,8 @@ class DocumentationInspector extends TastyInspector { | |||||
|
||||||
override def traverseTree(tree: Tree)(owner: Symbol): Unit = tree match { | ||||||
case tree: Definition => | ||||||
tree.symbol.documentation match { | ||||||
case Some(doc) => println(doc.raw) | ||||||
tree.symbol.docstring match { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
case Some(doc) => println(doc) | ||||||
case None => println() | ||||||
} | ||||||
super.traverseTree(tree)(owner) | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.