New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support diagramming of any function #35
Comments
@bnorm , have you explored the possibility of annotation-based configuration? That enables designing APIs that are usable with and without the compiler plugin.
It might go as an annotation on top of For instance: class Assert {
@ReplaceWith(target="assertEqualsWithDiagram")
void assertEquals(Object a, Object b) { ... }
void assertEqualsWithDiagram(
Object a,
Object b,
@CallDiagram
String diagram
) { ... } Of course, having text-like configuration when library author does not use annotations might be helpful, however, it would be nice to come up with a way that could be integrated into the libraries.
You probably need several plugins:
It is fine to have several Gradle plugins within a single Jar, however, shipping several plugins would make it easier for the users to opt-out of the plugin settings. |
I've filed a request to see what JUnit folks think of adding annotations to support diagram-like cases: junit-team/junit5#3176 WDYT of creating an umbrella organization like https://github.com/argument-expression-4j-team (or whatever name) to house projects like |
Yes, actually! This idea was suggested to me and I think is probably the best way to go. I'd still like to support specifying functions via the Gradle configuration - for simple cases at least - as that will be important if you use a library which can't or doesn't natively integrate with the kotlin-power-assert support library (Kotlin assert, JUnit, etc). But I'm hoping to start work on this soon as it is yet another part of #45.
I'm happy to consume something like that but doubt I have the time to sufficiently support and start such an initiative. I'll watch those tickets though to stay up-to-date with the conversation. |
Right now this compiler plugin supports diagramming a function if it can be called with parameters of either the following 2 forms:
function(Boolean, String)
function(Boolean, () -> String)
The plugin also supports diagramming of a function of the form
function(Boolean)
as long as it has an overload of one of the above forms.The reason for this is because the plugin transforms the function call to include the diagrammed source code in the supplied
String
parameter. Something like the following......is transformed into something like...
The
Boolean
parameter of the function is not very significant; only the parameter which takes the function diagram is important. For example, a function of the formfunction(Any, Any, String)
could be diagrammed if the compiler plugin understood that the function diagram can be appended to theString
parameter. However, the placement of thisString
parameter could differ from function to function which makes support of any function more challenging.Because of this, to support diagramming of any function, a syntax will need to be created to describe to the compiler plugin a supported function and which parameter the function diagram should be appended. For example, an pattern might be something like the following:
Open questions about possible syntax:
And one final question: Should the name of this compiler plugin be changed if/when support for diagramming any function lands?
The text was updated successfully, but these errors were encountered: