Skip to content

Commit

Permalink
Merge pull request #14546 from jchyb/scaladoc/searchbar-inherited-hidden
Browse files Browse the repository at this point in the history
Scaladoc: fix #14481: certain functions not being shown in searchbar
  • Loading branch information
TheElectronWill authored Mar 17, 2022
2 parents 1a5b165 + 598b8d3 commit f4a8983
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 5 deletions.
9 changes: 9 additions & 0 deletions scaladoc-testcases/src/tests/inheritedMembersFromHidden.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package tests
package inheritedMembersFromHidden

private[inheritedMembersFromHidden] trait HiddenTrait { //unexpected
def method: Unit
= ???
}

object PublicObject extends HiddenTrait //expected: object PublicObject
2 changes: 1 addition & 1 deletion scaladoc/src/dotty/tools/scaladoc/api.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ enum Origin:

case class Overridden(name: String, dri: DRI)

case class InheritedFrom(name: String, dri: DRI)
case class InheritedFrom(name: String, dri: DRI, isSourceSuperclassHidden: Boolean)

case class Annotation(val dri: DRI, val params: List[Annotation.AnnotationParameter])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
case _ => Nil

def inheritedFrom(m: Member) = m.inheritedFrom match
case Some(InheritedFrom(name, dri)) => tableRow("Inherited from:", signatureRenderer.renderLink(name, dri))
case Some(InheritedFrom(name, dri, isSourceSuperclassHidden)) =>
val hiddenNameSuffix = if isSourceSuperclassHidden then " (hidden)" else ""
tableRow("Inherited from:", signatureRenderer.renderLink(name + hiddenNameSuffix, dri))
case _ => Nil

def docAttributes(m: Member): Seq[AppliedTag] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
val entry = mkEntry(member.dri, member.name, flattenToText(sig), descr, member.kind.name)
val children = member
.membersBy(m => m.kind != Kind.Package && !m.kind.isInstanceOf[Classlike])
.filter(m => m.origin == Origin.RegularlyDefined && m.inheritedFrom.isEmpty)
.filter(m => m.origin == Origin.RegularlyDefined && m.inheritedFrom.fold(false)(_.isSourceSuperclassHidden))
Seq(entry) ++ children.flatMap(processMember)

processMember(m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ trait ClassLikeSupport:
}

private def parseInheritedMember(c: ClassDef)(s: Tree): Option[Member] =
def inheritance = Some(InheritedFrom(s.symbol.owner.normalizedName, s.symbol.dri))
def inheritance = Some(InheritedFrom(s.symbol.owner.normalizedName, s.symbol.dri, s.symbol.owner.isHiddenByVisibility))
processTreeOpt(s)(s match
case c: ClassDef if c.symbol.shouldDocumentClasslike => Some(parseClasslike(c, signatureOnly = true))
case other => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object FilterAttributes:
Map("visibility" -> m.visibility.name)

private def inheritedFrom(m: Member): Map[String, String] = m.inheritedFrom match
case Some(InheritedFrom(name, _)) => Map("inherited" -> name)
case Some(InheritedFrom(name, _, _)) => Map("inherited" -> name)
case _ => Map.empty

private def origin(m: Member): Map[String, String] = m.origin match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class InheritanceLoop extends SignatureTest("inheritanceLoop", SignatureTest.all
class InheritedMembers extends SignatureTest("inheritedMembers2", SignatureTest.all.filter(_ != "class"),
sourceFiles = List("inheritedMembers1", "inheritedMembers2"))

class InheritedFromHiddenClasslike extends SignatureTest("inheritedMembersFromHidden", SignatureTest.all)

class ComplexNames extends SignatureTest("complexNames", Seq("def", "class"))

class WrongDocumentationLinks extends SignatureTest("links", Seq("def"))
Expand Down

0 comments on commit f4a8983

Please sign in to comment.