summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVlad Ureche <vlad.ureche@gmail.com>2012-05-03 02:54:27 +0200
committerPaul Phillips <paulp@improving.org>2012-05-02 18:06:41 -0700
commitb6e989fbf63c9f47acfb54175241b42fdfbfe51b (patch)
treef1af4d441be6c1e903b09eca307b6609bf572ff2 /src
parent00b22ed4a307b3c49a09a03508a28a933aeb1a9f (diff)
downloadscala-b6e989fbf63c9f47acfb54175241b42fdfbfe51b.tar.gz
scala-b6e989fbf63c9f47acfb54175241b42fdfbfe51b.tar.bz2
scala-b6e989fbf63c9f47acfb54175241b42fdfbfe51b.zip
Fixes the backticks in use case signature crash
Suggested by Simon in https://groups.google.com/forum/?hl=en&fromgroups#!topic/scala-internals/z7s1CCRCz74 Now it eliminates backticks and gracefully bails out with an error message when it can't remove the wiki syntax.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/DocComments.scala25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala
index b3ed446563..028c5741c9 100755
--- a/src/compiler/scala/tools/nsc/ast/DocComments.scala
+++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala
@@ -383,7 +383,7 @@ trait DocComments { self: Global =>
}
// !!! todo: inherit from Comment?
- case class DocComment(raw: String, pos: Position = NoPosition) {
+ case class DocComment(raw: String, pos: Position = NoPosition, codePos: Position = NoPosition) {
/** Returns:
* template: the doc comment minus all @define and @usecase sections
@@ -412,7 +412,7 @@ trait DocComments { self: Global =>
val comment = "/** " + raw.substring(commentStart, end) + "*/"
val commentPos = subPos(commentStart, end)
- UseCase(DocComment(comment, commentPos), code, codePos)
+ UseCase(DocComment(comment, commentPos, codePos), code, codePos)
}
private def subPos(start: Int, end: Int) =
@@ -461,7 +461,18 @@ trait DocComments { self: Global =>
findIn(classes ::: List(pkgs.head, definitions.RootClass))
}
- def getType(str: String): Type = {
+ def getType(_str: String, variable: String): Type = {
+ /*
+ * work around the backticks issue suggested by Simon in
+ * https://groups.google.com/forum/?hl=en&fromgroups#!topic/scala-internals/z7s1CCRCz74
+ * ideally, we'd have a removeWikiSyntax method in the CommentFactory to completely eliminate the wiki markup
+ */
+ val str =
+ if (_str.length >= 2 && _str.startsWith("`") && _str.endsWith("`"))
+ _str.substring(1, _str.length - 2)
+ else
+ _str
+
def getParts(start: Int): List[String] = {
val end = skipIdent(str, start)
if (end == start) List()
@@ -471,7 +482,11 @@ trait DocComments { self: Global =>
}
}
val parts = getParts(0)
- assert(parts.nonEmpty, "parts is empty '" + str + "' in site " + site)
+ if (parts.isEmpty) {
+ reporter.error(comment.codePos, "Incorrect variable expansion for " + variable + " in use case. Does the " +
+ "variable expand to wiki syntax when documenting " + site + "?")
+ return ErrorType
+ }
val partnames = (parts.init map newTermName) :+ newTypeName(parts.last)
val (start, rest) = parts match {
case "this" :: _ => (site.thisType, partnames.tail)
@@ -490,7 +505,7 @@ trait DocComments { self: Global =>
for (alias <- aliases) yield
lookupVariable(alias.name.toString.substring(1), site) match {
case Some(repl) =>
- val tpe = getType(repl.trim)
+ val tpe = getType(repl.trim, alias.name.toString)
if (tpe != NoType) tpe
else {
val alias1 = alias.cloneSymbol(definitions.RootClass, alias.rawflags, newTypeName(repl))