IdeaPlugin
IdeaPlugin copied to clipboard
Zero-arg queries in java are not detected as publisher
Basic information
- Plugin version: 0.8.8
Steps to reproduce
- Have a zero-argument java class used as query
- Dispatch it somewhere on the QueryGateway
- Open the handler line marker to see places where it's being created
Expected behaviour
The popup contains the place the query is published
Actual behaviour
The popup is not there. It seems the IDEA SDK does not detect a zero-arg constructor as an actual constructor, as this test fails:
fun `test resolves zero-arg constructor as creator too in java`() {
addFile("MyZeroArgQuery.java", """
public class MyZeroArgQuery {
}
""".trimIndent())
addFile(
"MyQueryPublisher.java", """
import test.MyZeroArgQuery;
class MyQueryPublisher {
private final QueryGateway queryGateway;
public MyQueryPublisher(QueryGateway queryGateway) {
this.queryGateway = queryGateway;
}
public void publish() {
queryGateway.query(new MyZeroArgQuery(), String.class);
}
}
""".trimIndent(), open = true
)
val creators = project.creatorResolver().getCreatorsForPayload("test.MyZeroArgQuery")
Assertions.assertThat(creators).anyMatch {
it.payload == "test.MyZeroArgQuery" &&
it.renderText() == "MyQueryPublisher.publish"
it.renderContainerText() == null
}
}
I have been unable to resolve this issue, as neither the Psi nor UAST sees the constructor for Java. For Kotlin it works. Posted a question to Jetbrains for clarification.