javafx: do not include default properties in completion twice

(cherry picked from commit cc8af6dba30d01d0bcc5928338eba6b8eb9f9a91)
This commit is contained in:
anna
2013-03-26 21:42:59 +01:00
parent cb0b05343b
commit 7933803b89
3 changed files with 16 additions and 4 deletions
@@ -141,6 +141,13 @@ public class JavaFxCompletionTest extends LightFixtureCompletionTestCase {
assertContainsElements(myFixture.getLookupElementStrings(), "image", "Image");
}
public void testDefaultPropertyIncludeOnce() throws Exception {
myFixture.configureByFiles(getTestName(true) + ".fxml");
myItems = myFixture.completeBasic();
assertContainsElements(myFixture.getLookupElementStrings(), "fx:reference");
assertEquals(5, myItems.length);
}
public void testIncludedRootAttributes() throws Exception {
myFixture.addFileToProject("foo.fxml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<?import javafx.scene.layout.*?>\n" +
@@ -72,6 +72,10 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor,
final JavaFxPropertyElementDescriptor defaultPropertyDescriptor = getDefaultPropertyDescriptor();
if (defaultPropertyDescriptor != null) {
Collections.addAll(children, defaultPropertyDescriptor.getElementsDescriptors(context));
} else {
for (String name : FxmlConstants.FX_DEFAULT_ELEMENTS) {
children.add(new JavaFxDefaultPropertyElementDescriptor(name, null));
}
}
collectStaticElementDescriptors(context, children);
@@ -81,10 +85,6 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor,
JavaFxPropertyElementDescriptor.collectDescriptorsByCollection(returnType, myPsiClass.getResolveScope(), children, myPsiClass.getProject());
}
for (String name : FxmlConstants.FX_DEFAULT_ELEMENTS) {
children.add(new JavaFxDefaultPropertyElementDescriptor(name, null));
}
if (!children.isEmpty()) {
return children.toArray(new XmlElementDescriptor[children.size()]);
}
@@ -0,0 +1,5 @@
<?import javafx.scene.layout.GridPane?>
<GridPane xmlns:fx="http://javafx.com/fxml" fx:id="foo">
<fx:ref<caret>
</GridPane>