JetBrains / java-annotations

Annotations for JVM-based languages.
Apache License 2.0
404 stars 47 forks source link

Annotation for linking (generated) code #71

Open U1F984 opened 2 years ago

U1F984 commented 2 years ago

Example Usecase: when defining a HTTP API and generating client code which maps to it it would be good to have the IDE be able to recognize this, in e.g. Dataflow Analysis.

public class Controller {
    @Get("/foo")
    public String getFoo(String param) { return "foo " + param; }
}
public class GeneratedControllerClient {
    @Calls("org.example.Controller.getFoo(String)")
    public String getFoo(String param) { /* do http call and return server result */ }
}

Optionally the generated client could have additional parameters, e.g. for a callback style invocation, and it would be possible to map e.g. return value of original method to some Consumer<ReturnType> parameter of the call site.