-
Notifications
You must be signed in to change notification settings - Fork 1.1k
introduce scala.annotation.documented
#23770
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
base: main
Are you sure you want to change the base?
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package scala.annotation | ||
|
||
// TODO: Write the actual scaladoc of this annotation | ||
|
||
// The annotation from Java is a simple hack as both have the same semantic | ||
// meaning, only this one should be used by Scala code and the second | ||
// annotation by Java Code | ||
// @documented (TODO: can we make it work without breaking the cycle detection algorithm?) | ||
@java.lang.annotation.Documented | ||
final class documented extends StaticAnnotation |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,29 +41,15 @@ trait BasicSupport: | |
def documentation = parseComment(sym.docstring.getOrElse(""), sym.tree) | ||
|
||
def getAnnotations(): List[Annotation] = | ||
// Custom annotations should be documented only if annotated by @java.lang.annotation.Documented | ||
// We allow also some special cases | ||
val fqNameAllowlist0 = Set( | ||
"scala.specialized", | ||
"scala.throws", | ||
"scala.transient", | ||
"scala.volatile", | ||
"scala.annotation.experimental", | ||
"scala.annotation.constructorOnly", | ||
"scala.annotation.static", | ||
"scala.annotation.targetName", | ||
"scala.annotation.threadUnsafe", | ||
"scala.annotation.varargs", | ||
Comment on lines
-47
to
-56
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. This list was useless as all the symbols in the annotations are symbols to the constructors. |
||
) | ||
val fqNameAllowlist = | ||
if ccEnabled then | ||
fqNameAllowlist0 + CaptureDefs.useAnnotFullName | ||
else fqNameAllowlist0 | ||
val documentedSymbol = summon[Quotes].reflect.Symbol.requiredClass("java.lang.annotation.Documented") | ||
val annotations = sym.annotations.filter { a => | ||
a.tpe.typeSymbol.hasAnnotation(documentedSymbol) || fqNameAllowlist.contains(a.symbol.fullName) | ||
} | ||
annotations.map(parseAnnotation).reverse | ||
sym.annotations | ||
.filter(a => a.tpe.typeSymbol.isDocumented) | ||
.map(parseAnnotation) | ||
.reverse | ||
|
||
def isDocumented: Boolean = | ||
val javaDocumentedSymbol = reflect.Symbol.requiredClass("java.lang.annotation.Documented") | ||
val scalaDocumentedSymbol = reflect.Symbol.requiredClass("scala.annotation.documented") | ||
sym.hasAnnotation(scalaDocumentedSymbol) || sym.hasAnnotation(javaDocumentedSymbol) | ||
|
||
def isDeprecated(): Option[Annotation] = | ||
sym.annotations.find { a => | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change compared to the previous behavior, this means all the
@use
annotations of CC will be in the doc even when we suppress cc in scaladoc.