errael commented on a change in pull request #2333:
URL: https://github.com/apache/netbeans/pull/2333#discussion_r480389978
##########
File path:
javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/beans/BeanModelBuilder.java
##########
@@ -310,6 +310,78 @@ private void processGetters() {
addMapProperty(m, n);
}
}
+ if (allProperties.isEmpty() && !resultInfo.isFxInstance()) {
+ processGettersCheckForImmutables();
+ }
+ }
+
+ private static final String NAMED_ARG = "javafx.beans.NamedArg";
+
+ /** Some javafx classes, such as Insets, are immutable and do not have
+ * no argument constructors or setters; so they are not found.
+ * Accept a property if there is a getter with a corresponding
+ * constructor param declared with NamedArg annotation; use constructor
+ * with the most NamedArg parameters.
+ * <p/>
+ * One alternate strategy would be to provide a document with lines like:
+ * "Insets: top bottom left right" and use this info.
+ */
+ private void processGettersCheckForImmutables() {
+ Set<String> propsConstructor = Collections.emptySet();
+ Set<String> props1 = new HashSet<>();
+ CHECK_CONSTR: for (ExecutableElement c :
ElementFilter.constructorsIn(classElement.getEnclosedElements())) {
+ props1.clear();
+
+ CHECK_PARAMS: for (VariableElement p : c.getParameters()) {
+ for (AnnotationMirror am : p.getAnnotationMirrors()) {
+ if (NAMED_ARG.equals(am.getAnnotationType().toString())) {
+ String prop =
am.getElementValues().values().iterator().next().toString();
Review comment:
I looked around, but I didn't see it... Here's what I'm looking at now
```
if (am.getAnnotationType().asElement().equals(
compilationInfo.getElements().getTypeElement(NAMED_ARG))) {
for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry
: am.getElementValues().entrySet()) {
if (entry.getKey().getSimpleName().toString().equals("value")) {
props1.add((String)entry.getValue().getValue());
continue CHECK_PARAMS;
}
}
```
I looked around for some way to do `am.getElementValues().get(keyForValue)`,
but couldn't see a way to get the key.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists