summaryrefslogtreecommitdiff
path: root/src/scaladoc/scala/tools/nsc/doc/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/scaladoc/scala/tools/nsc/doc/model')
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/Entity.scala18
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/MemberLookup.scala2
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala45
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala30
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala4
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala4
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala6
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala2
8 files changed, 68 insertions, 43 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala b/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala
index d55c51b19c..e71383f7e7 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/Entity.scala
@@ -62,9 +62,15 @@ object Entity {
case x: MemberEntity => x.deprecation.isDefined
case _ => false
}
+
+ private def isObject(x: Entity) = x match {
+ case x: TemplateEntity => x.isObject
+ case _ => false
+ }
+
/** Ordering deprecated things last. */
implicit lazy val EntityOrdering: Ordering[Entity] =
- Ordering[(Boolean, String)] on (x => (isDeprecated(x), x.name))
+ Ordering[(Boolean, String, Boolean)] on (x => (isDeprecated(x), x.qualifiedName, isObject(x)))
}
/** A template, which is either a class, trait, object or package. Depending on whether documentation is available
@@ -250,11 +256,11 @@ trait DocTemplateEntity extends MemberTemplateEntity {
* only if the `docsourceurl` setting has been set. */
def sourceUrl: Option[java.net.URL]
- /** All class, trait and object templates which are part of this template's linearization, in lineratization order.
+ /** All class, trait and object templates which are part of this template's linearization, in linearization order.
* This template's linearization contains all of its direct and indirect super-classes and super-traits. */
def linearizationTemplates: List[TemplateEntity]
- /** All instantiated types which are part of this template's linearization, in lineratization order.
+ /** All instantiated types which are part of this template's linearization, in linearization order.
* This template's linearization contains all of its direct and indirect super-types. */
def linearizationTypes: List[TypeEntity]
@@ -449,7 +455,7 @@ trait ValueParam extends ParameterEntity {
/** The type of this value parameter. */
def resultType: TypeEntity
- /** The devault value of this value parameter, if it has been defined. */
+ /** The default value of this value parameter, if it has been defined. */
def defaultValue: Option[TreeEntity]
/** Whether this value parameter is implicit. */
@@ -505,9 +511,9 @@ trait ImplicitConversion {
/** Shadowing captures the information that the member is shadowed by some other members
* There are two cases of implicitly added member shadowing:
- * 1) shadowing from a original class member (the class already has that member)
+ * 1) shadowing from an original class member (the class already has that member)
* in this case, it won't be possible to call the member directly, the type checker will fail attempting to adapt
- * the call arguments (or if they fit it will call the original class' method)
+ * the call arguments (or if they fit it will call the original class method)
* 2) shadowing from other possible implicit conversions ()
* this will result in an ambiguous implicit converion error
*/
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/MemberLookup.scala b/src/scaladoc/scala/tools/nsc/doc/model/MemberLookup.scala
index a649c175d0..ebf3be4ce2 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/MemberLookup.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/MemberLookup.scala
@@ -40,7 +40,7 @@ trait MemberLookup extends base.MemberLookupBase {
override def findExternalLink(sym: Symbol, name: String): Option[LinkToExternal] = {
val sym1 =
if (sym == AnyClass || sym == AnyRefClass || sym == AnyValClass || sym == NothingClass) ListClass
- else if (sym.isPackage)
+ else if (sym.hasPackageFlag)
/* Get package object which has associatedFile ne null */
sym.info.member(newTermName("package"))
else sym
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
index 8ae31ce1c3..6e62ce0317 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -9,11 +9,9 @@ import base.comment._
import diagram._
import scala.collection._
-import scala.tools.nsc.doc.html.HtmlPage
import scala.tools.nsc.doc.html.page.diagram.{DotRunner}
import scala.util.matching.Regex
import scala.reflect.macros.internal.macroImpl
-import scala.xml.NodeSeq
import symtab.Flags
import io._
@@ -30,8 +28,8 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
with MemberLookup =>
import global._
- import definitions.{ ObjectClass, NothingClass, AnyClass, AnyValClass, AnyRefClass, ListClass }
- import rootMirror.{ RootPackage, RootClass, EmptyPackage }
+ import definitions.{ ObjectClass, NothingClass, AnyClass, AnyValClass, AnyRefClass }
+ import rootMirror.{ RootPackage, EmptyPackage }
// Defaults for member grouping, that may be overridden by the template
val defaultGroup = "Ungrouped"
@@ -53,7 +51,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
lazy val dotRunner = new DotRunner(settings)
}
_modelFinished = true
- // complete the links between model entities, everthing that couldn't have been done before
+ // complete the links between model entities, everything that couldn't have been done before
universe.rootPackage.completeModel()
Some(universe) filter (_.rootPackage != null)
@@ -93,10 +91,10 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
trait TemplateImpl extends EntityImpl with TemplateEntity {
override def qualifiedName: String =
if (inTemplate == null || inTemplate.isRootPackage) name else optimize(inTemplate.qualifiedName + "." + name)
- def isPackage = sym.isPackage
+ def isPackage = sym.hasPackageFlag
def isTrait = sym.isTrait
def isClass = sym.isClass && !sym.isTrait
- def isObject = sym.isModule && !sym.isPackage
+ def isObject = sym.isModule && !sym.hasPackageFlag
def isCaseClass = sym.isCaseClass
def isRootPackage = false
def selfType = if (sym.thisSym eq sym) None else Some(makeType(sym.thisSym.typeOfThis, this))
@@ -108,10 +106,12 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
// in the doc comment of MyClass
def linkTarget: DocTemplateImpl = inTpl
- lazy val comment = {
- val documented = if (sym.hasAccessorFlag) sym.accessed else sym
- thisFactory.comment(documented, linkTarget, inTpl)
- }
+ // if there is a field symbol, the ValDef will use it, which means docs attached to it will be under the field symbol, not the getter's
+ protected[this] def commentCarryingSymbol(sym: Symbol) =
+ if (sym.hasAccessorFlag && sym.accessed.exists) sym.accessed else sym
+
+ lazy val comment = thisFactory.comment(commentCarryingSymbol(sym), linkTarget, inTpl)
+
def group = comment flatMap (_.group) getOrElse defaultGroup
override def inTemplate = inTpl
override def toRoot: List[MemberImpl] = this :: inTpl.toRoot
@@ -254,7 +254,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
def valueParams: List[List[ValueParam]] = Nil /** TODO, these are now only computed for DocTemplates */
def parentTypes =
- if (sym.isPackage || sym == AnyClass) List() else {
+ if (sym.hasPackageFlag || sym == AnyClass) List() else {
val tps = (this match {
case a: AliasType => sym.tpe.dealias.parents
case a: AbstractType => sym.info.bounds match {
@@ -478,17 +478,18 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
override lazy val comment = {
def nonRootTemplate(sym: Symbol): Option[DocTemplateImpl] =
if (sym eq RootPackage) None else findTemplateMaybe(sym)
+
/* Variable precedence order for implicitly added members: Take the variable definitions from ...
* 1. the target of the implicit conversion
* 2. the definition template (owner)
* 3. the current template
*/
- val inRealTpl = conversion.flatMap { conv =>
- nonRootTemplate(conv.toType.typeSymbol)
- } orElse nonRootTemplate(sym.owner) orElse Option(inTpl)
- inRealTpl flatMap { tpl =>
- thisFactory.comment(sym, tpl, tpl)
- }
+ val inRealTpl = (
+ conversion.flatMap(conv => nonRootTemplate(conv.toType.typeSymbol))
+ orElse nonRootTemplate(sym.owner)
+ orElse Option(inTpl))
+
+ inRealTpl flatMap (tpl => thisFactory.comment(commentCarryingSymbol(sym), tpl, tpl))
}
override def inDefinitionTemplates = useCaseOf.fold(super.inDefinitionTemplates)(_.inDefinitionTemplates)
@@ -665,7 +666,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
s != EmptyPackage && s != RootPackage
}
})
- else if (bSym.isPackage) // (2)
+ else if (bSym.hasPackageFlag) // (2)
if (settings.skipPackage(makeQualifiedName(bSym)))
None
else
@@ -778,7 +779,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
Some(new MemberTemplateImpl(bSym, inTpl) with AliasImpl with AliasType {
override def isAliasType = true
})
- else if (!modelFinished && (bSym.isPackage || templateShouldDocument(bSym, inTpl)))
+ else if (!modelFinished && (bSym.hasPackageFlag || templateShouldDocument(bSym, inTpl)))
modelCreation.createTemplate(bSym, inTpl)
else
None
@@ -885,8 +886,8 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
// units.filter should return only one element
(currentRun.units filter (_.source.file == aSym.sourceFile)).toList match {
case List(unit) =>
- // SI-4922 `sym == aSym` is insufficent if `aSym` is a clone of symbol
- // of the parameter in the tree, as can happen with type parametric methods.
+ // SI-4922 `sym == aSym` is insufficient if `aSym` is a clone of symbol
+ // of the parameter in the tree, as can happen with type parameterized methods.
def isCorrespondingParam(sym: Symbol) = (
sym != null &&
sym != NoSymbol &&
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
index db39d059d7..cedbdd1547 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
@@ -11,7 +11,6 @@ package doc
package model
import scala.collection._
-import symtab.Flags
/**
* This trait finds implicit conversions for a class in the default scope and creates scaladoc entries for each of them.
@@ -99,10 +98,15 @@ trait ModelFactoryImplicitSupport {
// also keep empty conversions, so they appear in diagrams
// conversions = conversions.filter(!_.members.isEmpty)
- // Filter out specialized conversions from array
- if (sym == ArrayClass)
- conversions = conversions.filterNot((conv: ImplicitConversionImpl) =>
- hardcoded.arraySkipConversions.contains(conv.conversionQualifiedName))
+ val hiddenConversions: Seq[String] = thisFactory
+ .comment(sym, inTpl.linkTarget, inTpl)
+ .map(_.hideImplicitConversions)
+ .getOrElse(Nil)
+
+ conversions = conversions filterNot { conv: ImplicitConversionImpl =>
+ hiddenConversions.contains(conv.conversionShortName) ||
+ hiddenConversions.contains(conv.conversionQualifiedName)
+ }
// Filter out non-sensical conversions from value types
if (isPrimitiveValueType(sym.tpe_*))
@@ -167,6 +171,20 @@ trait ModelFactoryImplicitSupport {
return Nil
}
+ if (!settings.docImplicitsShowAll && viewSimplifiedType.resultType.typeSymbol == sym) {
+ // If, when looking at views for a class A, we find one that returns A as well
+ // (possibly with different type parameters), we ignore it.
+ // It usually is a way to build a "whatever" into an A, but we already have an A, as in:
+ // {{{
+ // object Box {
+ // implicit def anyToBox[T](t: T): Box[T] = new Box(t)
+ // }
+ // class Box[T](val t: T)
+ // }}}
+ // We don't want the implicit conversion from Box[T] to Box[Box[T]] to appear.
+ return Nil
+ }
+
// type the view application so we get the exact type of the result (not the formal type)
val viewTree = result.tree.setType(viewSimplifiedType)
val appliedTree = new ApplyImplicitView(viewTree, List(Ident("<argument>") setType viewTree.tpe.paramTypes.head))
@@ -232,7 +250,7 @@ trait ModelFactoryImplicitSupport {
try {
// TODO: Not sure if `owner = sym.owner` is the right thing to do -- seems similar to what scalac should be doing
val silentContext = context.make(owner = sym.owner).makeSilent(reportAmbiguousErrors = false)
- val search = inferImplicit(EmptyTree, tpe, false, false, silentContext, false)
+ val search = inferImplicitByTypeSilent(tpe, silentContext)
available = Some(search.tree != EmptyTree)
} catch {
case _: TypeError =>
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala
index 8834bc3efd..9b04125cc5 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala
@@ -20,7 +20,7 @@ trait ModelFactoryTypeSupport {
with MemberLookup =>
import global._
- import definitions.{ ObjectClass, NothingClass, AnyClass, AnyValClass, AnyRefClass }
+ import definitions.{ ObjectClass, AnyClass, AnyRefClass }
protected val typeCache = new mutable.LinkedHashMap[Type, TypeEntity]
@@ -94,7 +94,7 @@ trait ModelFactoryTypeSupport {
LinkToMember(bMbr, oTpl)
case _ =>
val name = makeQualifiedName(bSym)
- if (!bSym.owner.isPackage)
+ if (!bSym.owner.hasPackageFlag)
Tooltip(name)
else
findExternalLink(bSym, name).getOrElse (
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala
index 86a7a67160..27668a6040 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala
@@ -3,7 +3,7 @@ package doc
package model
import scala.collection._
-import scala.reflect.internal.util.{RangePosition, OffsetPosition, SourceFile}
+import scala.reflect.internal.util.{RangePosition, SourceFile}
/** The goal of this trait is , using makeTree,
* to browse a tree to
@@ -49,7 +49,7 @@ trait TreeFactory { thisTreeFactory: ModelFactory with TreeFactory =>
case _ =>
}
else if (asym.isTerm && asym.owner.isClass){
- if (asym.isSetter) asym = asym.getter(asym.owner)
+ if (asym.isSetter) asym = asym.getterIn(asym.owner)
makeTemplate(asym.owner) match {
case docTmpl: DocTemplateImpl =>
val mbrs: Option[MemberImpl] = findMember(asym, docTmpl)
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala
index 44d8886e4e..464cacc99a 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala
@@ -3,7 +3,7 @@ package model
package diagram
import model._
-import java.util.regex.{Pattern, Matcher}
+import java.util.regex.Pattern
import scala.util.matching.Regex
/**
@@ -163,7 +163,7 @@ trait DiagramDirectiveParser {
case Nil =>
defaultFilter
- // compute the exact filters. By including the annotation, the diagram is autmatically added
+ // compute the exact filters. By including the annotation, the diagram is automatically added
case _ =>
tFilter -= System.currentTimeMillis
var hideDiagram0: Boolean = false
@@ -177,7 +177,7 @@ trait DiagramDirectiveParser {
def warning(message: String) = {
// we need the position from the package object (well, ideally its comment, but yeah ...)
- val sym = if (template.sym.isPackage) template.sym.info.member(global.nme.PACKAGE) else template.sym
+ val sym = if (template.sym.hasPackageFlag) template.sym.packageObject else template.sym
assert((sym != global.NoSymbol) || (sym == global.rootMirror.RootPackage))
global.reporter.warning(sym.pos, message)
}
diff --git a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
index 86900f26c9..bbcb18353a 100644
--- a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
@@ -63,7 +63,7 @@ trait DiagramFactory extends DiagramDirectiveParser {
case d: TemplateImpl if !classExcluded(d) => NormalNode(makeType(d.sym.tpe, tpl), Some(d))()
}.sortBy(_.tpl.get.name)(implicitly[Ordering[String]].reverse)
- // outgoing implicit coversions
+ // outgoing implicit conversions
lazy val outgoingImplicitNodes = tpl.outgoingImplicitlyConvertedClasses.map {
case (outgoingTpl, outgoingType, conv) =>
ImplicitNode(outgoingType, Some(outgoingTpl))(implicitTooltip(from=tpl, to=tpl, conv=conv))