| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| private static List | |
| public List | getClosureSignatures(final MethodNode
the method node for which a node, final SourceUnit groovy. parameter was annotated with
ClosureParamsthe source unit of the file being compiled sourceUnit, final CompilationUnit the compilation unit of the file being compiled compilationUnit, final String[] the options, corresponding to the options, final ASTNode ClosureParams#options() found on the annotation @return a non-null list of signature, where a signature corresponds to an array of class nodes, each of them matching a parameter.the AST node, in the compiled file, which triggered a call to this method. Normally only used for logging/error handling usage)Implements abstract groovy. Subclasses should implement this method, which returns the list of accepted closure signatures. |
| FromAbstractTypeMethods | back to summary |
|---|---|
| public FromAbstractTypeMethods() | |
| extractParametersFromMethod | back to summary |
|---|---|
| private static void extractParametersFromMethod(final List<ClassNode[]> signatures, final MethodNode method) | |
| extractSignaturesFromMethods | back to summary |
|---|---|
| private static List | |
| getClosureSignatures | back to summary |
|---|---|
| public List Implements abstract groovy. Doc from groovy. Subclasses should implement this method, which returns the list of accepted closure signatures. The compiler will call this method each time, in a source file, a method call using a closure
literal is encountered and that the target method has the corresponding @groovy.transform.TypeChecked
void doSomething() {
println ['a','b'].collect { it.toUpperCase() }
}
The collect method accepts a closure, but normally, the type checker doesn't have enough type information
in the sole
Now, the hint instance can return the list of expected parameters. Here, it would have to say that the collect method accepts a closure for which the only argument is of the type of the first generic type of the first argument. With that type information, the type checker can now infer that the type of it is String, because the first argument (here the receiver of the collect method) is a List<String> Subclasses are therefore expected to return the signatures according to the available context, which is only the target method and the potential options.
| |