netbeans
netbeans copied to clipboard
syntax check in javafx fxml file is reporting 'does not support property' in KeyCodeCombination
Apache NetBeans version
Apache NetBeans 22
What happened
had scenebuilder create a fxml file. opened file in netbeans. netbeans indicated errors in file.
class 'javafx.scene.input.KeyCodeCombination' does not support property 'alt'. also for 'control' 'meta' 'shift' 'shortcut'.
Language / Project Type / NetBeans Component
javafx
How to reproduce
create stage with menubar with menuitem with shortcut in scenebuilder. open fxml file in netbeans.
Did this work correctly in an earlier version?
No / Don't know
Operating System
ubuntu linux mate hybrid
JDK
version "21.0.3" 2024-04-16 build 21.0.3+9-Ubuntu-1ubuntu122.04.1
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
always.
Are you willing to submit a pull request?
No
Used version scenebuilder
21.0.0
Used version javafx
javafx 21
Please provide a sample to make this reproducible.
looking at org.netbeans.modules.javafx2.editor.parser.processors.PropertyResolver and the behaviour in this case, it looks (a bit of a gamble) that the PropertyResolver gets confused due to KeyCodeCombination not having property setters for the properties report as in error.
i have not yet found a mechanism to scan for parameters in the constructors. if there are (it should be) then it is a case the wrong constructor was chosen. this is also supported by the fact that 'code' is not reported as an error. the other constructor had 'code' and 'modifiers' as NamedArg.
https://github.com/apache/netbeans/blob/0d0bfcf3faf364a2643238f2a44e1bb6eb8217bd/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/parser/processors/PropertyResolver.java#L269-L298
My reading of the BeanModelBuilder is, that properties are reported when:
- there is a setter
- there is a list/map getter
- there is a getter with a corresponding
@NamedArgparameter in the constructor with the most parameters
For KeyCodeCombination there are no getters for the individual keys and thus the third option does not match.
If I understand this correctly: https://github.com/openjdk/jfx/blob/6a586b662592be3eb81670f0c5ce48061c2fc07c/modules/javafx.fxml/src/main/java/com/sun/javafx/fxml/builder/ProxyBuilder.java#L248
- JFX prefers to use an exactly matching constructor for the supplied parameters
- if there is a default constructor and all supplied property values are covered by setters, this combination is used
- else try to find a suitable constructor/setters combination to cover all parameters
I think the model needs to be updated to report the constructor parameters as a separate list and the use sited of the property need to take this into account.
The code for scanning the constructors with NamedArgs:
https://github.com/apache/netbeans/blob/02c66120a8d5c90cde4c706bb15e7121372fd513/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/beans/BeanModelBuilder.java#L336-L357
looks like a good starting point. The name extraction is demonstrated there. The code in registerProperty for normal setter can be a template for extracting the type information.
https://github.com/apache/netbeans/blob/02c66120a8d5c90cde4c706bb15e7121372fd513/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/beans/BeanModelBuilder.java#L580-L586
@sijskes will you look into this?
@matthiasblaesing ideally there should be an InfoProxy that is reusable in the BeanModelBuilder and the PropertyResolver. This InfoProxy could mimic the information/logic from the JavaFx ProxyBuilder. I have a hard time following the javax.lang.model stuff, just by code inspection alone. I would assign some meaning by wrapping it in this InfoProxy. This InfoProxy could deliver information in <Name,Type> pairs and support 'completion-path' matching? Later this could grow to provide information regarding child elements.
@errael any insights to share? it looks like you worked on the completion.
Maybe FxBean is already the InfoProxy i'm talking about. Have to look if it is usable without completion code plumbing.