Skip to content
Browse files

Revert "upgrade to Groovy 1.8.3 snapshot and fix various issues with …

…the use of generic types in transforms"

This reverts commit dbbd267.
  • Loading branch information...
1 parent 65a0488 commit d4bbbdafb2b96de9fff06a877c196f40156f7e37 Graeme Rocher committed Sep 21, 2011
Showing with 101 additions and 109 deletions.
  1. +1 −1 build.gradle
  2. +4 −6 ...core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/ASTValidationErrorsHelper.java
  3. +10 −6 .../main/groovy/org/codehaus/groovy/grails/compiler/injection/AbstractGrailsArtefactTransformer.java
  4. +5 −2 .../src/main/groovy/org/codehaus/groovy/grails/compiler/injection/ArtefactTypeAstTransformation.java
  5. +6 −12 ...c/main/groovy/org/codehaus/groovy/grails/compiler/injection/DefaultGrailsDomainClassInjector.java
  6. +5 −2 ...s-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/EntityASTTransformation.java
  7. +10 −14 grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/GrailsASTUtils.java
  8. +1 −3 ...core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/PluginAwareAstTransformer.java
  9. +1 −4 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/compiler/gorm/GormTransformer.java
  10. +0 −1 grails-hibernate/src/test/groovy/org/codehaus/groovy/grails/compiler/gorm/GormTransformerSpec.groovy
  11. +2 −5 grails-logging/src/main/groovy/org/codehaus/groovy/grails/compiler/logging/LoggingTransformer.java
  12. +18 −22 ...trollers/src/main/groovy/org/codehaus/groovy/grails/compiler/web/ControllerActionTransformer.java
  13. +6 −4 ...in-gsp/src/ast/groovy/org/codehaus/groovy/grails/compiler/web/gsp/GroovyPageOptimizerVisitor.java
  14. +8 −7 ...ugin-gsp/src/ast/groovy/org/codehaus/groovy/grails/compiler/web/taglib/TagLibraryTransformer.java
  15. +1 −2 ...lugin-mimetypes/src/main/groovy/org/codehaus/groovy/grails/compiler/web/MimeTypesTransformer.java
  16. +5 −2 ...esting/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/test/MockTransformation.java
  17. +4 −4 ...ing/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/test/TestForTransformation.java
  18. +3 −3 ...g/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/test/TestMixinTransformation.java
  19. +5 −6 grails-plugin-validation/src/main/groovy/grails/validation/DefaultASTValidateableHelper.java
  20. +6 −3 ...on/src/main/groovy/org/codehaus/groovy/grails/compiler/validation/ValidateableTransformation.java
