Package com.axelor.script
Class GroovyCheckPropTransformation
java.lang.Object
org.codehaus.groovy.transform.AbstractASTTransformation
com.axelor.script.GroovyCheckPropTransformation
- All Implemented Interfaces:
org.codehaus.groovy.transform.ASTTransformation,org.codehaus.groovy.transform.ErrorCollecting
public class GroovyCheckPropTransformation
extends org.codehaus.groovy.transform.AbstractASTTransformation
A custom Groovy AST transformer to validate property accesses against the policy settings.
This is done at a compile phase when local variables and class names are resolved: before, a
qualified class name (com.axelor.example.Foo) is still a chain of properties.
For example:
def value = foo.bar def value2 = com.axelor.example.Foo.BAR def value3 = foo.bar.bazwould become:
def value = GroovySandbox.checkProperty(foo, 'bar').bar def value2 = GroovySandbox.checkProperty(com.axelor.example.Foo, 'BAR').BAR def value3 = GroovySandbox.checkProperty(GroovySandbox.checkProperty(foo, 'bar').bar, 'baz').baz
The compiler also turns a call of a local variable (x()) into a call of its
call method (x.call()) in this phase, after GroovyCheckTransformation checked
the receiver of x(): the variable is checked here instead.
-
Field Summary
Fields inherited from class org.codehaus.groovy.transform.AbstractASTTransformation
RETENTION_CLASSNODE, sourceUnit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvisit(org.codehaus.groovy.ast.ASTNode[] nodes, org.codehaus.groovy.control.SourceUnit source) Methods inherited from class org.codehaus.groovy.transform.AbstractASTTransformation
addError, checkIncludeExcludeUndefinedAware, checkIncludeExcludeUndefinedAware, checkNotInterface, checkPropertyList, checkPropertyList, checkPropertyList, copyAnnotatedNodeAnnotations, copyAnnotatedNodeAnnotations, deemedInternalName, getAnnotationName, getMemberClassList, getMemberClassValue, getMemberClassValue, getMemberIntValue, getMemberStringList, getMemberStringValue, getMemberStringValue, getMemberValue, hasAnnotation, init, memberHasValue, shouldSkip, shouldSkip, shouldSkipOnDescriptorUndefinedAware, shouldSkipUndefinedAware, shouldSkipUndefinedAware, tokenize
-
Constructor Details
-
GroovyCheckPropTransformation
public GroovyCheckPropTransformation()
-
-
Method Details
-
visit
public void visit(org.codehaus.groovy.ast.ASTNode[] nodes, org.codehaus.groovy.control.SourceUnit source)
-