redhat-developer / quarkus-ls

Language server for Quarkus tooling
Eclipse Public License 2.0
42 stars 15 forks source link

CodeAction for generate @TemplateData #532

Open angelozerr opened 2 years ago

angelozerr commented 2 years ago

Today completion validation etc provide fields methods from java type by using java reflection.

I wonder if we should have à settings like reflectionValueResolver set to true by default.

When this settings will be set to false completion validation will provide only fields and methods annotated with @TemplateData.

We could provide a quickfix for the methods and fields which are used in the template but not annotated, to insert in the java file the proper TemplateData annotation.

@mkouba what do you think about this idea?

mkouba commented 2 years ago

Today completion validation etc provide fields methods from java type by using java reflection.

Note that reflection resolver does not work for native images unless the relevant java type is registered for reflection (e.g. via @RegisterForReflection).

When this settings will be set to false completion validation will provide only fields and methods annotated with @templatedata.

We should not forget about template extension methods...

We could provide a quickfix for the methods and fields which are used in the template but not annotated, to insert in the java file the proper TemplateData annotation.

Sounds reasonable... but we'll need to make sure all value resolvers are counted, i.e. reflection + existing @TemplateData + @TemplateExtension and also @TemplateEnum and @TemplateGlobal from quarkus 2.7+.

angelozerr commented 2 years ago

Thanks for your relevant information @mkouba

IMHO I think it's important to have a settings liek reflectionValueResolver = true or perhaps a better name should be nativeImagesMode = false to understand why Quarkus application in runtime can work but not in native images.

The Qute validator can be a perfect feature to understand what the user must to fix to run a Quarkus application in native images.

Do you like this idea @mkouba ? Do you think it's an important feature?

mkouba commented 2 years ago

Do you like this idea? Do you think it's an important feature?

Hm, the problem is that a quarkus app can target multiple runtimes (JVM, native image). OTOH if an app runs ok in native mode then it should be safe to run the app in JVM. So an option like this probably makes sense. In other words, if nativeImages=true then just ignore the reflection value resolver...