-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle exports presenting in scala3doc #10504
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
35c1c90
f8e2559
5633399
ff3db41
1efc4af
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,23 @@ | ||
package tests | ||
package exports | ||
|
||
class A: | ||
def aDefInt: Int = 1 | ||
def aDef1: 1 = 1 | ||
val aValInt: Int = 1 | ||
val aVal1: 1 = 1 | ||
var aVarInt: Int = 1 | ||
var aVar1: 1 = 1 | ||
|
||
object X: | ||
def xDefInt: Int = 1 | ||
def xDef1: 1 = 1 | ||
val xValInt: Int = 1 | ||
val xVal1: 1 = 1 | ||
var xVarInt: Int = 1 | ||
var xVar1: 1 = 1 | ||
|
||
class B: | ||
val a = new A | ||
export a._ | ||
export X._ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,21 @@ trait ClassLikeSupport: | |
.map { _ => | ||
parseMethod(dd.symbol, kind = Kind.Given(getGivenInstance(dd).map(_.asSignature), None)) | ||
} | ||
|
||
case dd: DefDef if !dd.symbol.isHiddenByVisibility && dd.symbol.isExported => | ||
val exportedTarget = dd.rhs.collect { | ||
case a: Apply => a.fun.asInstanceOf[Select] | ||
case s: Select => s | ||
} | ||
val functionName = exportedTarget.fold("function")(_.name) | ||
val instanceName = exportedTarget.collect { | ||
case Select(qualifier: Select, _) => qualifier.name | ||
case Select(qualifier: Ident, _) => qualifier.tpe.typeSymbol.normalizedName | ||
}.getOrElse("instance") | ||
val dri = dd.rhs.collect { | ||
case s: Select if s.symbol.isDefDef => s.symbol.dri | ||
}.orElse(exportedTarget.map(_.qualifier.tpe.typeSymbol.dri)) | ||
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. Will 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. Hard to tell. Could not produce anything breaking the generation. EDIT: That was my misinterpretation
object X:
def x: Int = 1
val x2: Int = 1
var x3: Int = 1
class B:
val a = new A
export a._
export X._
|
||
Some(parseMethod(dd.symbol, kind = Kind.Exported).withOrigin(Origin.ExportedFrom(s"$instanceName.$functionName", dri))) | ||
|
||
case dd: DefDef if !dd.symbol.isHiddenByVisibility && !dd.symbol.isGiven && !dd.symbol.isSyntheticFunc && !dd.symbol.isExtensionMethod => | ||
Some(parseMethod(dd.symbol)) | ||
|
@@ -184,7 +199,6 @@ trait ClassLikeSupport: | |
case dd: DefDef if !dd.symbol.isClassConstructor && !(dd.symbol.isSuperBridgeMethod || dd.symbol.isDefaultHelperMethod) => dd | ||
case other => other | ||
} | ||
|
||
c.membersToDocument.flatMap(parseMember) ++ | ||
inherited.flatMap(s => parseInheritedMember(s)) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,9 +215,12 @@ trait TypesSupport: | |
// case _ => | ||
// throw Exception("Match error in TypeRef. This should not happen, please open an issue. " + convertTypeOrBoundsToReference(reflect)(qual)) | ||
// } | ||
case tr @ TermRef(qual, typeName) => qual match { | ||
case _ => link(tr.termSymbol) | ||
} | ||
case tr @ TermRef(qual, typeName) => | ||
tr.termSymbol.tree 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. This one here is a little bit tricky. The reason behind this is to extract |
||
case vd: ValDef => inner(vd.tpt.tpe) | ||
case _ => link(tr.termSymbol) | ||
|
||
|
||
// convertTypeOrBoundsToReference(reflect)(qual) match { | ||
// case TypeReference(label, link, xs, _) => TypeReference(typeName + "$", link + "/" + label, xs) | ||
// case EmptyReference => TypeReference(typeName, "", Nil) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,8 @@ object ScalaSignatureProvider: | |
extensionSignature(extension, builder) | ||
case method: DFunction if method.kind.isInstanceOf[Kind.Given] => | ||
givenMethodSignature(method, builder) | ||
case exprt: DFunction if exprt.kind == Kind.Exported => | ||
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. Do we need that 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. Can delete, but thought it would be more reasonable to state that explicitly |
||
exportedMethodSignature(exprt, builder) | ||
case method: DFunction => | ||
methodSignature(method, builder) | ||
case enumEntry: DClass if enumEntry.kind == Kind.EnumCase => | ||
|
@@ -138,14 +140,14 @@ object ScalaSignatureProvider: | |
} else { | ||
extension.getParameters.asScala(0) | ||
} | ||
val withSinature = builder | ||
val withSignature = builder | ||
.modifiersAndVisibility(extension, "def") | ||
.name(extension.getName, extension.getDri) | ||
.generics(extension) | ||
.functionParameters(extension) | ||
|
||
if extension.isConstructor then withSinature | ||
else withSinature.text(":").text(" ").typeSignature(extension.getType) | ||
if extension.isConstructor then withSignature | ||
else withSignature.text(":").text(" ").typeSignature(extension.getType) | ||
|
||
private def givenMethodSignature(method: DFunction, builder: SignatureBuilder): SignatureBuilder = method.kind match | ||
case Kind.Given(Some(instance), _) => | ||
|
@@ -156,6 +158,8 @@ object ScalaSignatureProvider: | |
case _ => | ||
builder.text("given ").name(method.getName, method.getDri) | ||
|
||
private def exportedMethodSignature(method: DFunction, builder: SignatureBuilder): SignatureBuilder = | ||
methodSignature(method, builder) | ||
|
||
private def methodSignature(method: DFunction, builder: SignatureBuilder): SignatureBuilder = | ||
val bdr = builder | ||
|
Uh oh!
There was an error while loading. Please reload this page.