use of groovy.transform.stc.ClosureSignatureHint in project groovy-core by groovy.
the class StaticTypeCheckingVisitor method getSignaturesFromHint.
private List<ClassNode[]> getSignaturesFromHint(final ClosureExpression expression, final MethodNode selectedMethod, final Expression hintClass, final Expression options) {
// initialize hints
List<ClassNode[]> closureSignatures = null;
try {
ClassLoader transformLoader = getTransformLoader();
@SuppressWarnings("unchecked") Class<? extends ClosureSignatureHint> hint = (Class<? extends ClosureSignatureHint>) transformLoader.loadClass(hintClass.getText());
ClosureSignatureHint hintInstance = hint.newInstance();
closureSignatures = hintInstance.getClosureSignatures(selectedMethod instanceof ExtensionMethodNode ? ((ExtensionMethodNode) selectedMethod).getExtensionMethodNode() : selectedMethod, typeCheckingContext.source, typeCheckingContext.compilationUnit, convertToStringArray(options), expression);
} catch (ClassNotFoundException e) {
throw new GroovyBugError(e);
} catch (InstantiationException e) {
throw new GroovyBugError(e);
} catch (IllegalAccessException e) {
throw new GroovyBugError(e);
}
return closureSignatures;
}
use of groovy.transform.stc.ClosureSignatureHint in project groovy by apache.
the class StaticTypeCheckingVisitor method getSignaturesFromHint.
private List<ClassNode[]> getSignaturesFromHint(final MethodNode mn, final Expression hintType, final Expression options, final ASTNode usage) {
// load hint class using compiler's classloader
String hintTypeName = hintType.getText();
try {
@SuppressWarnings("unchecked") Class<? extends ClosureSignatureHint> hintClass = (Class<? extends ClosureSignatureHint>) getTransformLoader().loadClass(hintTypeName);
List<ClassNode[]> closureSignatures = hintClass.getDeclaredConstructor().newInstance().getClosureSignatures(mn instanceof ExtensionMethodNode ? ((ExtensionMethodNode) mn).getExtensionMethodNode() : mn, typeCheckingContext.getSource(), typeCheckingContext.getCompilationUnit(), convertToStringArray(options), usage);
return closureSignatures;
} catch (ReflectiveOperationException e) {
throw new GroovyBugError(e);
}
}
use of groovy.transform.stc.ClosureSignatureHint in project groovy by apache.
the class StaticTypeCheckingVisitor method getSignaturesFromHint.
private List<ClassNode[]> getSignaturesFromHint(final ClosureExpression expression, final MethodNode selectedMethod, final Expression hintClass, final Expression options) {
// initialize hints
List<ClassNode[]> closureSignatures;
try {
ClassLoader transformLoader = getTransformLoader();
@SuppressWarnings("unchecked") Class<? extends ClosureSignatureHint> hint = (Class<? extends ClosureSignatureHint>) transformLoader.loadClass(hintClass.getText());
ClosureSignatureHint hintInstance = hint.newInstance();
closureSignatures = hintInstance.getClosureSignatures(selectedMethod instanceof ExtensionMethodNode ? ((ExtensionMethodNode) selectedMethod).getExtensionMethodNode() : selectedMethod, typeCheckingContext.source, typeCheckingContext.compilationUnit, convertToStringArray(options), expression);
} catch (ClassNotFoundException e) {
throw new GroovyBugError(e);
} catch (InstantiationException e) {
throw new GroovyBugError(e);
} catch (IllegalAccessException e) {
throw new GroovyBugError(e);
}
return closureSignatures;
}
Aggregations