Skip to content
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

Zero-arg queries in java are not detected as publisher #294

Open
CodeDrivenMitch opened this issue Oct 2, 2024 · 1 comment
Open

Zero-arg queries in java are not detected as publisher #294

CodeDrivenMitch opened this issue Oct 2, 2024 · 1 comment

Comments

@CodeDrivenMitch
Copy link
Member

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
    }
}
@CodeDrivenMitch
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant