From 88a82fe62df704042711f75d4bac0a1c834d576d Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 23 Jan 2013 22:34:11 +0400 Subject: [PATCH] javafx: completion of list property tags --- .../fxml/JavaFxClassBackedElementDescriptor.java | 12 +++++++----- .../javaFX/testData/completion/listPropertyTag.fxml | 9 +++++++++ .../testData/completion/listPropertyTag_after.fxml | 9 +++++++++ .../plugins/javaFX/fxml/JavaFxCompletionTest.java | 4 ++++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 plugins/javaFX/testData/completion/listPropertyTag.fxml create mode 100644 plugins/javaFX/testData/completion/listPropertyTag_after.fxml diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxClassBackedElementDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxClassBackedElementDescriptor.java index 99ca633ab2dc..d6aa30d6d9ac 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxClassBackedElementDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxClassBackedElementDescriptor.java @@ -80,14 +80,15 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor, } else if (descriptor instanceof JavaFxPropertyElementDescriptor) { } - if (myPsiClass != null) { + if (myPsiClass != null && descriptor instanceof JavaFxClassBackedElementDescriptor) { final List children = new ArrayList(); - collectProperties(children, new Function() { + collectProperties(children, true, new Function() { @Override public XmlElementDescriptor fun(PsiField field) { return new JavaFxPropertyElementDescriptor(myPsiClass, field.getName(), false); } }); + collectParentStaticProperties(context, children, new Function() { @Override public XmlElementDescriptor fun(PsiMethod method) { @@ -157,7 +158,7 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor, final String name = context.getName(); if (Comparing.equal(name, getName()) && myPsiClass != null) { final List simpleAttrs = new ArrayList(); - collectProperties(simpleAttrs, new Function() { + collectProperties(simpleAttrs, false, new Function() { @Override public XmlAttributeDescriptor fun(PsiField field) { return new JavaFxPropertyAttributeDescriptor(field.getName(), myPsiClass); @@ -175,7 +176,7 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor, return XmlAttributeDescriptor.EMPTY; } - private void collectProperties(List children, Function factory) { + private void collectProperties(List children, boolean includeListProperties, Function factory) { final PsiField[] fields = myPsiClass.getAllFields(); if (fields.length > 0) { for (PsiField field : fields) { @@ -183,7 +184,8 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor, final PsiType fieldType = field.getType(); if (PropertyUtil.findPropertyGetter(myPsiClass, field.getName(), false, true) != null && InheritanceUtil.isInheritor(fieldType, JavaFxCommonClassNames.JAVAFX_BEANS_PROPERTY_PROPERTY) || - fieldType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) { + fieldType.equalsToText(CommonClassNames.JAVA_LANG_STRING) || + includeListProperties && GenericsHighlightUtil.getCollectionItemType(field.getType(), myPsiClass.getResolveScope()) != null) { children.add(factory.fun(field)); } } diff --git a/plugins/javaFX/testData/completion/listPropertyTag.fxml b/plugins/javaFX/testData/completion/listPropertyTag.fxml new file mode 100644 index 000000000000..99f90000e9d4 --- /dev/null +++ b/plugins/javaFX/testData/completion/listPropertyTag.fxml @@ -0,0 +1,9 @@ + + + + + + + + < + \ No newline at end of file diff --git a/plugins/javaFX/testData/completion/listPropertyTag_after.fxml b/plugins/javaFX/testData/completion/listPropertyTag_after.fxml new file mode 100644 index 000000000000..3114b472c34e --- /dev/null +++ b/plugins/javaFX/testData/completion/listPropertyTag_after.fxml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java index 7d7e88e2e7f3..ef8c82ccc956 100644 --- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java +++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java @@ -49,6 +49,10 @@ public class JavaFxCompletionTest extends CompletionTestCase { doTest("text"); } + public void testListPropertyTag() throws Exception { + doTest("children"); + } + public void testStaticPropertiesEnumValue() throws Exception { doTest(); }