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
S1) to have method CtInvocation#addArgument(int, CtExpression)
S2) to have method CtInvocation#addFirstArgument(int, CtExpression)
it is the way how Spoon handles it actually. Each element implements (or does not implement (... yet?)) own set of collection manipulation methods. May be we might generate all possible add/addList/remove/contains methods of Set and List interface with appropriate attribute name suffix automatically.
It would be compatible with current model, but
it would mean a lot of methods in spoon API - more complicated for clients
it avoids usage of generic helper methods, which are able to do operations on List and Set
S3) to have method List CtInvocation#getArguments(), which would return modifiable implementation of List.
We cannot of course return internal list and let client to modify it.
The idea is to return a List/Set wrapper which would handle all the List/Set method calls. It would
generate appropriate model change events
handle consistency of model (change parent, ...)
It would be not backward compatible, but the code of spoon and code of client's would be simpler and spoon API would be more friendly to clients who needs model modifications.
S4) to use generic List modifiableList = invocation.getValueByRoleAsList(CtRole.ARGUMENT)
I like that API, because it will be useful for some special kind of model operations.
But it is not so nice solution like S3 would be, because client has to access attributes by CtRole.ARGUMENT, which is more complicated then simple call of List getArguments()
monperrus
changed the title
Unified work with collection attributes of Spoon model
feature: better collection-based properties of Spoon model
Mar 16, 2018
monperrus
changed the title
feature: better collection-based properties of Spoon model
feature: better collection-based properties of Spoon model (non-derived getters)
Mar 16, 2018
Example of problem: Use case: Client needs to add argument at the beginning of CtInvocation#arguments list.
Actually the only solution is
Solutions?
it is the way how Spoon handles it actually. Each element implements (or does not implement (... yet?)) own set of collection manipulation methods. May be we might generate all possible add/addList/remove/contains methods of Set and List interface with appropriate attribute name suffix automatically.
It would be compatible with current model, but
We cannot of course return internal list and let client to modify it.
The idea is to return a List/Set wrapper which would handle all the List/Set method calls. It would
It would be not backward compatible, but the code of spoon and code of client's would be simpler and spoon API would be more friendly to clients who needs model modifications.
This is already partially implemented in #1582.
List getArguments()
get/setArguments(...)
, ...). If S3 would be already implemented in spoon model, then implementation of review: feat: Spoon CtRole based attributes access #1582 would be much simpler too.The text was updated successfully, but these errors were encountered: