Skip to content

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

Description

@CodeDrivenMitch

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
    }
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions