summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala24
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala4
-rw-r--r--src/library/scala/util/logging/Logged.scala2
3 files changed, 18 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
index 02fadb94fd..e332b28c67 100644
--- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala
@@ -21,7 +21,7 @@ import util.{NoPosition, Position}
trait CommentFactory { thisFactory: ModelFactory with CommentFactory =>
val global: Global
- import global.reporter
+ import global.{ reporter, definitions }
protected val commentCache = mutable.HashMap.empty[(global.Symbol, TemplateImpl), Comment]
@@ -674,7 +674,7 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory =>
}
def link(): Inline = {
- val SchemeUri = new Regex("""([^:]+:.*)""")
+ val SchemeUri = """([^:]+:.*)""".r
jump("[[")
readUntil { check("]]") || check(" ") }
val target = getRead()
@@ -685,18 +685,20 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory =>
})
else None
jump("]]")
+
(target, title) match {
- case (SchemeUri(uri), Some(title)) =>
- Link(uri, title)
- case (SchemeUri(uri), None) =>
- Link(uri, Text(uri))
- case (qualName, None) =>
- entityLink(qualName)
- case (qualName, Some(text)) =>
- reportError(pos, "entity link to " + qualName + " cannot have a custom title'" + text + "'")
+ case (SchemeUri(uri), optTitle) =>
+ Link(uri, optTitle getOrElse Text(uri))
+ case (qualName, optTitle) =>
+ optTitle foreach (text => reportError(pos, "entity link to " + qualName + " cannot have a custom title'" + text + "'"))
+ // XXX rather than warning here we should allow unqualified names
+ // to refer to members of the same package. The "package exists"
+ // exclusion is because [[scala]] is used in some scaladoc.
+ if (!qualName.contains(".") && !definitions.packageExists(qualName))
+ reportError(pos, "entity link to " + qualName + " should be a fully qualified name")
+
entityLink(qualName)
}
-
}
/* UTILITY */
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 8166b36c31..8977989e21 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -614,6 +614,10 @@ trait Definitions extends reflect.generic.StandardDefinitions {
case result => result
}
}
+ def packageExists(packageName: String): Boolean = {
+ try getModuleOrClass(newTermName(packageName)).isPackage
+ catch { case _: MissingRequirementError => false }
+ }
/** If you're looking for a class, pass a type name.
* If a module, a term name.
diff --git a/src/library/scala/util/logging/Logged.scala b/src/library/scala/util/logging/Logged.scala
index e07c14da6b..01757e1bfa 100644
--- a/src/library/scala/util/logging/Logged.scala
+++ b/src/library/scala/util/logging/Logged.scala
@@ -18,7 +18,7 @@ package scala.util.logging
// The user of the library instantiates:
val x = new MyClass() with ConsoleLogger
}}}
- * and the logging is sent to the [[ConsoleLogger]] object.
+ * and the logging is sent to the [[scala.util.logging.ConsoleLogger]] object.
*/
trait Logged {
/** This method should log the message given as argument somewhere