History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-15630
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Avdeev
Reporter: Taras Tielkes
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

Properties on abstract parent bean of abstract parent bean marked red

Created: 15 Mar 07 17:05   Updated: 27 Mar 07 18:34
Component/s: J2EE.Spring
Fix Version/s: Selena 6791

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
File Attachments: 1. Text File descendants.patch (14 kb)

Image Attachments:

1. screenshot-1.jpg
(34 kb)

Build: 6,755
Fixed in build: 6,785


 Description  « Hide
This looks similar to IDEADEV-13531, which seems fixed in current release (but still open in JIRA).
public class SomeBean {
    public void setPropertyOne(String value) {}
    public void setPropertyTwo(String value) {}
    public void setPropertyThree(String value) {}
}
<bean id="grandParentBean" abstract="true">
  <property name="propertyOne" value="123"/>
</bean>

<bean id="parentBean" parent="grandParentBean" abstract="true">
  <property name="propertyTwo" value="456"/>
</bean>

<bean id="childBean" parent="parentBean" class="foo.bar.SomeBean">
  <property name="propertyThree" value="678"/>
</bean>

Property 'propertyOne' is marked with two (!) warnings Cannot resolve property 'propertyOne'

Link to original forum post: http://intellij.net/forums/thread.jspa?threadID=266256&tstart=0



 All   Comments   Work Log   Change History      Sort Order:
Taras Tielkes - 20 Mar 07 14:15
Dmitry, are you working on this right now?

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.


Dmitry Avdeev - 20 Mar 07 16:51
ok

Taras Tielkes - 23 Mar 07 16:02
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.
I think this is much more usefull in practice than current approach. Otherwise IDEA is providing suggestions that it will mark red next because they are not valid for (some) child beans.


Taras Tielkes - 27 Mar 07 12:20
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:
-example from this issue now works
-in parent beans, completion is provided only for properties present on all descendant beans (children, childrens children, etc)
-multiple resolving (PsiPolyVariantReference) if parent property is implemented by different child classes
-completion for first step of compound properties (was not working before)
-tries to give better error messages when property is missing on some children, or has different type


Taras Tielkes - 27 Mar 07 12:22
Patch was attached as "descendants.patch".