You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the simplify plugin replaces multiple choice properties, it does not set the parent of the replacement property which leads to failures in other plugins that may be executed after it. For instance any call to CPropertyInfo.displayName() on a replaced property will fail with a NPE.
This is caused by adding the replaced property to the CClassInfo.properties but not setting the class as the parent of the property.
The method CPropertyInfo.setParent is package scoped. The only way to set the parent is to first add the replacement property to the class using the CClassInfo.addProperty() method, then remove it from the collection and then add it back at the correct index position.
CPropertyInfonewProperty = createElementPropertyInfo(oldProperty, elementDef, ... );
// attach/detach to set parentclassInfo.addProperty(newProperty);
classInfo.getProperties().remove(newProperty);
// then add to right place and remove old oneclassInfo.getProperties().add(index, newProperty);
classInfo.getProperties().remove(oldProperty);
This will require modification of the class properties outside the visitation loop or else the code that modifies the properties list will fail with ConcurrentModificationException. We would need to collect enough information in the visitor to be able to apply the modifications after finalising the visitation.
Problem:
When the simplify plugin replaces multiple choice properties, it does not set the parent of the replacement property which leads to failures in other plugins that may be executed after it. For instance any call to
CPropertyInfo.displayName()
on a replaced property will fail with a NPE.This is caused by adding the replaced property to the
CClassInfo.properties
but not setting the class as the parent of the property.SimplifyPlugin.java#L167
SimplifyPlugin.java#L192
SimplifyPlugin.java#L195
SimplifyPlugin.java#L243
Possible solution:
The method
CPropertyInfo.setParent
is package scoped. The only way to set the parent is to first add the replacement property to the class using theCClassInfo.addProperty()
method, then remove it from the collection and then add it back at the correct index position.This will require modification of the class properties outside the visitation loop or else the code that modifies the properties list will fail with
ConcurrentModificationException
. We would need to collect enough information in the visitor to be able to apply the modifications after finalising the visitation.A bit hacky but works reliably.
The text was updated successfully, but these errors were encountered: