Search in sources :

Example 1 with GrailsDomainClassInjector

use of grails.compiler.ast.GrailsDomainClassInjector in project grails-core by grails.

the class EntityASTTransformation method applyTransformation.

public void applyTransformation(SourceUnit sourceUnit, ClassNode classNode) {
    if (GrailsASTUtils.isApplied(classNode, EntityASTTransformation.class)) {
        return;
    }
    GrailsASTUtils.markApplied(classNode, EntityASTTransformation.class);
    GrailsDomainClassInjector domainInjector = new DefaultGrailsDomainClassInjector();
    domainInjector.performInjectionOnAnnotatedEntity(classNode);
    ClassInjector[] classInjectors = GrailsAwareInjectionOperation.getClassInjectors();
    final List<ClassInjector> domainInjectors = ArtefactTypeAstTransformation.findInjectors(DomainClassArtefactHandler.TYPE, classInjectors);
    for (ClassInjector injector : domainInjectors) {
        try {
            injector.performInjection(sourceUnit, classNode);
        } catch (RuntimeException e) {
            try {
                System.err.println("Error occurred calling AST injector [" + injector.getClass().getName() + "]: " + e.getMessage());
            } catch (Throwable t) {
            // ignore
            }
            throw e;
        }
    }
    if (compilationUnit != null) {
        TraitInjectionUtils.processTraitsForNode(sourceUnit, classNode, DomainClassArtefactHandler.TYPE, compilationUnit);
    }
}
Also used : GrailsDomainClassInjector(grails.compiler.ast.GrailsDomainClassInjector) GrailsDomainClassInjector(grails.compiler.ast.GrailsDomainClassInjector) ClassInjector(grails.compiler.ast.ClassInjector)

Aggregations

ClassInjector (grails.compiler.ast.ClassInjector)1 GrailsDomainClassInjector (grails.compiler.ast.GrailsDomainClassInjector)1