manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.42k stars 125 forks source link

When using param in manifold-templates, Idea reports that param may not have been initialized #588

Closed moheng233 closed 6 months ago

moheng233 commented 6 months ago

Describe the bug When using param in manifold-templates, Idea reports that param may not have been initialized

To Reproduce I used the following code to demonstrate the bug

<%@ params(String param1) %>

Hello ${param1} test

<%if (param1 == "1") {%>
<%}%>

Such code will report an error in idea: param1 may not be initialized. Although the compilation is fine, the idea's error reporting still affects the enjoyment of the development.

Screenshots image

I'm Chinese for this, so please don't mind my Chinese screenshots. But the reported error is the same as described above.

Desktop:

rsmckinney commented 6 months ago

Hi @moheng233. Sorry for the wait. This issue is specific to the Chinese (Simplified) Language Pack / 中文语言包. Manifold has a lot of the Chinese translations covered, but still more to go. This issue will be fixed along with many other translation related fixes within a couple of days when the next Manifold IntelliJ plugin is released. Thanks for your patience.

moheng233 commented 6 months ago

Hi @rsmckinney, thank you for your reply, but I realized that the language pack is not the cause of the error, because when I uninstalled the language pack, it still had the error. image

rsmckinney commented 6 months ago

I can't reproduce this. Although, the sample you have will produce a different error because your template example uses a statement, but should instead use an expression: use <%= param1 %> or ${param1}.

In any case, regarding the Chinese lang pack use, I am positive that's the cause of the error. Lang pack related changes are ready that will be included in the next plugin release tomorrow.

moheng233 commented 6 months ago

I appreciate your response. I will await the next iteration of the software, as I am particularly interested in your work. It is encouraging to see improvements being made to the shortcomings of Java, and it is also beneficial to note that it works well with lombok.

rsmckinney commented 6 months ago

Nice to hear, thank you very much.

rsmckinney commented 6 months ago

Fix available with latest plugin release.

Here you can see a sample template file open with Chinese Language Pack installed. Notice no errors on the param reference.

image