diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java index ebd7d50b41da..0d4d2dc0a01b 100644 --- a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java +++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java @@ -129,6 +129,18 @@ public class JavaFxCompletionTest extends LightFixtureCompletionTestCase { doTest("top"); } + public void testPrimitiveSubtags() throws Exception { + myFixture.configureByFiles(getTestName(true) + ".fxml"); + complete(); + assertDoesntContain(myFixture.getLookupElementStrings(), "geomBoundsInvalid"); + } + + public void testDefaultPropertyWrappedField() throws Exception { + myFixture.configureByFiles(getTestName(true) + ".fxml"); + complete(); + assertContainsElements(myFixture.getLookupElementStrings(), "image", "Image"); + } + public void testIncludedRootAttributes() throws Exception { myFixture.addFileToProject("foo.fxml", "\n" + "\n" + diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxClassBackedElementDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxClassBackedElementDescriptor.java index 005e205845c6..66ce96de2390 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxClassBackedElementDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxClassBackedElementDescriptor.java @@ -69,6 +69,11 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor, } }); + final JavaFxPropertyElementDescriptor defaultPropertyDescriptor = getDefaultPropertyDescriptor(); + if (defaultPropertyDescriptor != null) { + Collections.addAll(children, defaultPropertyDescriptor.getElementsDescriptors(context)); + } + collectStaticElementDescriptors(context, children); final PsiType returnType = JavaFxPsiUtil.getDefaultPropertyExpectedType(myPsiClass); @@ -88,6 +93,21 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor, return XmlElementDescriptor.EMPTY_ARRAY; } + private JavaFxPropertyElementDescriptor getDefaultPropertyDescriptor() { + final PsiAnnotation defaultProperty = AnnotationUtil + .findAnnotationInHierarchy(myPsiClass, Collections.singleton(JavaFxCommonClassNames.JAVAFX_BEANS_DEFAULT_PROPERTY)); + if (defaultProperty != null) { + final PsiAnnotationMemberValue defaultPropertyAttributeValue = defaultProperty.findAttributeValue("value"); + if (defaultPropertyAttributeValue instanceof PsiLiteralExpression) { + final Object value = ((PsiLiteralExpression)defaultPropertyAttributeValue).getValue(); + if (value instanceof String) { + return new JavaFxPropertyElementDescriptor(myPsiClass, (String)value, false); + } + } + } + return null; + } + static void collectStaticAttributesDescriptors(@Nullable XmlTag context, List simpleAttrs) { if (context == null) return; collectParentStaticProperties(context.getParentTag(), simpleAttrs, new Function() { @@ -159,18 +179,17 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor, return elementDescriptor; } } else { - final PsiAnnotation defaultProperty = AnnotationUtil - .findAnnotationInHierarchy(myPsiClass, Collections.singleton(JavaFxCommonClassNames.JAVAFX_BEANS_DEFAULT_PROPERTY)); - if (defaultProperty != null) { - final PsiAnnotationMemberValue defaultPropertyAttributeValue = defaultProperty.findAttributeValue("value"); - if (defaultPropertyAttributeValue instanceof PsiLiteralExpression) { - final Object value = ((PsiLiteralExpression)defaultPropertyAttributeValue).getValue(); - if (value instanceof String && ((String)value).equalsIgnoreCase(name) && myPsiClass.findFieldByName(name, true) == null) { - elementDescriptor = null; + final JavaFxPropertyElementDescriptor defaultPropertyDescriptor = getDefaultPropertyDescriptor(); + if (defaultPropertyDescriptor != null) { + final String defaultPropertyName = defaultPropertyDescriptor.getName(); + if (StringUtil.equalsIgnoreCase(defaultPropertyName, name) && !StringUtil.equals(defaultPropertyName, name)) { + final XmlElementDescriptor childDescriptor = defaultPropertyDescriptor.getElementDescriptor(childTag, contextTag); + if (childDescriptor != null) { + return childDescriptor; } } } - if (elementDescriptor != null && elementDescriptor.getDeclaration() != null) { + if (elementDescriptor.getDeclaration() != null) { return elementDescriptor; } } diff --git a/plugins/javaFX/testData/completion/defaultPropertyWrappedField.fxml b/plugins/javaFX/testData/completion/defaultPropertyWrappedField.fxml new file mode 100644 index 000000000000..1670c52bd515 --- /dev/null +++ b/plugins/javaFX/testData/completion/defaultPropertyWrappedField.fxml @@ -0,0 +1,4 @@ + + + < + \ No newline at end of file