|
|
|
In general the bug is that parent/child hierarchy can be more than 2 levels deep - in can have arbitrary depth. In larger projects having 'grandparent' beans is common, and even 4 levels is not strange.
Parent/Child bean hierarchies sometimes have a approximate relation with Base/Derives class hierarchies, but this is not necessary. For code that has uniform naming conventions for some properties (like Spring itself), it's quite common to define parent beans for types that have no relation at all on the 'java class' level. (see example for (1) below) I'm testing different solutions to see what works 'most intuitive'. Thoughts so far: 1) When property is implemented by different classes, make the parent resolve to multiple properties (using PsiPolyVariantReference). class ChildA {
public void setString(String value) {}
}
class ChildB {
public void setString(String value) {}
}
<bean abstract="true" id="parent"> <property name="string" value="test"/> </bean> <bean id="childA" class="foo.ChildA" parent="parent"/> <bean id="childB" class="foo.ChildB" parent="parent"/> In above example I think it would be convenient if property "string" on abstract bean "parent" would resolve to both setters (in ChildA and in ChildB). 2) More important questions is, for parent beans, what variants to suggest for completion. The current code (in PropertyReference#getVariants() will provide union of all child bean properties. This could be extended to provide union of all descendant bean properties (children of children etc). However, I think it would make sense to make completion more useful in this case by providing intersection of all descendant bean properties: class ChildA {
public void setString(String value) {}
public void setFlag(boolean flag) {}
}
class ChildB {
public void setNumber(int number) {}
public void setFlag(boolean flag) {}
}
<bean abstract="true" id="parent"> <property name="<caret>" /> </bean> <bean id="childA" class="foo.ChildA" parent="parent"/> <bean id="childB" class="foo.ChildB" parent="parent"/> In this case intersection of descendant bean properties is {"flag"}. This is the only property that is valid over the subtree of all children. Here is a first try.
Maybe code is not very good, but it works so you can try 'intersection' solution and see if it is practical or not. Features of patch: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If not, I think I can send a patch tomorrow that fixes this and improves other aspects of parent/child bean editing. Let me know if I should give it a try.