<commit_before>package kotka.gradle.utils

import org.codehaus.groovy.ast.ASTNode
import org.codehaus.groovy.ast.ClassHelper
import org.codehaus.groovy.ast.ClassNode
import org.codehaus.groovy.ast.MethodNode
import org.codehaus.groovy.ast.Parameter
import org.codehaus.groovy.ast.expr.FieldExpression
import org.codehaus.groovy.ast.expr.StaticMethodCallExpression
import org.codehaus.groovy.ast.stmt.ExpressionStatement
import org.codehaus.groovy.control.CompilePhase
import org.codehaus.groovy.control.SourceUnit
import org.codehaus.groovy.transform.ASTTransformation
import org.codehaus.groovy.transform.GroovyASTTransformation

import java.lang.reflect.Modifier

@GroovyASTTransformation(phase=CompilePhase.SEMANTIC_ANALYSIS)
class DelayedTransformation implements ASTTransformation {
    void visit(ASTNode[] nodes, SourceUnit sourceUnit) {
        def fieldNode = nodes[1]
        def getterNode = new MethodNode(
                "get${fieldNode.name.capitalize()}",
                Modifier.PUBLIC,
                fieldNode.type,
                [] as Parameter[],
                [] as ClassNode[],
                new ExpressionStatement(
                        new StaticMethodCallExpression(
                                ClassHelper.make(Delay),
                                "force",
                                new FieldExpression(fieldNode)
                        )
                )
        )

        fieldNode.owner.addMethod getterNode
    }
}<commit_msg>Extract the class node for Delay into local<commit_after>package kotka.gradle.utils

import org.codehaus.groovy.ast.ASTNode
import org.codehaus.groovy.ast.ClassHelper
import org.codehaus.groovy.ast.ClassNode
import org.codehaus.groovy.ast.MethodNode
import org.codehaus.groovy.ast.Parameter
import org.codehaus.groovy.ast.expr.FieldExpression
import org.codehaus.groovy.ast.expr.StaticMethodCallExpression
import org.codehaus.groovy.ast.stmt.ExpressionStatement
import org.codehaus.groovy.control.CompilePhase
import org.codehaus.groovy.control.SourceUnit
import org.codehaus.groovy.transform.ASTTransformation
import org.codehaus.groovy.transform.GroovyASTTransformation

import java.lang.reflect.Modifier

@GroovyASTTransformation(phase=CompilePhase.SEMANTIC_ANALYSIS)
class DelayedTransformation implements ASTTransformation {
    void visit(ASTNode[] nodes, SourceUnit sourceUnit) {
        def delayNode = ClassHelper.make(Delay)
        def fieldNode = nodes[1]
        def getterNode = new MethodNode(
                "get${fieldNode.name.capitalize()}",
                Modifier.PUBLIC,
                fieldNode.type,
                [] as Parameter[],
                [] as ClassNode[],
                new ExpressionStatement(
                        new StaticMethodCallExpression(
                                delayNode,
                                "force",
                                new FieldExpression(fieldNode)
                        )
                )
        )

        fieldNode.owner.addMethod getterNode
    }
}
{'fraction_non_alphanumeric': 0.07816622691292877, 'fraction_numerical': 0.0006596306068601583, 'mean_word_length': 2.4002242152466366, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2275585', 'n_tokens_mistral': 866, 'n_tokens_neox': 793, 'n_words': 134}