-
-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: Manipulation with node attributes by CtRole #1581
Comments
Another related idea. The API above would be simpler if each CtRole would have exactly one type of the returned value. But it is actually not like this in these cases: CtRole.BODY
CtRole.CASE
CtRole.ELSE
CtRole.EXPRESSION
CtRole.LABEL
CtRole.OPERATOR_KIND
... and more ... now I see that there is more such case. I thought at beginning that it is only rare case... |
This is long standing need, thanks for bringing this up. In terms of baby PR, I would propose first only two additional methods (no new interface and class)
|
Thanks for suggestion about I would prefer a longer unique name of methods like
no interface, is the problem, because first step in each such method has to be looking for a code, which handles CtRole on appropriate CtElement instance. I think we should implement this resolving code only once. Therefore I have designed interface CtRoleHandler. I love it! So it will be hard to convince me to delete it ;-) |
Closing this issue in order to avoid a discussion split in two threads. |
I think it would be helpful to have a methods, which can get/set value of an AST node by CtRole.
Some internal spoon algorithms would be simpler then. For example ReplacementVisitor. And I would like to use that in new more powerful SubsitutionVisitor and TemplateMatcher.
For example:
I would like to have methods:
I would like to implement a generator, which creates code which would provide implementation of these methods. But first I would like to discuss with You all, this concept.
Concept 1
To have a new class/interface CtMetaModel, which would provide these functions
Concept 2
To have an interface
CtRoleProvider
with methodsand to have one implementation of CtRoleProvider for each CtRole enum value.
Concept 3
To have it implemented directly in spoon model. It means
WDYT?
The text was updated successfully, but these errors were encountered: