IntelliJ warnings unaware of GUI forms

已回答

IntelliJ's warning system seems to be out of sync with GUI Designer forms

Here's an example. Even though `_tableList` will be initialized in the generated `$$$setupUI()$$$` method, I get a warning that invoking methods on it may produce NPE (it may not)

It's happening because IntelliJ can't figure out that `initFields()` is invoked from the constructor, after the invocation of the generated method

If I move it to the constructor, the warning disappears

Our init code is not in the constructor directly because a static analysis tool that we use doesn't not about GUI designer forms and complains if we invoke methods on fields that weren't explicitly initialized beforehand

Here's another example. `searchSource` is indeed not used in the code below, but the binding in the associated GUI form helps making the purpose of that element explicit


Otherwise, the element would be labeled with its class name

Generate GUI into: Binary class files (not going to change it)

IntelliJ IDEA 2024.1 (Community Edition)
Build #IC-241.14494.240, built on March 28, 2024
Runtime version: 17.0.10+8-b1207.12 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 4
Registry:
 ide.experimental.ui=true
Non-Bundled Plugins:
 Lombook Plugin (241.14494.240)
 AntSupport (241.14494.158)
Kotlin: 241.14494.240-IJ

0

Could you please share a sample project to try and reproduce the issue on our end? You can upload it here: https://uploads.jetbrains.com , just provide the uploaded file ID. Thanks!

0

请先登录再写评论。