groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 02/05: minor refactor: remove javadoc warnings and tidy up (cont'd)
Date Sat, 27 Apr 2019 07:16:11 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit c76236f8d75ff9f757f28d8250da8c1393e949c8
Author: Paul King <paulk@asert.com.au>
AuthorDate: Sat Apr 27 13:02:34 2019 +1000

    minor refactor: remove javadoc warnings and tidy up (cont'd)
---
 src/main/groovy/groovy/lang/Category.java          |   2 +-
 src/main/groovy/groovy/lang/Closure.java           |  46 +++---
 src/main/groovy/groovy/lang/ExpandoMetaClass.java  |  42 +++---
 src/main/groovy/groovy/lang/GrabConfig.java        |   8 +-
 src/main/groovy/groovy/lang/Range.java             |   2 +-
 .../transform/builder/InitializerStrategy.java     |   2 +
 .../groovy/ast/expr/ClosureExpression.java         |   4 +-
 .../codehaus/groovy/ast/expr/LambdaExpression.java |  11 +-
 .../groovy/ast/expr/MethodPointerExpression.java   |   4 +-
 .../classgen/asm/MethodCallerMultiAdapter.java     | 164 ++++++++++-----------
 .../codehaus/groovy/control/GenericsVisitor.java   |   2 +-
 .../builder/InlinedASTCustomizerFactory.java       |   2 +-
 .../builder/SourceAwareCustomizerFactory.java      |   4 +-
 .../codehaus/groovy/runtime/ComposedClosure.java   |  24 +--
 .../codehaus/groovy/runtime/CurriedClosure.java    |   2 +-
 .../groovy/runtime/memoize/StampedCommonCache.java |   2 +-
 .../runtime/metaclass/MetaClassRegistryImpl.java   |   2 +-
 .../groovy/util/JavadocAssertionTestBuilder.groovy |   4 +-
 .../main/groovy/groovy/util/StringTestUtil.groovy  |  64 ++++----
 19 files changed, 202 insertions(+), 189 deletions(-)

diff --git a/src/main/groovy/groovy/lang/Category.java b/src/main/groovy/groovy/lang/Category.java
index f092068..bd6bf1d 100644
--- a/src/main/groovy/groovy/lang/Category.java
+++ b/src/main/groovy/groovy/lang/Category.java
@@ -91,7 +91,7 @@ import java.lang.annotation.Target;
  *
  * def words = ["The", "quick", "brown", "fox"]
  * println new Sentence(words).shuffle()
- * // => [quick, fox, The, brown]       (order will vary)
+ * // {@code =>} [quick, fox, The, brown]       (order will vary)
  * </pre>
  */
 @java.lang.annotation.Documented
diff --git a/src/main/groovy/groovy/lang/Closure.java b/src/main/groovy/groovy/lang/Closure.java
index 7a0ee4d..d59744d 100644
--- a/src/main/groovy/groovy/lang/Closure.java
+++ b/src/main/groovy/groovy/lang/Closure.java
@@ -491,7 +491,7 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * <p>
      * Typical usage:
      * <pre class="groovyTestCase">
-     * def multiply = { a, b -> a * b }
+     * def multiply = { a, b {@code ->} a * b }
      * def doubler = multiply.curry(2)
      * assert doubler(4) == 8
      * </pre>
@@ -499,7 +499,7 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * If you curry a vararg parameter, you don't consume the entire vararg array
      * but instead the first parameter of the vararg array as the following example shows:
      * <pre class="groovyTestCase">
-     * def a = { one, two, Object[] others -> one + two + others.sum() }
+     * def a = { one, two, Object[] others {@code ->} one + two + others.sum() }
      * assert a.parameterTypes.name == ['java.lang.Object', 'java.lang.Object', '[Ljava.lang.Object;']
      * assert a(1,2,3,4) == 10
      * def b = a.curry(1)
@@ -541,7 +541,7 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * Parameters are supplied on the right rather than left as per the normal curry() method.
      * Typical usage:
      * <pre class="groovyTestCase">
-     * def divide = { a, b -> a / b }
+     * def divide = { a, b {@code ->} a / b }
      * def halver = divide.rcurry(2)
      * assert halver(8) == 4
      * </pre>
@@ -574,20 +574,20 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * Parameters are supplied from index position "n".
      * Typical usage:
      * <pre>
-     * def caseInsensitive = { a, b -> a.toLowerCase() <=> b.toLowerCase() } as
Comparator
-     * def caseSensitive = { a, b -> a <=> b } as Comparator
+     * def caseInsensitive = { a, b {@code ->} a.toLowerCase() {@code <=>} b.toLowerCase()
} as Comparator
+     * def caseSensitive = { a, b {@code ->} a {@code <=>} b } as Comparator
      * def animals1 = ['ant', 'dog', 'BEE']
      * def animals2 = animals1 + ['Cat']
      * // curry middle param of this utility method:
      * // Collections#binarySearch(List list, Object key, Comparator c)
-     * def catSearcher = Collections.&binarySearch.ncurry(1, "cat")
-     * [[animals1, animals2], [caseInsensitive, caseSensitive]].combinations().each{ a, c
->
+     * {@code def catSearcher = Collections.&binarySearch.ncurry(1, "cat")}
+     * [[animals1, animals2], [caseInsensitive, caseSensitive]].combinations().each{ a, c
{@code ->}
      *   def idx = catSearcher(a.sort(c), c)
      *   print a.sort(c).toString().padRight(22)
-     *   if (idx < 0) println "Not found but would belong in position ${-idx - 1}"
+     *   {@code if (idx < 0) println "Not found but would belong in position ${-idx -
1}"}
      *   else println "Found at index $idx"
      * }
-     * // =>
+     * // {@code =>}
      * // [ant, BEE, dog]       Not found but would belong in position 2
      * // [ant, BEE, Cat, dog]  Found at index 2
      * // [BEE, ant, dog]       Not found but would belong in position 2
@@ -623,10 +623,10 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * <p>
      * Typical usage:
      * <pre class="groovyTestCase">
-     * def times2 = { a -> a * 2 }
-     * def add3 = { a -> a + 3 }
-     * def timesThenAdd = times2 >> add3
-     * // equivalent: timesThenAdd = { a -> add3(times2(a)) }
+     * def times2 = { a {@code ->} a * 2 }
+     * def add3 = { a {@code ->} a + 3 }
+     * def timesThenAdd = times2 {@code >>} add3
+     * // equivalent: timesThenAdd = { a {@code ->} add3(times2(a)) }
      * assert timesThenAdd(3) == 9
      * </pre>
      *
@@ -642,10 +642,10 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * <p>
      * Typical usage:
      * <pre class="groovyTestCase">
-     * def times2 = { a -> a * 2 }
-     * def add3 = { a -> a + 3 }
-     * def addThenTimes = times2 << add3
-     * // equivalent: addThenTimes = { a -> times2(add3(a)) }
+     * def times2 = { a {@code ->} a * 2 }
+     * def add3 = { a {@code ->} a + 3 }
+     * def addThenTimes = times2 {@code <<} add3
+     * // equivalent: addThenTimes = { a {@code ->} times2(add3(a)) }
      * assert addThenTimes(3) == 12
      * </pre>
      *
@@ -661,9 +661,9 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * <p>
      * Typical usage:
      * <pre class="groovyTestCase">
-     * def times2 = { a -> a * 2 }
-     * def add3 = { a -> a * 3 }
-     * assert add3 << times2 << 3 == 9
+     * def times2 = { a {@code ->} a * 2 }
+     * def add3 = { a {@code ->} a * 3 }
+     * assert add3 {@code <<} times2 {@code <<} 3 == 9
      * </pre>
      *
      * @param arg the argument to call the closure with
@@ -782,11 +782,11 @@ public abstract class Closure<V> extends GroovyObjectSupport implements
Cloneabl
      * Here is an example:
      * <pre>
      * def fact
-     * fact = { n, total ->
+     * fact = { n, total {@code ->}
      *     n == 0 ? total : fact.trampoline(n - 1, n * total)
      * }.trampoline()
-     * def factorial = { n -> fact(n, 1G)}
-     * println factorial(20) // => 2432902008176640000
+     * def factorial = { n {@code ->} fact(n, 1G)}
+     * println factorial(20) // {@code =>} 2432902008176640000
      * </pre>
      *
      * @param args Parameters to the closure, so as the trampoline mechanism can call it
diff --git a/src/main/groovy/groovy/lang/ExpandoMetaClass.java b/src/main/groovy/groovy/lang/ExpandoMetaClass.java
index 63dba12..a4482c2 100644
--- a/src/main/groovy/groovy/lang/ExpandoMetaClass.java
+++ b/src/main/groovy/groovy/lang/ExpandoMetaClass.java
@@ -63,25 +63,25 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
  * Some examples of usage:
  * <pre>
  * // defines or replaces instance method:
- * metaClass.myMethod = { args -> }
+ * metaClass.myMethod = { args {@code ->} }
  *
  * // defines a new instance method
- * metaClass.myMethod << { args -> }
+ * metaClass.myMethod {@code <<} { args {@code ->} }
  *
  * // creates multiple overloaded methods of the same name
- * metaClass.myMethod << { String s -> } << { Integer i -> }
+ * metaClass.myMethod {@code <<} { String s {@code ->} } {@code <<} { Integer
i {@code ->} }
  *
  * // defines or replaces a static method with the 'static' qualifier
- * metaClass.'static'.myMethod = { args ->  }
+ * metaClass.'static'.myMethod = { args {@code ->}  }
  *
  * // defines a new static method with the 'static' qualifier
- * metaClass.'static'.myMethod << { args ->  }
+ * metaClass.'static'.myMethod {@code <<} { args {@code ->}  }
  *
  * // defines a new constructor
- * metaClass.constructor << { String arg -> }
+ * metaClass.constructor {@code <<} { String arg {@code ->} }
  *
  * // defines or replaces a constructor
- * metaClass.constructor = { String arg -> }
+ * metaClass.constructor = { String arg {@code ->} }
  *
  * // defines a new property with an initial value of "blah"
  * metaClass.myProperty = "blah"
@@ -89,14 +89,14 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
  * <p>
  * ExpandoMetaClass also supports a DSL/builder like notation to combine multiple definitions
together. So instead of this:
  * <pre>
- * Number.metaClass.multiply = { Amount amount -> amount.times(delegate) }
- * Number.metaClass.div =      { Amount amount -> amount.inverse().times(delegate) }
+ * Number.metaClass.multiply = { Amount amount {@code ->} amount.times(delegate) }
+ * Number.metaClass.div =      { Amount amount {@code ->} amount.inverse().times(delegate)
}
  * </pre>
  * You can also now do this:
  * <pre>
  * Number.metaClass {
- *     multiply { Amount amount -> amount.times(delegate) }
- *     div      { Amount amount -> amount.inverse().times(delegate) }
+ *     multiply { Amount amount {@code ->} amount.times(delegate) }
+ *     div      { Amount amount {@code ->} amount.inverse().times(delegate) }
  * }
  * </pre>
  * <p>
@@ -138,12 +138,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
  * <pre>
  * class Student {
  *     List<String> schedule = []
- *     def addLecture(String lecture) { schedule << lecture }
+ *     def addLecture(String lecture) { schedule {@code <<} lecture }
  * }
  *
  * class Worker {
  *     List<String> schedule = []
- *     def addMeeting(String meeting) { schedule << meeting }
+ *     def addMeeting(String meeting) { schedule {@code <<} meeting }
  * }
  * </pre>
  * We can mimic a form of multiple inheritance as follows:
@@ -198,16 +198,16 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
  * ndq.metaClass {
  *     mixin ArrayDeque
  *     mixin HashSet
- *     leftShift = { Object o ->
+ *     leftShift = { Object o  {@code ->} 
  *         if (!mixedIn[Set].contains(o)) {
  *             mixedIn[Queue].push(o)
  *             mixedIn[Set].add(o)
  *         }
  *     }
  * }
- * ndq << 1
- * ndq << 2
- * ndq << 1
+ * ndq {@code <<} 1
+ * ndq {@code <<} 2
+ * ndq {@code <<} 1
  * assert ndq.size() == 2
  * </pre>
  * As a final example, we sometimes need to pass such mixed in classes or objects
@@ -232,8 +232,8 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
  * o.metaClass.mixin CustomComparator, CustomCloseable
  * def items = ['a', 'bbb', 'cc']
  * sort(items, o as Comparator)
- * println items                // => [a, cc, bbb]
- * closeQuietly(o as Closeable) // => Lights out - I am closing
+ * println items                // {@code =>} [a, cc, bbb]
+ * closeQuietly(o as Closeable) // {@code =>} Lights out - I am closing
  * </pre>
  * <p>
  * <b>Further details</b>
@@ -559,11 +559,11 @@ public class ExpandoMetaClass extends MetaClassImpl implements GroovyObject
{
     }
 
     /**
-     * Instances of this class are returned when using the << left shift operator.
+     * Instances of this class are returned when using the {@code <<} left shift operator.
      * <p>
      * Example:
      * <p>
-     * metaClass.myMethod << { String args -> }
+     * metaClass.myMethod {@code <<} { String args {@code ->} }
      * <p>
      * This allows callbacks to the ExpandoMetaClass for registering appending methods
      */
diff --git a/src/main/groovy/groovy/lang/GrabConfig.java b/src/main/groovy/groovy/lang/GrabConfig.java
index e6b8980..015dd96 100644
--- a/src/main/groovy/groovy/lang/GrabConfig.java
+++ b/src/main/groovy/groovy/lang/GrabConfig.java
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
  * <p>
  * An example involving databases:
  * <pre>
- * {@code @Grab}('mysql:mysql-connector-java:5.1.6'),
+ * {@code @Grab}('mysql:mysql-connector-java:5.1.6')
  * {@code @GrabConfig}(systemClassLoader=true)
  * import groovy.sql.Sql
  *
@@ -37,9 +37,10 @@ import java.lang.annotation.Target;
  * </pre>
  * Another example involving XStream:
  * <pre>
- * {@code @Grab}('com.thoughtworks.xstream:xstream:1.4.9'),
- * {@code @Grab}('xpp3:xpp3_min:1.1.4c'),
+ * {@code @Grab}('com.thoughtworks.xstream:xstream:1.4.9')
+ * {@code @Grab}('xpp3:xpp3_min:1.1.4c')
  * {@code @GrabConfig}(systemClassLoader=true, initContextClassLoader=true)
+ * {@code
  * import com.thoughtworks.xstream.*
  *
  * class Staff {
@@ -63,6 +64,7 @@ import java.lang.annotation.Target;
  * }
  *
  * println john2.dump()
+ * }
  * </pre>
  * <p>
  * Further information about customising grape behavior can be found on the Grape documentation
page:
diff --git a/src/main/groovy/groovy/lang/Range.java b/src/main/groovy/groovy/lang/Range.java
index 99f30de..0273341 100644
--- a/src/main/groovy/groovy/lang/Range.java
+++ b/src/main/groovy/groovy/lang/Range.java
@@ -33,7 +33,7 @@ import java.util.List;
  *
  * Particular range implementations may also support the notion of inclusivity
  * and exclusivity with respect to the ending value in the range.
- * E.g. <code>1..3 == [1, 2, 3]</code>; but <code>1..<3 == [1, 2]</code>.
+ * E.g. {@code 1..3 == [1, 2, 3]}; but {@code 1..<3 == [1, 2]}.
  *
  * In general, the second boundary may not be contained in the range,
  * and <code>a..b</code> may produce a different set of elements than <code>(b..a).reversed()</code>.
diff --git a/src/main/groovy/groovy/transform/builder/InitializerStrategy.java b/src/main/groovy/groovy/transform/builder/InitializerStrategy.java
index 0ed615e..cedd884 100644
--- a/src/main/groovy/groovy/transform/builder/InitializerStrategy.java
+++ b/src/main/groovy/groovy/transform/builder/InitializerStrategy.java
@@ -106,7 +106,9 @@ import static org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
  * </pre>
  * then the following compile-time error would result:
  * <pre>
+ * {@code
  * [Static type checking] - Cannot find matching method Person#<init>(Person$PersonInitializer
<groovy.transform.builder.InitializerStrategy$SET, groovy.transform.builder.InitializerStrategy$SET,
groovy.transform.builder.InitializerStrategy$UNSET>). Please check if the declared type
is correct and if the method exists.
+ * }
  * </pre>
  * The message is a little cryptic, but it is basically the static compiler telling us that
the third parameter, {@code age} in our case, is unset.
  *
diff --git a/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
index e2b2aee..5960e00 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/ClosureExpression.java
@@ -27,8 +27,8 @@ import org.codehaus.groovy.ast.stmt.Statement;
 import org.codehaus.groovy.runtime.InvokerHelper;
 
 /**
- * Represents a closure expression such as { statement }
- * or { i -> statement } or { i, x, String y ->  statement }
+ * Represents a closure expression such as <pre>{ statement }</pre>
+ * or { i {@code ->} statement } or { i, x, String y {@code ->}  statement }
  */
 public class ClosureExpression extends Expression {
     
diff --git a/src/main/java/org/codehaus/groovy/ast/expr/LambdaExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/LambdaExpression.java
index 8191feb..080e450 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/LambdaExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/LambdaExpression.java
@@ -25,8 +25,15 @@ import org.codehaus.groovy.ast.Parameter;
 import org.codehaus.groovy.ast.stmt.Statement;
 
 /**
- * Represents a lambda expression such as e -> e * 2
- * or (x, y) -> x + y or (x, y) -> { x + y } or (int x, int y) -> { x + y }
+ * Represents a lambda expression such as one of these:
+ * <pre>
+ * {@code
+ * e -> e * 2
+ * (x, y) -> x + y
+ * (x, y) -> { x + y }
+ * (int x, int y) -> { x + y }
+ * }
+ * </pre>
  */
 public class LambdaExpression extends ClosureExpression {
     public LambdaExpression(Parameter[] parameters, Statement code) {
diff --git a/src/main/java/org/codehaus/groovy/ast/expr/MethodPointerExpression.java b/src/main/java/org/codehaus/groovy/ast/expr/MethodPointerExpression.java
index 07422bb..206a047 100644
--- a/src/main/java/org/codehaus/groovy/ast/expr/MethodPointerExpression.java
+++ b/src/main/java/org/codehaus/groovy/ast/expr/MethodPointerExpression.java
@@ -25,8 +25,8 @@ import org.codehaus.groovy.ast.GroovyCodeVisitor;
 
 /**
  * Represents a method pointer on an object such as
- * foo.&bar which means find the method pointer on foo for the method called "bar"
- * which is equivalent to
+ * {@code foo.&bar} which means find the method pointer for the {@code bar} method on
the {@code foo} instance.
+ * This is equivalent to:
  * <code>
  * foo.metaClass.getMethodPointer(foo, "bar")
  * </code>
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/MethodCallerMultiAdapter.java
b/src/main/java/org/codehaus/groovy/classgen/asm/MethodCallerMultiAdapter.java
index 1802028..608e737 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/MethodCallerMultiAdapter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/MethodCallerMultiAdapter.java
@@ -1,83 +1,83 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.codehaus.groovy.classgen.asm;
-
-import org.objectweb.asm.MethodVisitor;
-
-public class MethodCallerMultiAdapter {
-    private MethodCaller[] methods;
-    boolean skipSpreadSafeAndSafe;
-
-    public static final int MAX_ARGS = 0;
-
-    public static MethodCallerMultiAdapter newStatic(Class theClass, String baseName, boolean
createNArgs, boolean skipSpreadSafeAndSafe) {
-        MethodCallerMultiAdapter mcma = new MethodCallerMultiAdapter();
-        mcma.skipSpreadSafeAndSafe = skipSpreadSafeAndSafe;
-        if (createNArgs) {
-            int numberOfBaseMethods = mcma.numberOfBaseMethods();
-            mcma.methods = new MethodCaller[(MAX_ARGS + 2) * numberOfBaseMethods];
-            for (int i = 0; i <= MAX_ARGS; i++) {
-                mcma.methods[i * numberOfBaseMethods] = MethodCaller.newStatic(theClass,
baseName + i);
-                if (skipSpreadSafeAndSafe) continue;
-                mcma.methods[i * numberOfBaseMethods + 1] = MethodCaller.newStatic(theClass,
baseName + i + "Safe");
-                mcma.methods[i * numberOfBaseMethods + 2] = MethodCaller.newStatic(theClass,
baseName + i + "SpreadSafe");
-            }
-            mcma.methods[(MAX_ARGS + 1) * numberOfBaseMethods] = MethodCaller.newStatic(theClass,
baseName + "N");
-            if (!skipSpreadSafeAndSafe) {
-                mcma.methods[(MAX_ARGS + 1) * numberOfBaseMethods + 1] = MethodCaller.newStatic(theClass,
baseName + "N" + "Safe");
-                mcma.methods[(MAX_ARGS + 1) * numberOfBaseMethods + 2] = MethodCaller.newStatic(theClass,
baseName + "N" + "SpreadSafe");
-            }
-
-        } else if (!skipSpreadSafeAndSafe) {
-            mcma.methods = new MethodCaller[]{
-                    MethodCaller.newStatic(theClass, baseName),
-                    MethodCaller.newStatic(theClass, baseName + "Safe"),
-                    MethodCaller.newStatic(theClass, baseName + "SpreadSafe")
-            };
-        } else {
-            mcma.methods = new MethodCaller[]{
-                    MethodCaller.newStatic(theClass, baseName)
-            };
-        }
-        return mcma;
-    }
-
-    /**
-     * @param methodVisitor
-     * @param numberOfArguments a value >0 describing how many arguments are additionally
used for the method call
-     * @param safe
-     * @param spreadSafe
-     */
-    public void call(MethodVisitor methodVisitor, int numberOfArguments, boolean safe, boolean
spreadSafe) {
-        int offset = 0;
-        if (safe && !skipSpreadSafeAndSafe) offset = 1;
-        if (spreadSafe && !skipSpreadSafeAndSafe) offset = 2;
-        if (numberOfArguments > MAX_ARGS || numberOfArguments < 0) {
-            offset += (MAX_ARGS + 1) * numberOfBaseMethods();
-        } else {
-            offset += numberOfArguments * numberOfBaseMethods();
-        }
-        methods[offset].call(methodVisitor);
-    }
-
-    private int numberOfBaseMethods() {
-        if (skipSpreadSafeAndSafe) return 1;
-        return 3;
-    }
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.classgen.asm;
+
+import org.objectweb.asm.MethodVisitor;
+
+public class MethodCallerMultiAdapter {
+    private MethodCaller[] methods;
+    boolean skipSpreadSafeAndSafe;
+
+    public static final int MAX_ARGS = 0;
+
+    public static MethodCallerMultiAdapter newStatic(Class theClass, String baseName, boolean
createNArgs, boolean skipSpreadSafeAndSafe) {
+        MethodCallerMultiAdapter mcma = new MethodCallerMultiAdapter();
+        mcma.skipSpreadSafeAndSafe = skipSpreadSafeAndSafe;
+        if (createNArgs) {
+            int numberOfBaseMethods = mcma.numberOfBaseMethods();
+            mcma.methods = new MethodCaller[(MAX_ARGS + 2) * numberOfBaseMethods];
+            for (int i = 0; i <= MAX_ARGS; i++) {
+                mcma.methods[i * numberOfBaseMethods] = MethodCaller.newStatic(theClass,
baseName + i);
+                if (skipSpreadSafeAndSafe) continue;
+                mcma.methods[i * numberOfBaseMethods + 1] = MethodCaller.newStatic(theClass,
baseName + i + "Safe");
+                mcma.methods[i * numberOfBaseMethods + 2] = MethodCaller.newStatic(theClass,
baseName + i + "SpreadSafe");
+            }
+            mcma.methods[(MAX_ARGS + 1) * numberOfBaseMethods] = MethodCaller.newStatic(theClass,
baseName + "N");
+            if (!skipSpreadSafeAndSafe) {
+                mcma.methods[(MAX_ARGS + 1) * numberOfBaseMethods + 1] = MethodCaller.newStatic(theClass,
baseName + "N" + "Safe");
+                mcma.methods[(MAX_ARGS + 1) * numberOfBaseMethods + 2] = MethodCaller.newStatic(theClass,
baseName + "N" + "SpreadSafe");
+            }
+
+        } else if (!skipSpreadSafeAndSafe) {
+            mcma.methods = new MethodCaller[]{
+                    MethodCaller.newStatic(theClass, baseName),
+                    MethodCaller.newStatic(theClass, baseName + "Safe"),
+                    MethodCaller.newStatic(theClass, baseName + "SpreadSafe")
+            };
+        } else {
+            mcma.methods = new MethodCaller[]{
+                    MethodCaller.newStatic(theClass, baseName)
+            };
+        }
+        return mcma;
+    }
+
+    /**
+     * @param methodVisitor
+     * @param numberOfArguments a value &gt; 0 describing how many arguments are additionally
used for the method call
+     * @param safe
+     * @param spreadSafe
+     */
+    public void call(MethodVisitor methodVisitor, int numberOfArguments, boolean safe, boolean
spreadSafe) {
+        int offset = 0;
+        if (safe && !skipSpreadSafeAndSafe) offset = 1;
+        if (spreadSafe && !skipSpreadSafeAndSafe) offset = 2;
+        if (numberOfArguments > MAX_ARGS || numberOfArguments < 0) {
+            offset += (MAX_ARGS + 1) * numberOfBaseMethods();
+        } else {
+            offset += numberOfArguments * numberOfBaseMethods();
+        }
+        methods[offset].call(methodVisitor);
+    }
+
+    private int numberOfBaseMethods() {
+        if (skipSpreadSafeAndSafe) return 1;
+        return 3;
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/org/codehaus/groovy/control/GenericsVisitor.java b/src/main/java/org/codehaus/groovy/control/GenericsVisitor.java
index e623b18..022cbff 100644
--- a/src/main/java/org/codehaus/groovy/control/GenericsVisitor.java
+++ b/src/main/java/org/codehaus/groovy/control/GenericsVisitor.java
@@ -36,7 +36,7 @@ import org.codehaus.groovy.ast.expr.TupleExpression;
  * <ul>
  * <li>class header (class and superclass declaration)</li>
  * <li>arity of type parameters for fields, parameters, local variables</li>
- * <li>invalid diamond &;t;&gt; usage</li>
+ * <li>invalid diamond {@code <>} usage</li>
  * </ul>
  */
 public class GenericsVisitor extends ClassCodeVisitorSupport {
diff --git a/src/main/java/org/codehaus/groovy/control/customizers/builder/InlinedASTCustomizerFactory.java
b/src/main/java/org/codehaus/groovy/control/customizers/builder/InlinedASTCustomizerFactory.java
index 66b4f41..9f6afc2 100644
--- a/src/main/java/org/codehaus/groovy/control/customizers/builder/InlinedASTCustomizerFactory.java
+++ b/src/main/java/org/codehaus/groovy/control/customizers/builder/InlinedASTCustomizerFactory.java
@@ -34,7 +34,7 @@ import java.util.Map;
  * <p>
  * Here is an example, which only logs the class name during compilation:
  * <pre>
- * inline(phase:'CONVERSION') { source, context, classNode ->
+ * inline(phase:'CONVERSION') { source, context, classNode {@code ->}
  *     println "visiting $classNode"
  * }
  * </pre>
diff --git a/src/main/java/org/codehaus/groovy/control/customizers/builder/SourceAwareCustomizerFactory.java
b/src/main/java/org/codehaus/groovy/control/customizers/builder/SourceAwareCustomizerFactory.java
index e1a4df7..cb02d8a 100644
--- a/src/main/java/org/codehaus/groovy/control/customizers/builder/SourceAwareCustomizerFactory.java
+++ b/src/main/java/org/codehaus/groovy/control/customizers/builder/SourceAwareCustomizerFactory.java
@@ -67,12 +67,12 @@ import java.util.Map;
  *     }
  *
  *     // apply CompileStatic AST annotation on files that do not contain a class named 'Baz'
- *     builder.source(unitValidator: { unit -> !unit.AST.classes.any { it.name == 'Baz'
} }) {
+ *     builder.source(unitValidator: { unit {@code ->} !unit.AST.classes.any { it.name
== 'Baz' } }) {
  *         ast(CompileStatic)
  *     }
  *
  *     // apply CompileStatic AST annotation on class nodes that end with 'CS'
- *     builder.source(classValidator: { cn -> cn.name.endsWith('CS') }) {
+ *     builder.source(classValidator: { cn {@code ->} cn.name.endsWith('CS') }) {
  *         ast(CompileStatic)
  *     }
  * </code></pre>
diff --git a/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java b/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java
index 52f52cb..588d846 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ComposedClosure.java
@@ -29,29 +29,29 @@ import java.util.List;
  * <p>
  * Typical usages:
  * <pre class="groovyTestCase">
- * def twice = { a -> a * 2 }
- * def inc = { b -> b + 1 }
- * def f = { x -> twice(inc(x)) } // longhand
- * def g = inc >> twice
- * def h = twice << inc
+ * def twice = { a {@code ->} a * 2 }
+ * def inc = { b {@code ->} b + 1 }
+ * def f = { x {@code ->} twice(inc(x)) } // longhand
+ * def g = inc {@code >>} twice
+ * def h = twice {@code <<} inc
  * assert f(10) == 22
  * assert g(10) == 22
  * assert h(10) == 22
  *
  * def s2c = { it.chars[0] }
- * def p = Integer.&toHexString >> s2c >> Character.&toUpperCase
+ * {@code def p = Integer.&toHexString >> s2c >> Character.&toUpperCase}
  * assert p(15) == 'F'
  *
- * def multiply = { a, b -> a * b }
- * def identity = { a -> [a, a] }
- * def sq = identity >> multiply
+ * def multiply = { a, b {@code ->} a * b }
+ * def identity = { a {@code ->} [a, a] }
+ * def sq = identity {@code >>} multiply
  * assert (1..5).collect{ sq(it) } == [1, 4, 9, 16, 25]
  *
- * def add3 = { a, b, c -> a + b + c }
+ * def add3 = { a, b, c {@code ->} a + b + c }
  * def add2plus10 = add3.curry(10)
- * def multBoth = { a, b, c -> [a*c, b*c] }
+ * def multBoth = { a, b, c {@code ->} [a*c, b*c] }
  * def twiceBoth = multBoth.rcurry(2)
- * def twiceBothPlus10 = twiceBoth >> add2plus10
+ * def twiceBothPlus10 = twiceBoth {@code >>} add2plus10
  * assert twiceBothPlus10(5, 10) == 40
  * </pre>
  */
diff --git a/src/main/java/org/codehaus/groovy/runtime/CurriedClosure.java b/src/main/java/org/codehaus/groovy/runtime/CurriedClosure.java
index e9365be..48cbe61 100644
--- a/src/main/java/org/codehaus/groovy/runtime/CurriedClosure.java
+++ b/src/main/java/org/codehaus/groovy/runtime/CurriedClosure.java
@@ -27,7 +27,7 @@ import groovy.lang.Closure;
  * Typical usages:
  * <pre class="groovyTestCase">
  * // normal usage
- * def unitAdder = { first, second, unit -> "${first + second} $unit" }
+ * def unitAdder = { first, second, unit {@code ->} "${first + second} $unit" }
  * assert unitAdder(10, 15, "minutes") == "25 minutes"
  * assert unitAdder.curry(60)(15, "minutes") == "75 minutes"
  * def minuteAdder = unitAdder.rcurry("minutes")
diff --git a/src/main/java/org/codehaus/groovy/runtime/memoize/StampedCommonCache.java b/src/main/java/org/codehaus/groovy/runtime/memoize/StampedCommonCache.java
index e9342ef..1b1da7a 100644
--- a/src/main/java/org/codehaus/groovy/runtime/memoize/StampedCommonCache.java
+++ b/src/main/java/org/codehaus/groovy/runtime/memoize/StampedCommonCache.java
@@ -30,7 +30,7 @@ import java.util.concurrent.locks.StampedLock;
  * StampedCommonCache has better performance than {@link ConcurrentCommonCache},
  * but it is not reentrant, in other words, <b>it may cause deadlock</b> if {@link
#getAndPut(Object, MemoizeCache.ValueProvider)}
  * or {@link #getAndPut(Object, MemoizeCache.ValueProvider, boolean)} is called recursively:
- * readlock -> upgrade to writelock -> readlock (fails to get and waits forever)
+ * readlock -&gt; upgrade to writelock -&gt; readlock (fails to get and waits forever)
  *
  * @param <K> type of the keys
  * @param <V> type of the values
diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
index 8b59d40..1c6cc65 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
@@ -53,7 +53,7 @@ import java.util.Map;
 import java.util.Properties;
 
 /**
- * A registry of MetaClass instances which caches introspection &
+ * A registry of MetaClass instances which caches introspection and
  * reflection information and allows methods to be dynamically added to
  * existing classes at runtime
  */
diff --git a/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
b/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
index 8fa5546..54900a2 100644
--- a/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
+++ b/subprojects/groovy-test/src/main/groovy/groovy/util/JavadocAssertionTestBuilder.groovy
@@ -25,6 +25,8 @@ import java.util.regex.Pattern
  * the Javadoc comments of a source file. Assertions should be placed within an html tag
with a <code>class="groovyTestCase"</code>
  * attribute assignment. Example:
  * <pre>&lt;pre class="groovyTestCase"&gt; assert "example".size() == 7 &lt;/pre&gt;</pre>
+ * When extracting the code for the test, single-line snippets of code without braces within
a {{@code @code} ...}
+ * tag will have the javadoc {@code code} tag stripped.
  */
 class JavadocAssertionTestBuilder {
     // TODO write tests for this classes functionality
@@ -36,7 +38,7 @@ class JavadocAssertionTestBuilder {
     Class buildTest(String filename, String code) {
         Class test = null
         
-        List assertionTags = getAssertionTags(code);
+        List assertionTags = getAssertionTags(code)
         if (assertionTags) {
             String testName = getTestName(filename)
 
diff --git a/subprojects/groovy-test/src/main/groovy/groovy/util/StringTestUtil.groovy b/subprojects/groovy-test/src/main/groovy/groovy/util/StringTestUtil.groovy
index b9bb855..0a575c4 100644
--- a/subprojects/groovy-test/src/main/groovy/groovy/util/StringTestUtil.groovy
+++ b/subprojects/groovy-test/src/main/groovy/groovy/util/StringTestUtil.groovy
@@ -1,32 +1,32 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package groovy.util
-
-import org.junit.Assert
-
-class StringTestUtil {
-    static void assertMultilineStringsEqual(String a, String b) {
-        def aLines = a.trim().replaceAll('\r','').split('\n')
-        def bLines = b.trim().replaceAll('\r','').split('\n')
-        assert aLines.size() == bLines.size()
-        for (i in 0..<aLines.size()) {
-            Assert.assertEquals(aLines[i].trim(), bLines[i].trim())
-        }
-    }
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.util
+
+import org.junit.Assert
+
+class StringTestUtil {
+    static void assertMultilineStringsEqual(String a, String b) {
+        def aLines = a.trim().replaceAll('\r','').split('\n')
+        def bLines = b.trim().replaceAll('\r','').split('\n')
+        assert aLines.size() == bLines.size()
+        for (i in 0..<aLines.size()) {
+            Assert.assertEquals(aLines[i].trim(), bLines[i].trim())
+        }
+    }
+}


Mime
View raw message