Search in sources :

Example 1 with FormalParameterContext

use of org.apache.groovy.parser.antlr4.GroovyParser.FormalParameterContext in project groovy by apache.

the class AstBuilder method transformRecordHeaderToProperties.

private void transformRecordHeaderToProperties(ClassDeclarationContext ctx, ClassNode classNode) {
    Parameter[] parameters = this.visitFormalParameters(ctx.formalParameters());
    classNode.putNodeMetaData(RECORD_HEADER, parameters);
    final int n = parameters.length;
    for (int i = 0; i < n; i += 1) {
        Parameter parameter = parameters[i];
        FormalParameterContext parameterCtx = parameter.getNodeMetaData(PARAMETER_CONTEXT);
        ModifierManager parameterModifierManager = parameter.getNodeMetaData(PARAMETER_MODIFIER_MANAGER);
        ClassNode originType = parameter.getOriginType();
        PropertyNode propertyNode = declareProperty(parameterCtx, parameterModifierManager, originType, classNode, i, parameter, parameter.getName(), parameter.getModifiers(), parameter.getInitialExpression());
        propertyNode.getField().putNodeMetaData(IS_RECORD_GENERATED, Boolean.TRUE);
    }
}
Also used : ClassNode(org.codehaus.groovy.ast.ClassNode) EnumConstantClassNode(org.codehaus.groovy.ast.EnumConstantClassNode) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) PropertyNode(org.codehaus.groovy.ast.PropertyNode) FormalParameterContext(org.apache.groovy.parser.antlr4.GroovyParser.FormalParameterContext) ThisFormalParameterContext(org.apache.groovy.parser.antlr4.GroovyParser.ThisFormalParameterContext) Parameter(org.codehaus.groovy.ast.Parameter)

Aggregations

FormalParameterContext (org.apache.groovy.parser.antlr4.GroovyParser.FormalParameterContext)1 ThisFormalParameterContext (org.apache.groovy.parser.antlr4.GroovyParser.ThisFormalParameterContext)1 ClassNode (org.codehaus.groovy.ast.ClassNode)1 EnumConstantClassNode (org.codehaus.groovy.ast.EnumConstantClassNode)1 InnerClassNode (org.codehaus.groovy.ast.InnerClassNode)1 Parameter (org.codehaus.groovy.ast.Parameter)1 PropertyNode (org.codehaus.groovy.ast.PropertyNode)1