apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.59k stars 834 forks source link

syntax check in javafx fxml file is reporting 'does not support property' in KeyCodeCombination #7490

Open sijskes opened 2 weeks ago

sijskes commented 2 weeks ago

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

Screenshot at 2024-06-17 11-22-11 crop

Used version scenebuilder

21.0.0

Used version javafx

javafx 21

matthiasblaesing commented 2 weeks ago

Please provide a sample to make this reproducible.

sijskes commented 2 weeks ago

sample to reproduce.
remove .txt extension, github wouldn't attach without it.

sandbox.fxml.txt

sijskes commented 2 weeks ago

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

matthiasblaesing commented 2 weeks ago

My reading of the BeanModelBuilder is, that properties are reported when:

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

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?

sijskes commented 1 week ago

@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.