use of grails.compiler.ast.ClassInjector in project grails-core by grails.
the class GrailsAwareInjectionOperation method call.
@Override
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException {
URL url = null;
final String filename = source.getName();
Resource resource = new FileSystemResource(filename);
if (resource.exists()) {
try {
url = resource.getURL();
} catch (IOException e) {
// ignore
}
}
ClassInjector[] classInjectors1 = getLocalClassInjectors();
if (classInjectors1 == null || classInjectors1.length == 0) {
classInjectors1 = getClassInjectors();
}
for (ClassInjector classInjector : classInjectors1) {
if (classInjector.shouldInject(url)) {
classInjector.performInjection(source, context, classNode);
}
}
}
use of grails.compiler.ast.ClassInjector in project grails-core by grails.
the class ArtefactTypeAstTransformation method performInjection.
public static void performInjection(SourceUnit sourceUnit, ClassNode cNode, Collection<ClassInjector> injectors) {
try {
for (ClassInjector injector : injectors) {
if (!GrailsASTUtils.isApplied(cNode, injector.getClass())) {
GrailsASTUtils.markApplied(cNode, injector.getClass());
injector.performInjectionOnAnnotatedClass(sourceUnit, cNode);
}
}
} catch (RuntimeException e) {
try {
GrailsConsole.getInstance().error("Error occurred calling AST injector: " + e.getMessage(), e);
} catch (Throwable t) {
// ignore it
}
throw e;
}
}
use of grails.compiler.ast.ClassInjector in project grails-core by grails.
the class ArtefactTypeAstTransformation method performInjectionOnArtefactType.
public void performInjectionOnArtefactType(SourceUnit sourceUnit, ClassNode cNode, String artefactType) {
List<ClassInjector> injectors = findInjectors(artefactType, GrailsAwareInjectionOperation.getClassInjectors());
for (ClassInjector injector : injectors) {
if (injector instanceof CompilationUnitAware) {
((CompilationUnitAware) injector).setCompilationUnit(this.compilationUnit);
}
}
performInjection(sourceUnit, cNode, injectors);
}
Aggregations