Tracking Init, Read, Write accesses to a field [message #1781930] |
Wed, 14 February 2018 16:48 |
|
Dear all.
In my DSL, I have defined the concept of class field (it extends the one from Xtend).
I would like to track initialization, read and write accesses to the declared fields in order to output very specific warning messages to the user of my DSL.
The ReadAndWriteTraking class provides an API for the two first types.
I have created DSLReadAndWriteTracking which is a subtype of ReadAndWritreTraking with the write access (i.e. assignment) tracking.
When I'm calling the tracker within my JvmModelInferrer or my JvmModelCompleter, I obtain the error "cannot root twice" in some cases.
The code used for tracking write accesses is:
protected boolean trackWriteAccess(XExpression expr) {
for (final XAssignment assign : EcoreUtil2.getAllContentsOfType(expr, XAssignment.class)) {
final JvmIdentifiableElement feature = assign.getFeature();
if (feature instanceof JvmField) {
final JvmField field = (JvmField) feature;
this.readAndWriteTracking.markAssignmentAccess(field);
}
}
}
What is the best location/class for calling the tracking function?
Or should I code everything within my DSL validator instead of keeping track within the ReadAndWriteTracking object? Indeed, within my validator, my calls to the tracker works without error.
Thank you.
Stéphane.
|
|
|
Powered by
FUDForum. Page generated in 0.02985 seconds