View
2 build.gradle
@@ -25,7 +25,7 @@ commonsLangVersion = "2.6"
datastoreVersion = "1.0.0.BUILD-SNAPSHOT"
gantVersion = "1.9.5"
gdocEngineVersion = "1.0.1"
-groovyVersion = "1.8.3-SNAPSHOT"
+groovyVersion = "1.8.2"
ivyVersion = "2.2.0"
jansiVersion = "1.2.1"
jlineVersion = "1.0"
View
10 .../main/groovy/org/codehaus/groovy/grails/compiler/injection/ASTValidationErrorsHelper.java
@@ -40,14 +40,11 @@
private static final String INIT_ERRORS_METHOD_NAME = "initErrors";
private static final String ERRORS_PROPERTY_NAME = "errors";
private static final Token EQUALS_SYMBOL = Token.newSymbol(Types.EQUALS, 0, 0);
- private static final ClassNode ERRORS_CLASS_NODE = ClassHelper.make(Errors.class).getPlainNodeReference();
+ private static final ClassNode ERRORS_CLASS_NODE = new ClassNode(Errors.class);
private static final VariableExpression ERRORS_EXPRESSION = new VariableExpression(ERRORS_PROPERTY_NAME);
private static final VariableExpression THIS_EXPRESSION = new VariableExpression("this");
private static final TupleExpression EMPTY_TUPLE = new TupleExpression();
private static final MethodCallExpression INIT_ERRORS_METHOD_CALL_EXPRESSION = new MethodCallExpression(THIS_EXPRESSION, INIT_ERRORS_METHOD_NAME, EMPTY_TUPLE);
- public static final ClassNode PLAIN_BOOLEAN = ClassHelper.make(Boolean.class).getPlainNodeReference();
- public static final ClassNode VALIDATION_ERRORS_CLASS = ClassHelper.make(
- ValidationErrors.class).getPlainNodeReference();
public void injectErrorsCode(ClassNode classNode) {
addErrorsField(classNode);
@@ -79,7 +76,8 @@ protected void addInitErrorsMethod(final ClassNode paramTypeClassNode) {
final Statement newEvaluatorExpression = new ExpressionStatement(
new BinaryExpression(ERRORS_EXPRESSION,
EQUALS_SYMBOL,
- new ConstructorCallExpression(VALIDATION_ERRORS_CLASS,
+ new ConstructorCallExpression(new ClassNode(
+ ValidationErrors.class),
beanPropertyBindingResultConstructorArgs)));
final Statement initErrorsIfNullStatement = new IfStatement(
new BooleanExpression(errorsIsNullExpression), newEvaluatorExpression,
@@ -112,7 +110,7 @@ protected void addHasErrorsMethod(final ClassNode paramTypeClassNode) {
final Statement returnStatement = new ReturnStatement(new BooleanExpression(new MethodCallExpression(ERRORS_EXPRESSION, HAS_ERRORS_METHOD_NAME, EMPTY_TUPLE)));
hasErrorsMethodCode.addStatement(returnStatement);
paramTypeClassNode.addMethod(new MethodNode(HAS_ERRORS_METHOD_NAME,
- Modifier.PUBLIC, PLAIN_BOOLEAN,
+ Modifier.PUBLIC, new ClassNode(Boolean.class),
ZERO_PARAMETERS, EMPTY_CLASS_ARRAY, hasErrorsMethodCode));
}
}
View
16 ...oovy/org/codehaus/groovy/grails/compiler/injection/AbstractGrailsArtefactTransformer.java
@@ -20,7 +20,11 @@
import java.lang.reflect.Modifier;
import java.util.List;
-import org.codehaus.groovy.ast.*;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ClassNode;
+import org.codehaus.groovy.ast.FieldNode;
+import org.codehaus.groovy.ast.MethodNode;
+import org.codehaus.groovy.ast.PropertyNode;
import org.codehaus.groovy.ast.expr.ArgumentListExpression;
import org.codehaus.groovy.ast.expr.ClassExpression;
import org.codehaus.groovy.ast.expr.ConstantExpression;
@@ -48,10 +52,10 @@
private static final String INSTANCE_PREFIX = "instance";
private static final String STATIC_PREFIX = "static";
- private static final AnnotationNode AUTO_WIRED_ANNOTATION = new AnnotationNode(ClassHelper.make(Autowired.class).getPlainNodeReference());
- private static final ClassNode ENHANCED_CLASS_NODE = ClassHelper.make(Enhanced.class).getPlainNodeReference();
+ private static final AnnotationNode AUTO_WIRED_ANNOTATION = new AnnotationNode(new ClassNode(Autowired.class));
+ private static final ClassNode ENHANCED_CLASS_NODE = new ClassNode(Enhanced.class);
- public static final ClassNode OBJECT_CLASS = new ClassNode(Object.class).getPlainNodeReference();
+ protected static final ClassNode OBJECT_CLASS = new ClassNode(Object.class);
protected static final VariableExpression THIS_EXPRESSION = new VariableExpression("this");
public static final int PUBLIC_STATIC_MODIFIER = Modifier.PUBLIC | Modifier.STATIC;
@@ -86,7 +90,7 @@ public void performInjection(SourceUnit source, GeneratorContext context, ClassN
Class instanceImplementation = getInstanceImplementation();
if (instanceImplementation != null) {
- ClassNode implementationNode = ClassHelper.make(instanceImplementation).getPlainNodeReference();
+ ClassNode implementationNode = new ClassNode(instanceImplementation);
String apiInstanceProperty = INSTANCE_PREFIX + instanceImplementation.getSimpleName();
Expression apiInstance = new VariableExpression(apiInstanceProperty);
@@ -129,7 +133,7 @@ else if (isCandidateInstanceMethod(classNode, declaredMethod)) {
Class staticImplementation = getStaticImplementation();
if (staticImplementation != null) {
- ClassNode staticImplementationNode = ClassHelper.make(staticImplementation).getPlainNodeReference();
+ ClassNode staticImplementationNode = new ClassNode(staticImplementation);
final List<MethodNode> declaredMethods = staticImplementationNode.getMethods();
final String staticImplementationSimpleName = staticImplementation.getSimpleName();
View
7 ...n/groovy/org/codehaus/groovy/grails/compiler/injection/ArtefactTypeAstTransformation.java
@@ -20,7 +20,10 @@
import java.util.ArrayList;
import java.util.List;
-import org.codehaus.groovy.ast.*;
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.AnnotatedNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.expr.ConstantExpression;
import org.codehaus.groovy.ast.expr.Expression;
import org.codehaus.groovy.control.CompilePhase;
@@ -38,7 +41,7 @@
*/
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
public class ArtefactTypeAstTransformation extends AbstractArtefactTypeAstTransformation implements ASTTransformation {
- private static final ClassNode MY_TYPE = ClassHelper.make(Artefact.class);
+ private static final ClassNode MY_TYPE = new ClassNode(Artefact.class);
private static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();
public void visit(ASTNode[] astNodes, SourceUnit sourceUnit) {
View
18 ...roovy/org/codehaus/groovy/grails/compiler/injection/DefaultGrailsDomainClassInjector.java
@@ -45,8 +45,6 @@
private static final String DOMAIN_DIR = "domain";
private static final String GRAILS_APP_DIR = "grails-app";
- public static final ClassNode STRING_CLASS = ClassHelper.make(String.class).getPlainNodeReference();
- public static final ClassNode LONG_CLASS = ClassHelper.make(Long.class).getPlainNodeReference();
private List<ClassNode> classesWithInjectedToString = new ArrayList<ClassNode>();
@@ -139,7 +137,6 @@ private void injectAssociations(ClassNode classNode) {
type = ClassHelper.make(expression.getText());
}
- type = GrailsASTUtils.nonGeneric(type);
properties.add(new PropertyNode(key, Modifier.PUBLIC, type, classNode, null, null, null));
}
}
@@ -161,10 +158,7 @@ private void injectAssociationProperties(ClassNode classNode, List<PropertyNode>
MapExpression me = (MapExpression) e;
for (MapEntryExpression mee : me.getMapEntryExpressions()) {
String key = mee.getKeyExpression().getText();
- Expression valueExpression = mee.getValueExpression();
- if(valueExpression instanceof ClassExpression) {
- addAssociationForKey(key, properties, classNode, findPropertyType(mee.getValueExpression()));
- }
+ addAssociationForKey(key, properties, classNode, findPropertyType(mee.getValueExpression()));
}
}
return properties;
@@ -177,10 +171,10 @@ private void injectAssociationProperties(ClassNode classNode, List<PropertyNode>
* @return A {@link ClassNode} of type {@link Set} that is possibly parameterized by the expression that is passed in.
*/
private ClassNode findPropertyType(Expression expression) {
- ClassNode setNode = ClassHelper.make(Set.class).getPlainNodeReference();
+ ClassNode setNode = new ClassNode(Set.class);
if (expression instanceof ClassExpression) {
GenericsType[] genericsTypes = new GenericsType[1];
- genericsTypes[0] = new GenericsType(GrailsASTUtils.nonGeneric(expression.getType()));
+ genericsTypes[0] = new GenericsType(expression.getType());
setNode.setGenericsTypes(genericsTypes);
}
return setNode;
@@ -199,7 +193,7 @@ private void injectToStringMethod(ClassNode classNode) {
ge.addString(new ConstantExpression(classNode.getName() + " : "));
ge.addValue(new VariableExpression("id"));
Statement s = new ReturnStatement(ge);
- MethodNode mn = new MethodNode("toString", Modifier.PUBLIC, STRING_CLASS, new Parameter[0], new ClassNode[0], s);
+ MethodNode mn = new MethodNode("toString", Modifier.PUBLIC, new ClassNode(String.class), new Parameter[0], new ClassNode[0], s);
classNode.addMethod(mn);
classesWithInjectedToString.add(classNode);
}
@@ -219,7 +213,7 @@ private void injectVersionProperty(ClassNode classNode) {
if (!hasVersion) {
ClassNode parent = GrailsASTUtils.getFurthestUnresolvedParent(classNode);
- parent.addProperty(GrailsDomainClassProperty.VERSION, Modifier.PUBLIC, LONG_CLASS, null, null, null);
+ parent.addProperty(GrailsDomainClassProperty.VERSION, Modifier.PUBLIC, new ClassNode(Long.class), null, null, null);
}
}
@@ -230,7 +224,7 @@ private void injectIdProperty(ClassNode classNode) {
// inject into furthest relative
ClassNode parent = GrailsASTUtils.getFurthestUnresolvedParent(classNode);
- parent.addProperty(GrailsDomainClassProperty.IDENTITY, Modifier.PUBLIC, LONG_CLASS, null, null, null);
+ parent.addProperty(GrailsDomainClassProperty.IDENTITY, Modifier.PUBLIC, new ClassNode(Long.class), null, null, null);
}
}
View
7 ...rc/main/groovy/org/codehaus/groovy/grails/compiler/injection/EntityASTTransformation.java
@@ -17,7 +17,10 @@
import grails.build.logging.GrailsConsole;
import grails.persistence.Entity;
-import org.codehaus.groovy.ast.*;
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.AnnotatedNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.control.CompilePhase;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.grails.commons.DomainClassArtefactHandler;
@@ -35,7 +38,7 @@
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
public class EntityASTTransformation implements ASTTransformation {
- private static final ClassNode MY_TYPE = ClassHelper.make(Entity.class);
+ private static final ClassNode MY_TYPE = new ClassNode(Entity.class);
private static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();
public void visit(ASTNode[] astNodes, SourceUnit sourceUnit) {
View
24 ...ls-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/GrailsASTUtils.java
@@ -20,12 +20,15 @@
import java.lang.reflect.Modifier;
import java.util.List;
-import java.util.Map;
-import groovy.lang.Closure;
import org.apache.commons.lang.StringUtils;
import org.codehaus.groovy.ast.*;
-import org.codehaus.groovy.ast.expr.*;
+import org.codehaus.groovy.ast.expr.ArgumentListExpression;
+import org.codehaus.groovy.ast.expr.ClassExpression;
+import org.codehaus.groovy.ast.expr.ConstructorCallExpression;
+import org.codehaus.groovy.ast.expr.Expression;
+import org.codehaus.groovy.ast.expr.MethodCallExpression;
+import org.codehaus.groovy.ast.expr.VariableExpression;
import org.codehaus.groovy.ast.stmt.BlockStatement;
import org.codehaus.groovy.ast.stmt.ExpressionStatement;
import org.codehaus.groovy.ast.stmt.Statement;
@@ -41,13 +44,6 @@
public static final String METHOD_MISSING_METHOD_NAME = "methodMissing";
public static final String STATIC_METHOD_MISSING_METHOD_NAME = "$static_methodMissing";
- public static final ClassNode OBJECT_CLASS = new ClassNode(Object.class);
- public static final TupleExpression EMPTY_TUPLE = new TupleExpression();
- public static final VariableExpression THIS_EXPRESSION = new VariableExpression("this");
- public static final ClassNode MAP_CLASS = ClassHelper.make(Map.class).getPlainNodeReference();
- public static final ClassNode STRING_CLASS = ClassHelper.make(String.class).getPlainNodeReference();
- public static final ClassNode CLOSURE_CLASS = new ClassNode(Closure.class).getPlainNodeReference();
- public static final ClassNode LIST_CLASS = new ClassNode(List.class).getPlainNodeReference();
/**
* Returns whether a classNode has the specified property or not
@@ -416,7 +412,7 @@ public static ConstructorNode getDefaultConstructor(ClassNode classNode) {
return newParameterTypes;
}
- public static ClassNode nonGeneric(ClassNode type) {
+ private static ClassNode nonGeneric(ClassNode type) {
if (type.isUsingGenerics()) {
final ClassNode nonGen = ClassHelper.makeWithoutCaching(type.getName());
nonGen.setRedirect(type);
@@ -431,7 +427,7 @@ public static ClassNode nonGeneric(ClassNode type) {
return nonGen.makeArray();
}
- return type.getPlainNodeReference();
+ return type;
}
public static boolean isCandidateInstanceMethod(ClassNode classNode, MethodNode declaredMethod) {
@@ -504,9 +500,9 @@ public static void addFieldIfNonExistent(ClassNode classNode, ClassNode fieldTyp
}
}
- public static void addAnnotationIfNecessary(ClassNode classNode, Class entityClass) {
+ public static void addAnnotationIfNecessary(ClassNode classNode, Class<Entity> entityClass) {
List<AnnotationNode> annotations = classNode.getAnnotations();
- ClassNode annotationClassNode = ClassHelper.make(entityClass).getPlainNodeReference();
+ ClassNode annotationClassNode = new ClassNode(Entity.class);
AnnotationNode annotationToAdd = new AnnotationNode(annotationClassNode);
if(annotations.isEmpty()) {
classNode.addAnnotation(annotationToAdd);
View
4 .../main/groovy/org/codehaus/groovy/grails/compiler/injection/PluginAwareAstTransformer.java
@@ -16,7 +16,6 @@
import grails.util.PluginBuildSettings;
import org.codehaus.groovy.ast.AnnotationNode;
-import org.codehaus.groovy.ast.ClassHelper;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.expr.ConstantExpression;
import org.codehaus.groovy.classgen.GeneratorContext;
@@ -39,7 +38,6 @@
@AstTransformer
public class PluginAwareAstTransformer implements ClassInjector, AllArtefactClassInjector {
- public static final ClassNode PLUGIN_ANNOTATION = ClassHelper.make(GrailsPlugin.class);
PluginBuildSettings pluginBuildSettings;
public PluginAwareAstTransformer() {
@@ -59,7 +57,7 @@ public void performInjection(SourceUnit source, GeneratorContext context, ClassN
return;
}
- final ClassNode annotation = PLUGIN_ANNOTATION;
+ final ClassNode annotation = new ClassNode(GrailsPlugin.class);
final List<?> list = classNode.getAnnotations(annotation);
if (!list.isEmpty()) {
return;
View
5 ...s-hibernate/src/main/groovy/org/codehaus/groovy/grails/compiler/gorm/GormTransformer.java
@@ -21,7 +21,6 @@
import grails.persistence.Entity;
import org.codehaus.groovy.ast.AnnotationNode;
-import org.codehaus.groovy.ast.ClassHelper;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.MethodNode;
import org.codehaus.groovy.ast.expr.ArgumentListExpression;
@@ -58,7 +57,6 @@
private static final List<String> EXCLUDES = Arrays.asList("create");
private static final Class<?>[] EMPTY_JAVA_CLASS_ARRAY = {};
private static final Class<?>[] OBJECT_CLASS_ARG = { Object.class };
- public static final ClassNode ILLEGAL_STATE_EXCEPTION_CLASS = ClassHelper.make(IllegalStateException.class).getPlainNodeReference();
@Override
protected boolean isStaticCandidateMethod(ClassNode classNode, MethodNode declaredMethod) {
@@ -109,7 +107,7 @@ protected boolean requiresStaticLookupMethod() {
protected MethodNode populateAutowiredApiLookupMethod(ClassNode implementationNode, String apiInstanceProperty, String methodName, BlockStatement methodBody) {
ArgumentListExpression arguments = new ArgumentListExpression();
arguments.addExpression(new ConstantExpression(MISSING_GORM_ERROR_MESSAGE));
- methodBody.addStatement(new ThrowStatement(new ConstructorCallExpression(ILLEGAL_STATE_EXCEPTION_CLASS, arguments)));
+ methodBody.addStatement(new ThrowStatement(new ConstructorCallExpression(new ClassNode(IllegalStateException.class), arguments)));
return new MethodNode(methodName, PUBLIC_STATIC_MODIFIER, implementationNode,ZERO_PARAMETERS,null,methodBody);
}
@@ -118,7 +116,6 @@ protected void performInjectionInternal(String apiInstanceProperty, SourceUnit s
classNode.setUsingGenerics(true);
GrailsASTUtils.addAnnotationIfNecessary(classNode, Entity.class);
- classNode = GrailsASTUtils.nonGeneric(classNode);
final BlockStatement methodBody = new BlockStatement();
methodBody.addStatement(new ExpressionStatement(new MethodCallExpression(new ClassExpression(classNode), NEW_INSTANCE_METHOD,ZERO_ARGS)));
MethodNode methodNode = classNode.getDeclaredMethod(CreateDynamicMethod.METHOD_NAME, ZERO_PARAMETERS);
View
1 ...rnate/src/test/groovy/org/codehaus/groovy/grails/compiler/gorm/GormTransformerSpec.groovy
@@ -49,7 +49,6 @@ class Associated {
cls.getAnnotation(Entity) != null
cls.getDeclaredField("associated") != null
cls.getDeclaredField("associated").genericType != null
- println cls.getDeclaredField("associated").genericType
cls.getDeclaredField("associated").genericType.getActualTypeArguments()[0] == gcl.loadClass("Associated")
}
View
7 ...gging/src/main/groovy/org/codehaus/groovy/grails/compiler/logging/LoggingTransformer.java
@@ -17,7 +17,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codehaus.groovy.ast.ClassHelper;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.FieldNode;
import org.codehaus.groovy.ast.expr.ArgumentListExpression;
@@ -45,8 +44,6 @@
private static final String FILTERS_ARTEFACT_TYPE_SUFFIX = "Filters";
public static final String CONF_DIR = "conf";
public static final String FILTERS_ARTEFACT_TYPE = "filters";
- public static final ClassNode LOG_CLASS = ClassHelper.make(Log.class).getPlainNodeReference();
- public static final ClassExpression LOG_FACTORY_EXPRESSION = new ClassExpression(ClassHelper.make(LogFactory.class).getPlainNodeReference());
public void performInjection(SourceUnit source, GeneratorContext context, ClassNode classNode) {
final FieldNode existingField = classNode.getDeclaredField(LOG_PROPERTY);
@@ -68,9 +65,9 @@ public void performInjection(SourceUnit source, GeneratorContext context, ClassN
public static void addLogField(ClassNode classNode, String logName) {
FieldNode logVariable = new FieldNode(LOG_PROPERTY,
Modifier.STATIC | Modifier.PRIVATE,
- LOG_CLASS,
+ new ClassNode(Log.class),
classNode,
- new MethodCallExpression(LOG_FACTORY_EXPRESSION, "getLog", new ArgumentListExpression(new ConstantExpression(logName))));
+ new MethodCallExpression(new ClassExpression(new ClassNode(LogFactory.class)), "getLog", new ArgumentListExpression(new ConstantExpression(logName))));
classNode.addField(logVariable);
}
View
40 .../src/main/groovy/org/codehaus/groovy/grails/compiler/web/ControllerActionTransformer.java
@@ -50,6 +50,7 @@
import org.codehaus.groovy.ast.expr.PropertyExpression;
import org.codehaus.groovy.ast.expr.StaticMethodCallExpression;
import org.codehaus.groovy.ast.expr.TernaryExpression;
+import org.codehaus.groovy.ast.expr.TupleExpression;
import org.codehaus.groovy.ast.expr.VariableExpression;
import org.codehaus.groovy.ast.stmt.BlockStatement;
import org.codehaus.groovy.ast.stmt.ExpressionStatement;
@@ -60,9 +61,7 @@
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.control.messages.SimpleMessage;
import org.codehaus.groovy.grails.commons.ControllerArtefactHandler;
-import org.codehaus.groovy.grails.compiler.injection.AbstractGrailsArtefactTransformer;
import org.codehaus.groovy.grails.compiler.injection.AstTransformer;
-import org.codehaus.groovy.grails.compiler.injection.GrailsASTUtils;
import org.codehaus.groovy.grails.compiler.injection.GrailsArtefactClassInjector;
import org.codehaus.groovy.grails.web.plugins.support.WebMetaUtils;
import org.codehaus.groovy.syntax.Token;
@@ -126,9 +125,12 @@ def someAction() {
@AstTransformer
public class ControllerActionTransformer implements GrailsArtefactClassInjector {
+ private static final ClassNode OBJECT_CLASS = new ClassNode(Object.class);
private static final AnnotationNode ACTION_ANNOTATION_NODE = new AnnotationNode(new ClassNode(Action.class));
private static final String ACTION_MEMBER_TARGET = "commandObjects";
+ private static final VariableExpression THIS_EXPRESSION = new VariableExpression("this");
private static final VariableExpression PARAMS_EXPRESSION = new VariableExpression("params");
+ private static final TupleExpression EMPTY_TUPLE = new TupleExpression();
@SuppressWarnings({ "unchecked"})
private static final Map<ClassNode, String> TYPE_WRAPPER_CLASS_TO_CONVERSION_METHOD_NAME = CollectionUtils.<ClassNode, String>newMap(
ClassHelper.Integer_TYPE, "int",
@@ -148,12 +150,6 @@ def someAction() {
ClassHelper.double_TYPE,
ClassHelper.float_TYPE,
ClassHelper.byte_TYPE);
- public static final ConstructorCallExpression MAP_CONSTRUCTOR_CALL = new ConstructorCallExpression(ClassHelper.make(HashMap.class).getPlainNodeReference(), GrailsASTUtils.EMPTY_TUPLE);
-
- public static final AnnotationNode ACTION_ANNOTATION = new AnnotationNode(ClassHelper.make(Action.class).getPlainNodeReference());
- public static final ClassNode WEB_META_UTILS_CLASS = ClassHelper.make(WebMetaUtils.class).getPlainNodeReference();
- public static final ClassNode MAP_BINDING_RESULT_CLASS = ClassHelper.make(MapBindingResult.class).getPlainNodeReference();
- public static final ClassNode REQUEST_PARAMETER_ANNOTATION = ClassHelper.make(RequestParameter.class).getPlainNodeReference();
private Boolean converterEnabled;
@@ -238,7 +234,7 @@ private Statement addOriginalMethodCall(MethodNode _method, BlockStatement block
}
MethodCallExpression callExpression = new MethodCallExpression(
- GrailsASTUtils.THIS_EXPRESSION, _method.getName(), arguments);
+ THIS_EXPRESSION, _method.getName(), arguments);
callExpression.setMethodTarget(_method);
blockStatement.addStatement(new ReturnStatement(callExpression));
@@ -286,7 +282,7 @@ protected void addMethodToInvokeClosure(ClassNode controllerClassNode,
}
final MethodCallExpression methodCallExpression = new MethodCallExpression(closureExpression, "call", closureInvocationArguments);
newMethodCode.addStatement(new ExpressionStatement(methodCallExpression));
- final MethodNode methodNode = new MethodNode(closureProperty.getName(), Modifier.PUBLIC, AbstractGrailsArtefactTransformer.OBJECT_CLASS, ZERO_PARAMETERS, EMPTY_CLASS_ARRAY, newMethodCode);
+ final MethodNode methodNode = new MethodNode(closureProperty.getName(), Modifier.PUBLIC, new ClassNode(Object.class), ZERO_PARAMETERS, EMPTY_CLASS_ARRAY, newMethodCode);
annotateActionMethod(parameters, methodNode);
@@ -300,7 +296,7 @@ protected void annotateActionMethod(final Parameter[] parameters,
for (Parameter parameter : parameters) {
initArray.addExpression(new ClassExpression(parameter.getType()));
}
- AnnotationNode paramActionAnn = ACTION_ANNOTATION;
+ AnnotationNode paramActionAnn = new AnnotationNode(new ClassNode(Action.class));
paramActionAnn.setMember(ACTION_MEMBER_TARGET, initArray);
methodNode.addAnnotation(paramActionAnn);
@@ -331,10 +327,10 @@ protected BlockStatement initializeActionParameters(ClassNode classNode,
BlockStatement wrapper = new BlockStatement();
ArgumentListExpression mapBindingResultConstructorArgs = new ArgumentListExpression();
- mapBindingResultConstructorArgs.addExpression(MAP_CONSTRUCTOR_CALL);
+ mapBindingResultConstructorArgs.addExpression(new ConstructorCallExpression(new ClassNode(HashMap.class), EMPTY_TUPLE));
mapBindingResultConstructorArgs.addExpression(new ConstantExpression("controller"));
final Expression mapBindingResultConstructorCallExpression = new ConstructorCallExpression(
- MAP_BINDING_RESULT_CLASS, mapBindingResultConstructorArgs);
+ new ClassNode(MapBindingResult.class), mapBindingResultConstructorArgs);
final Expression errorsAssignmentExpression = new BinaryExpression(
new VariableExpression("errors"), Token.newSymbol(Types.EQUALS, 0, 0),
@@ -352,17 +348,17 @@ protected void initializeMethodParameter(final ClassNode classNode, final BlockS
final ClassNode paramTypeClassNode = param.getType();
final String paramName = param.getName();
String requestParameterName = paramName;
- List<AnnotationNode> requestParameters = param.getAnnotations(REQUEST_PARAMETER_ANNOTATION);
+ List<AnnotationNode> requestParameters = param.getAnnotations(new ClassNode(RequestParameter.class));
if (requestParameters.size() == 1) {
requestParameterName = requestParameters.get(0).getMember("value").getText();
}
if ((PRIMITIVE_CLASS_NODES.contains(paramTypeClassNode) ||
TYPE_WRAPPER_CLASS_TO_CONVERSION_METHOD_NAME.containsKey(paramTypeClassNode))) {
initializePrimitiveOrTypeWrapperParameter(wrapper, param, requestParameterName);
- } else if (paramTypeClassNode.equals(GrailsASTUtils.STRING_CLASS)) {
+ } else if (paramTypeClassNode.equals(new ClassNode(String.class))) {
initializeStringParameter(wrapper, param, requestParameterName);
- } else if (!paramTypeClassNode.equals(GrailsASTUtils.OBJECT_CLASS)) {
+ } else if (!paramTypeClassNode.equals(OBJECT_CLASS)) {
initializeCommandObjectParameter(wrapper, classNode, paramTypeClassNode, paramName);
}
}
@@ -374,7 +370,7 @@ protected void initializeCommandObjectParameter(final BlockStatement wrapper,
enhanceCommandObjectClass(commandObjectTypeClassNode);
final Expression constructorCallExpression = new ConstructorCallExpression(
- commandObjectTypeClassNode, GrailsASTUtils.EMPTY_TUPLE);
+ commandObjectTypeClassNode, EMPTY_TUPLE);
final Statement newCommandCode = new ExpressionStatement(
new DeclarationExpression(new VariableExpression(paramName, commandObjectTypeClassNode),
@@ -390,7 +386,7 @@ protected void initializeCommandObjectParameter(final BlockStatement wrapper,
classNode, paramName, commandObjectTypeClassNode);
wrapper.addStatement(statement);
final MethodCallExpression validateMethodCallExpression = new MethodCallExpression(
- new VariableExpression(paramName), "validate", GrailsASTUtils.EMPTY_TUPLE);
+ new VariableExpression(paramName), "validate", EMPTY_TUPLE);
MethodNode validateMethod =
commandObjectTypeClassNode.getMethod("validate", new Parameter[0]);
if (validateMethod != null) {
@@ -413,10 +409,10 @@ protected Statement getCommandObjectDataBindingStatement(
final ArgumentListExpression getCommandObjectBindingParamsArgs = new ArgumentListExpression();
getCommandObjectBindingParamsArgs.addExpression(new MethodCallExpression(new VariableExpression(paramName), "getClass", ZERO_ARGS));
getCommandObjectBindingParamsArgs.addExpression(PARAMS_EXPRESSION);
- Expression invokeGetCommandObjectBindingParamsExpression = new StaticMethodCallExpression(WEB_META_UTILS_CLASS, "getCommandObjectBindingParams", getCommandObjectBindingParamsArgs);
+ Expression invokeGetCommandObjectBindingParamsExpression = new StaticMethodCallExpression(new ClassNode(WebMetaUtils.class), "getCommandObjectBindingParams", getCommandObjectBindingParamsArgs);
final Statement intializeCommandObjectParams = new ExpressionStatement(
new DeclarationExpression(new VariableExpression(
- "commandObjectParams", GrailsASTUtils.MAP_CLASS),
+ "commandObjectParams", new ClassNode(Map.class)),
Token.newSymbol(Types.EQUALS, 0, 0),
invokeGetCommandObjectBindingParamsExpression));
@@ -427,7 +423,7 @@ protected Statement getCommandObjectDataBindingStatement(
arguments.addExpression(new VariableExpression(new VariableExpression("commandObjectParams")));
final MethodCallExpression bindDataMethodCallExpression = new MethodCallExpression(
- GrailsASTUtils.THIS_EXPRESSION, "bindData", arguments);
+ THIS_EXPRESSION, "bindData", arguments);
// final MethodNode bindDataMethodNode = controllerClassNode.getMethod("bindData", new Parameter[]{
// new Parameter(new ClassNode(Object.class), "target"),
// new Parameter(new ClassNode(Object.class), "params")});
@@ -498,7 +494,7 @@ protected void initializePrimitiveOrTypeWrapperParameter(final BlockStatement wr
new MethodCallExpression(PARAMS_EXPRESSION, "containsKey", paramsContainsKeyMethodArguments));
final Token equalsToken = Token.newSymbol(Types.EQUALS, 0, 0);
- final VariableExpression convertedValueExpression = new VariableExpression("___converted_" + methodParamName, GrailsASTUtils.OBJECT_CLASS);
+ final VariableExpression convertedValueExpression = new VariableExpression("___converted_" + methodParamName, new ClassNode(Object.class));
final DeclarationExpression declareConvertedValueExpression = new DeclarationExpression(convertedValueExpression, equalsToken, new EmptyExpression());
Statement declareVariableStatement = new ExpressionStatement(declareConvertedValueExpression);
View
10 ...rc/ast/groovy/org/codehaus/groovy/grails/compiler/web/gsp/GroovyPageOptimizerVisitor.java
@@ -1,12 +1,14 @@
package org.codehaus.groovy.grails.compiler.web.gsp;
import groovy.lang.Closure;
-import org.codehaus.groovy.ast.*;
+import org.codehaus.groovy.ast.ClassNode;
+import org.codehaus.groovy.ast.CodeVisitorSupport;
+import org.codehaus.groovy.ast.MethodNode;
+import org.codehaus.groovy.ast.Parameter;
import org.codehaus.groovy.ast.expr.*;
import org.codehaus.groovy.ast.stmt.BlockStatement;
import org.codehaus.groovy.ast.stmt.ExpressionStatement;
import org.codehaus.groovy.ast.stmt.Statement;
-import org.codehaus.groovy.grails.compiler.injection.GrailsASTUtils;
import org.codehaus.groovy.grails.web.pages.GroovyPage;
import org.codehaus.groovy.grails.web.util.GrailsPrintWriter;
import org.codehaus.groovy.syntax.Token;
@@ -23,9 +25,9 @@
*/
class GroovyPageOptimizerVisitor extends CodeVisitorSupport {
- private static final ClassNode groovyPageClassNode = ClassHelper.make(GroovyPage.class).getPlainNodeReference();
+ private static final ClassNode groovyPageClassNode = new ClassNode(GroovyPage.class);
private static final MethodNode writerMethodNode = new ClassNode(GrailsPrintWriter.class).getMethod("print",
- new Parameter[]{new Parameter(GrailsASTUtils.OBJECT_CLASS, "obj")});
+ new Parameter[]{new Parameter(new ClassNode(Object.class), "obj")});
private static final String THIS_RECEIVER = "this";
private static final String THISOBJECT = "thisObject";
View
15 .../src/ast/groovy/org/codehaus/groovy/grails/compiler/web/taglib/TagLibraryTransformer.java
@@ -15,6 +15,8 @@
*/
package org.codehaus.groovy.grails.compiler.web.taglib;
+import groovy.lang.Closure;
+
import java.lang.reflect.Modifier;
import java.net.URL;
import java.util.ArrayList;
@@ -40,7 +42,6 @@
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.grails.compiler.injection.AbstractGrailsArtefactTransformer;
import org.codehaus.groovy.grails.compiler.injection.AstTransformer;
-import org.codehaus.groovy.grails.compiler.injection.GrailsASTUtils;
import org.codehaus.groovy.grails.io.support.GrailsResourceUtils;
import org.codehaus.groovy.grails.plugins.web.api.TagLibraryApi;
import org.codehaus.groovy.grails.web.pages.GroovyPage;
@@ -61,14 +62,14 @@
private static final String ATTRS_ARGUMENT = "attrs";
private static final String BODY_ARGUMENT = "body";
private static final Parameter[] MAP_CLOSURE_PARAMETERS = new Parameter[] {
- new Parameter(GrailsASTUtils.MAP_CLASS, ATTRS_ARGUMENT),
- new Parameter(GrailsASTUtils.CLOSURE_CLASS, BODY_ARGUMENT) };
+ new Parameter(new ClassNode(Map.class), ATTRS_ARGUMENT),
+ new Parameter(new ClassNode(Closure.class), BODY_ARGUMENT) };
private static final Parameter[] CLOSURE_PARAMETERS = new Parameter[] {
- new Parameter(GrailsASTUtils.CLOSURE_CLASS, BODY_ARGUMENT) };
+ new Parameter(new ClassNode(Closure.class), BODY_ARGUMENT) };
private static final Parameter[] MAP_PARAMETERS = new Parameter[] {
- new Parameter(GrailsASTUtils.MAP_CLASS, ATTRS_ARGUMENT) };
+ new Parameter(new ClassNode(Map.class), ATTRS_ARGUMENT) };
private static final Parameter[] MAP_CHARSEQUENCE_PARAMETERS = new Parameter[] {
- new Parameter(GrailsASTUtils.MAP_CLASS, ATTRS_ARGUMENT),
+ new Parameter(new ClassNode(Map.class), ATTRS_ARGUMENT),
new Parameter(new ClassNode(CharSequence.class), BODY_ARGUMENT) };
private static final ClassNode GROOVY_PAGE_CLASS_NODE = new ClassNode(GroovyPage.class);
private static final VariableExpression ATTRS_EXPRESSION = new VariableExpression(ATTRS_ARGUMENT);
@@ -78,7 +79,7 @@
"currentRequestAttributes", ZERO_ARGS);
private static final Expression NULL_EXPRESSION = new ConstantExpression(null);
private static final String NAMESPACE_PROPERTY = "namespace";
- private static final ClassNode CLOSURE_CLASS_NODE = GrailsASTUtils.CLOSURE_CLASS;
+ private static final ClassNode CLOSURE_CLASS_NODE = new ClassNode(Closure.class);
@Override
public Class<?> getInstanceImplementation() {
View
3 ...metypes/src/main/groovy/org/codehaus/groovy/grails/compiler/web/MimeTypesTransformer.java
@@ -36,7 +36,6 @@
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.grails.commons.ControllerArtefactHandler;
import org.codehaus.groovy.grails.compiler.injection.AstTransformer;
-import org.codehaus.groovy.grails.compiler.injection.GrailsASTUtils;
import org.codehaus.groovy.grails.compiler.injection.GrailsArtefactClassInjector;
import org.codehaus.groovy.grails.io.support.GrailsResourceUtils;
import org.codehaus.groovy.grails.plugins.web.api.ControllersMimeTypesApi;
@@ -54,7 +53,7 @@
GrailsResourceUtils.GRAILS_APP_DIR + "/controllers/(.+)Controller\\.groovy");
public static final String FIELD_MIME_TYPES_API = "mimeTypesApi";
- public static final Parameter[] CLOSURE_PARAMETER = new Parameter[]{ new Parameter(GrailsASTUtils.CLOSURE_CLASS, "callable")};
+ public static final Parameter[] CLOSURE_PARAMETER = new Parameter[]{ new Parameter(new ClassNode(Closure.class), "callable")};
public static final String WITH_FORMAT_METHOD = "withFormat";
public void performInjection(SourceUnit source, GeneratorContext context, ClassNode classNode) {
View
7 ...rc/main/groovy/org/codehaus/groovy/grails/compiler/injection/test/MockTransformation.java
@@ -17,7 +17,10 @@
import grails.test.mixin.Mock;
-import org.codehaus.groovy.ast.*;
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.AnnotatedNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.expr.ClassExpression;
import org.codehaus.groovy.ast.expr.Expression;
import org.codehaus.groovy.ast.expr.ListExpression;
@@ -35,7 +38,7 @@
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
public class MockTransformation extends TestForTransformation {
- private static final ClassNode MY_TYPE = ClassHelper.make(Mock.class).getPlainNodeReference();
+ private static final ClassNode MY_TYPE = new ClassNode(Mock.class);
private static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();
@Override
View
8 ...main/groovy/org/codehaus/groovy/grails/compiler/injection/test/TestForTransformation.java
@@ -71,7 +71,7 @@
@SuppressWarnings("rawtypes")
public class TestForTransformation extends TestMixinTransformation {
- private static final ClassNode MY_TYPE = ClassHelper.make(TestFor.class).getPlainNodeReference();
+ private static final ClassNode MY_TYPE = new ClassNode(TestFor.class);
private static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();
private static final Token ASSIGN = Token.newSymbol("=", -1, -1);
@@ -85,11 +85,11 @@
}
public static final String DOMAIN_TYPE = "Domain";
- public static final ClassNode BEFORE_CLASS_NODE = ClassHelper.make(Before.class).getPlainNodeReference();
+ public static final ClassNode BEFORE_CLASS_NODE = new ClassNode(Before.class);
public static final AnnotationNode BEFORE_ANNOTATION = new AnnotationNode(BEFORE_CLASS_NODE);
- public static final AnnotationNode TEST_ANNOTATION = new AnnotationNode(ClassHelper.make(Test.class).getPlainNodeReference());
- public static final ClassNode GROOVY_TEST_CASE_CLASS = ClassHelper.make(GroovyTestCase.class).getPlainNodeReference();
+ public static final AnnotationNode TEST_ANNOTATION = new AnnotationNode(new ClassNode(Test.class));
+ public static final ClassNode GROOVY_TEST_CASE_CLASS = new ClassNode(GroovyTestCase.class);
private ResourceLocator resourceLocator;
View
6 ...in/groovy/org/codehaus/groovy/grails/compiler/injection/test/TestMixinTransformation.java
@@ -48,16 +48,16 @@
*/
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
public class TestMixinTransformation implements ASTTransformation{
- public static final AnnotationNode MIXIN_METHOD_ANNOTATION = new AnnotationNode(ClassHelper.make(MixinMethod.class));
- private static final ClassNode MY_TYPE = ClassHelper.make(TestMixin.class).getPlainNodeReference();
+ public static final AnnotationNode MIXIN_METHOD_ANNOTATION = new AnnotationNode(new ClassNode(MixinMethod.class));
+ private static final ClassNode MY_TYPE = new ClassNode(TestMixin.class);
private static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();
public static final String OBJECT_CLASS = "java.lang.Object";
public static final String SPEC_CLASS = "spock.lang.Specification";
private static final String JUNIT3_CLASS = "junit.framework.TestCase";
public static final String SET_UP_METHOD = "setUp";
public static final VariableExpression THIS_EXPRESSION = new VariableExpression("this");
public static final String TEAR_DOWN_METHOD = "tearDown";
- public static final ClassNode GROOVY_OBJECT_CLASS_NODE = ClassHelper.make(GroovyObjectSupport.class).getPlainNodeReference();
+ public static final ClassNode GROOVY_OBJECT_CLASS_NODE = new ClassNode(GroovyObjectSupport.class);
public void visit(ASTNode[] astNodes, SourceUnit source) {
if (!(astNodes[0] instanceof AnnotationNode) || !(astNodes[1] instanceof AnnotatedNode)) {
View
11 grails-plugin-validation/src/main/groovy/grails/validation/DefaultASTValidateableHelper.java
@@ -24,7 +24,6 @@
import org.codehaus.groovy.ast.stmt.Statement;
import org.codehaus.groovy.grails.compiler.injection.ASTErrorsHelper;
import org.codehaus.groovy.grails.compiler.injection.ASTValidationErrorsHelper;
-import org.codehaus.groovy.grails.compiler.injection.GrailsASTUtils;
import org.codehaus.groovy.grails.web.plugins.support.ValidationSupport;
import org.codehaus.groovy.syntax.Token;
import org.codehaus.groovy.syntax.Types;
@@ -33,7 +32,7 @@
private static final String CONSTRAINED_PROPERTIES_PROPERTY_NAME = "constrainedProperties";
private static final String VALIDATE_METHOD_NAME = "validate";
- private static final VariableExpression THIS_EXPRESSION = GrailsASTUtils.THIS_EXPRESSION;
+ private static final VariableExpression THIS_EXPRESSION = new VariableExpression("this");
public void injectValidateableCode(ClassNode classNode) {
ASTErrorsHelper errorsHelper = new ASTValidationErrorsHelper();
@@ -44,7 +43,7 @@ public void injectValidateableCode(ClassNode classNode) {
protected void addConstrainedPropertiesProperty(final ClassNode classNode) {
classNode.addProperty(CONSTRAINED_PROPERTIES_PROPERTY_NAME,
- Modifier.STATIC | Modifier.PUBLIC, GrailsASTUtils.OBJECT_CLASS,
+ Modifier.STATIC | Modifier.PUBLIC, new ClassNode(Object.class),
null, null, null);
final Expression nullOutConstrainedPropertiesExpression = new BinaryExpression(
new VariableExpression(CONSTRAINED_PROPERTIES_PROPERTY_NAME),
@@ -56,7 +55,7 @@ protected void addConstrainedPropertiesProperty(final ClassNode classNode) {
protected void addValidateMethod(final ClassNode classNode) {
String fieldsToValidateParameterName = "$fieldsToValidate";
- final MethodNode listArgValidateMethod = classNode.getMethod(VALIDATE_METHOD_NAME, new Parameter[]{new Parameter(GrailsASTUtils.LIST_CLASS, fieldsToValidateParameterName)});
+ final MethodNode listArgValidateMethod = classNode.getMethod(VALIDATE_METHOD_NAME, new Parameter[]{new Parameter(new ClassNode(List.class), fieldsToValidateParameterName)});
if (listArgValidateMethod == null) {
final BlockStatement validateMethodCode = new BlockStatement();
final ArgumentListExpression validateInstanceArguments = new ArgumentListExpression();
@@ -65,7 +64,7 @@ protected void addValidateMethod(final ClassNode classNode) {
final ClassNode validationSupportClassNode = new ClassNode(ValidationSupport.class);
final StaticMethodCallExpression invokeValidateInstanceExpression = new StaticMethodCallExpression(validationSupportClassNode, "validateInstance", validateInstanceArguments);
validateMethodCode.addStatement(new ExpressionStatement(invokeValidateInstanceExpression));
- final Parameter fieldsToValidateParameter = new Parameter(GrailsASTUtils.LIST_CLASS, fieldsToValidateParameterName);
+ final Parameter fieldsToValidateParameter = new Parameter(new ClassNode(List.class), fieldsToValidateParameterName);
classNode.addMethod(new MethodNode(
VALIDATE_METHOD_NAME, Modifier.PUBLIC, new ClassNode(Boolean.class),
new Parameter[]{fieldsToValidateParameter}, EMPTY_CLASS_ARRAY, validateMethodCode));
@@ -75,7 +74,7 @@ protected void addValidateMethod(final ClassNode classNode) {
final BlockStatement validateMethodCode = new BlockStatement();
final ArgumentListExpression validateInstanceArguments = new ArgumentListExpression();
- validateInstanceArguments.addExpression(new CastExpression(GrailsASTUtils.LIST_CLASS, new ConstantExpression(null)));
+ validateInstanceArguments.addExpression(new CastExpression(new ClassNode(List.class), new ConstantExpression(null)));
final Expression callListArgValidateMethod = new MethodCallExpression(THIS_EXPRESSION, VALIDATE_METHOD_NAME, validateInstanceArguments);
validateMethodCode.addStatement(new ReturnStatement(callListArgValidateMethod));
classNode.addMethod(new MethodNode(
View
9 ...ain/groovy/org/codehaus/groovy/grails/compiler/validation/ValidateableTransformation.java
@@ -3,7 +3,10 @@
import grails.validation.ASTValidateableHelper;
import grails.validation.DefaultASTValidateableHelper;
-import org.codehaus.groovy.ast.*;
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.AnnotatedNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.control.CompilePhase;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.transform.ASTTransformation;
@@ -12,8 +15,8 @@
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
public class ValidateableTransformation implements ASTTransformation{
- private static final ClassNode ORIGINAL_VALIDATEABLE_CLASS_NODE = ClassHelper.make(org.codehaus.groovy.grails.validation.Validateable.class).getPlainNodeReference();
- private static final ClassNode NEW_VALIDATEABLE_CLASS_NODE = ClassHelper.make(grails.validation.Validateable.class).getPlainNodeReference();
+ private static final ClassNode ORIGINAL_VALIDATEABLE_CLASS_NODE = new ClassNode(org.codehaus.groovy.grails.validation.Validateable.class);
+ private static final ClassNode NEW_VALIDATEABLE_CLASS_NODE = new ClassNode(grails.validation.Validateable.class);
public void visit(ASTNode[] astNodes, SourceUnit source) {

0 comments on commit d4bbbda

Please sign in to comment.
Something went wrong with that request. Please try again.