Skip to content

Commit eb91821

Browse files
committed
Add missing javadoc
1 parent 056ea54 commit eb91821

13 files changed

Lines changed: 431 additions & 0 deletions

src/main/groovy/org/codehaus/groovy/classgen/genArrayAccess.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public class ArrayOperations {
3636
}
3737
"""
3838

39+
/**
40+
* Generates the inner meta-method classes for each primitive array type.
41+
*
42+
* @return the Java source for the generated inner classes
43+
*/
3944
def genInners () {
4045
def res = ''
4146

src/main/groovy/org/codehaus/groovy/classgen/genArrayUtil.groovy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,24 @@ public class ArrayUtil {
2626
2727
"""
2828

29+
/**
30+
* Generates all supported {@code createArray} overloads.
31+
*
32+
* @return the Java source for the overload set
33+
*/
2934
def genMethods () {
3035
def res = ''
3136
for (i in 1..250)
3237
res += '\n\n' + genMethod (i)
3338
res
3439
}
3540

41+
/**
42+
* Generates a single {@code createArray} overload for the supplied arity.
43+
*
44+
* @param paramNum the number of array elements accepted by the overload
45+
* @return the Java source for the generated overload
46+
*/
3647
def genMethod (int paramNum) {
3748
def res = 'public static Object [] createArray ('
3849
for (k in 0..<paramNum) {

src/main/groovy/org/codehaus/groovy/classgen/genDgmMath.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@
1818
*/
1919
package org.codehaus.groovy.classgen
2020

21+
/**
22+
* Emits numeric call-site specializations for default Groovy method math operations.
23+
*/
2124
def types = ['Integer', 'Long', 'Float', 'Double']
2225

26+
/**
27+
* Returns the {@code NumberMath} implementation name for the supplied boxed operand types.
28+
*
29+
* @param a the left operand type name
30+
* @param b the right operand type name
31+
* @return the helper class name that should implement the operation
32+
*/
2333
def getMath (a,b) {
2434
if (a == 'Double' || b == 'Double' || a == 'Float' || b == 'Float')
2535
return 'FloatingPointMath'

src/main/groovy/org/codehaus/groovy/classgen/genMathModification.groovy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919
package org.codehaus.groovy.classgen
2020

21+
/**
22+
* Emits the numeric helper source used by {@code NumberMathModificationInfo}.
23+
*/
2124
def ops = [
2225
'plus',
2326
'minus',
@@ -77,14 +80,33 @@ ops.each { op ->
7780
}
7881
}
7982

83+
/**
84+
* Determines whether the supplied boxed number type is floating point.
85+
*
86+
* @param number the boxed number type name
87+
* @return {@code true} for {@code Double} or {@code Float}
88+
*/
8089
def isFloatingPoint(number) {
8190
number == 'Double' || number == 'Float'
8291
}
8392

93+
/**
94+
* Determines whether the supplied boxed number type is {@code Long}.
95+
*
96+
* @param number the boxed number type name
97+
* @return {@code true} when the type is {@code Long}
98+
*/
8499
def isLong(number) {
85100
number == 'Long'
86101
}
87102

103+
/**
104+
* Returns the arithmetic operator metadata for the supplied boxed operand types.
105+
*
106+
* @param left the left operand type name
107+
* @param right the right operand type name
108+
* @return a map describing the result type and supported operators
109+
*/
88110
def getMath (left, right) {
89111
if (isFloatingPoint(left) || isFloatingPoint(right)) {
90112
return [

src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,14 @@ import static org.codehaus.groovy.ast.tools.GeneralUtils.propX
8787
class ASTTransformationCustomizer extends CompilationCustomizer implements CompilationUnitAware {
8888

8989
private boolean applied // global xforms
90+
/**
91+
* Compilation unit currently being customized.
92+
*/
9093
protected CompilationUnit compilationUnit
9194
private final AnnotationNode annotationNode
95+
/**
96+
* Transformation instance applied by this customizer.
97+
*/
9298
final ASTTransformation transformation
9399

94100
/**
@@ -136,6 +142,14 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
136142
this.annotationParameters = annotationParams
137143
}
138144

145+
/**
146+
* Creates an AST transformation customizer using the specified annotation, annotation parameters,
147+
* and transformation class name.
148+
*
149+
* @param annotationParams the annotation member values to apply
150+
* @param transformationAnnotation the transformation annotation type
151+
* @param astTransformationClassName the implementation class name for the transformation
152+
*/
139153
ASTTransformationCustomizer(Map annotationParams, Class<? extends Annotation> transformationAnnotation, String astTransformationClassName) {
140154
this(annotationParams, transformationAnnotation, transformationAnnotation.classLoader)
141155
}
@@ -185,10 +199,22 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
185199
this.annotationParameters = annotationParams
186200
}
187201

202+
/**
203+
* Creates an AST transformation customizer using the specified annotation and annotation parameters.
204+
*
205+
* @param annotationParams the annotation member values to apply
206+
* @param transformationAnnotation the transformation annotation type
207+
*/
188208
ASTTransformationCustomizer(Map annotationParams, Class<? extends Annotation> transformationAnnotation) {
189209
this(annotationParams, transformationAnnotation, transformationAnnotation.classLoader)
190210
}
191211

212+
/**
213+
* Creates an AST transformation customizer using the specified transformation and annotation parameters.
214+
*
215+
* @param annotationParams the annotation member values to apply
216+
* @param transformation the transformation to invoke
217+
*/
192218
ASTTransformationCustomizer(Map annotationParams, ASTTransformation transformation) {
193219
this(transformation)
194220
this.annotationParameters = annotationParams
@@ -373,11 +399,23 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
373399

374400
//--------------------------------------------------------------------------
375401

402+
/**
403+
* Records the compilation unit that will receive the configured transformation.
404+
*
405+
* @param compilationUnit the owning compilation unit
406+
*/
376407
@Override
377408
void setCompilationUnit(CompilationUnit compilationUnit) {
378409
this.compilationUnit = compilationUnit
379410
}
380411

412+
/**
413+
* Applies the configured transformation to the supplied class or source unit.
414+
*
415+
* @param sourceUnit the current source unit
416+
* @param context the current generator context
417+
* @param classNode the class node being customized
418+
*/
381419
@Override
382420
void call(SourceUnit sourceUnit, GeneratorContext context, ClassNode classNode) {
383421
if (transformation instanceof CompilationUnitAware unitAware) {

src/main/groovy/org/codehaus/groovy/control/customizers/builder/ASTTransformationCustomizerFactory.groovy

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,40 @@ import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer
3636
@CompileStatic
3737
class ASTTransformationCustomizerFactory extends AbstractFactory {
3838

39+
/**
40+
* Indicates that {@code ast} nodes do not accept nested builder content.
41+
*
42+
* @return {@code true}
43+
*/
3944
@Override
4045
boolean isLeaf() {
4146
true
4247
}
4348

49+
/**
50+
* Leaves attribute handling to {@link #newInstance(FactoryBuilderSupport, Object, Object, Map)}.
51+
*
52+
* @param builder the active builder
53+
* @param node the current node
54+
* @param attributes the node attributes
55+
* @return {@code false} to keep the attributes available for instance creation
56+
*/
4457
@Override
4558
boolean onHandleNodeAttributes(final FactoryBuilderSupport builder, final Object node, final Map attributes) {
4659
false
4760
}
4861

62+
/**
63+
* Creates an {@link ASTTransformationCustomizer} for the supplied annotation and attributes.
64+
*
65+
* @param builder the active builder
66+
* @param name the node name
67+
* @param value the transformation annotation class
68+
* @param attributes annotation member values to apply
69+
* @return a configured {@link ASTTransformationCustomizer}
70+
* @throws InstantiationException if the customizer cannot be instantiated
71+
* @throws IllegalAccessException if the customizer cannot be accessed
72+
*/
4973
@Override
5074
@CompileDynamic
5175
Object newInstance(final FactoryBuilderSupport builder, final Object name, final Object value, final Map attributes) throws InstantiationException, IllegalAccessException {

src/main/groovy/org/codehaus/groovy/control/customizers/builder/CompilerCustomizationBuilder.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,23 @@ import org.codehaus.groovy.control.CompilerConfiguration
3131
@AutoFinal @CompileStatic
3232
class CompilerCustomizationBuilder extends FactoryBuilderSupport {
3333

34+
/**
35+
* Applies compilation customizers declared by the builder DSL to the supplied configuration.
36+
*
37+
* @param config the compiler configuration to customize
38+
* @param spec the customization DSL
39+
* @return the same {@link CompilerConfiguration} instance for chaining
40+
*/
3441
static CompilerConfiguration withConfig(CompilerConfiguration config, @DelegatesTo(type='org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder') Closure spec) {
3542
config.invokeMethod('addCompilationCustomizers', new CompilerCustomizationBuilder().invokeMethod('customizers', spec))
3643
config
3744
}
3845

3946
//--------------------------------------------------------------------------
4047

48+
/**
49+
* Creates a builder and registers the supported customization factories.
50+
*/
4151
CompilerCustomizationBuilder() {
4252
registerFactory('customizers', new CustomizersFactory()) // root
4353

@@ -48,6 +58,13 @@ class CompilerCustomizationBuilder extends FactoryBuilderSupport {
4858
registerFactory('source', new SourceAwareCustomizerFactory())
4959
}
5060

61+
/**
62+
* Finalizes a node and gives post-completion factories a chance to replace it.
63+
*
64+
* @param parent the parent builder node
65+
* @param node the node being completed
66+
* @return the completed node, possibly replaced by the active factory
67+
*/
5168
@Override
5269
protected Object postNodeCompletion(Object parent, Object node) {
5370
Object value = super.postNodeCompletion(parent, node)

0 commit comments

Comments
 (0)