diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-30 20:40:46 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-30 20:40:46 +0000 |
commit | 386d5068471809d906d3db3aa56ed5f9352250c2 (patch) | |
tree | 2bcbcf5e889a7e12e7422bfe7077eb6603b25e45 /src/library | |
parent | bbd5efa596170e79613c7b2305171a8108e52080 (diff) | |
download | scala-386d5068471809d906d3db3aa56ed5f9352250c2.tar.gz scala-386d5068471809d906d3db3aa56ed5f9352250c2.tar.bz2 scala-386d5068471809d906d3db3aa56ed5f9352250c2.zip |
Issue warning when doccomments have $variables ...
Issue warning when doccomments have $variables which go unfulfilled.
Started with patch by dmharrah. Noticed expandVariables never
incremented its recursion guard and ended up rewriting it. To avoid
spurious warnings you can escape $'s, as in this comment:
/** The decoded name of the symbol, e.g. `==` instead of `\$eq\$eq`.
*/
The above will be ignored during expansion and translated to $eq$eq for
output. Closes #4412, no review.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/immutable/StringLike.scala | 15 | ||||
-rwxr-xr-x | src/library/scala/reflect/NameTransformer.scala | 15 | ||||
-rwxr-xr-x | src/library/scala/reflect/generic/Symbols.scala | 4 |
3 files changed, 23 insertions, 11 deletions
diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index 926fde4fe0..98f1b90866 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -162,6 +162,21 @@ self => if (toString.endsWith(suffix)) toString.substring(0, toString.length() - suffix.length) else toString + /** Replace all literal occurrences of `literal` with the string `replacement`. + * This is equivalent to [[java.lang.String#replaceAll]] except that both arguments + * are appropriately quoted to avoid being interpreted as metacharacters. + * + * @param literal the string which should be replaced everywhere it occurs + * @param replacement the replacement string + * @return the resulting string + */ + def replaceAllLiterally(literal: String, replacement: String): String = { + val arg1 = java.util.regex.Pattern.quote(literal) + val arg2 = java.util.regex.Matcher.quoteReplacement(replacement) + + toString.replaceAll(arg1, arg2) + } + /** * For every line in this string: * diff --git a/src/library/scala/reflect/NameTransformer.scala b/src/library/scala/reflect/NameTransformer.scala index 6cfb40cadf..7bc5a61f6c 100755 --- a/src/library/scala/reflect/NameTransformer.scala +++ b/src/library/scala/reflect/NameTransformer.scala @@ -6,8 +6,6 @@ ** |/ ** \* */ - - package scala.reflect /** @@ -21,7 +19,6 @@ object NameTransformer { private val op2code = new Array[String](nops) private val code2op = new Array[OpCodes](ncodes) - private def enterOp(op: Char, code: String) = { op2code(op) = code val c = (code.charAt(1) - 'a') * 26 + code.charAt(2) - 'a' @@ -48,10 +45,10 @@ object NameTransformer { enterOp('?', "$qmark") enterOp('@', "$at") - /** Replace operator symbols by corresponding "<code>$op_name</code>". + /** Replace operator symbols by corresponding `\$opname`. * - * @param name ... - * @return ... + * @param name the string to encode + * @return the string with all recognized opchars replaced with their encoding */ def encode(name: String): String = { var buf: StringBuilder = null @@ -82,10 +79,10 @@ object NameTransformer { if (buf eq null) name else buf.toString() } - /** Replace <code>$op_name</code> by corresponding operator symbol. + /** Replace `\$opname` by corresponding operator symbol. * - * @param name0 ... - * @return ... + * @param name0 the string to decode + * @return the string with all recognized operator symbol encodings replaced with their name */ def decode(name0: String): String = { //System.out.println("decode: " + name);//DEBUG diff --git a/src/library/scala/reflect/generic/Symbols.scala b/src/library/scala/reflect/generic/Symbols.scala index 770c6e920c..49cf7df1ef 100755 --- a/src/library/scala/reflect/generic/Symbols.scala +++ b/src/library/scala/reflect/generic/Symbols.scala @@ -25,11 +25,11 @@ trait Symbols { self: Universe => */ def name: Name - /** The name of the symbol before decoding, e.g. `$eq$eq` instead of `==`. + /** The name of the symbol before decoding, e.g. `\$eq\$eq` instead of `==`. */ def encodedName: String - /** The decoded name of the symbol, e.g. `==` instead of `$eq$eq`. + /** The decoded name of the symbol, e.g. `==` instead of `\$eq\$eq`. */ def decodedName: String = stripLocalSuffix(NameTransformer.decode(encodedName)) |