Take input from other field
I have the following scenario. I have two fields to select, first a field with a java class via a pedefined scope selectable. Now the problem is the second field, it should take the information of the class and should allow a scope of informationen from this class selectable, method names, method parameters etc.
I tried the approach from the Shapes tutorial:
new ListScope(node/Color/.staticFields()) {
public string getName(node<> child) {
child : StaticFieldDeclaration.name;
}
};
and used it for my purpose like:
new ListScope(node/<my_Class>/.methods()) {
public string getName(node<> child) {
child : InstanceMethodDeclaration.name;
}
};
and it works, but the problem the <my_Class> changes depending on what is used on the first field.
I tried this approach:
new ListScope(enclosingNode.ancestor<concept = TestClassRef>.testClass.methods()) {
public string getName(node<> child) {
child : InstanceMethodDeclaration.name;
}
};
But this does return an empty sequence, because the scope initializes instantly when it is created. Just for clarification, "TestClassRef" holds the "testClass" as reference which is a "InstanceMethodDeclaration". Is there anything I'm doing completetly wrong here? I can't find anything in any tutorial or in the documentation.
I appreciate all you help!
I tried the approach from the Shapes tutorial:
new ListScope(node/Color/.staticFields()) {
public string getName(node<> child) {
child : StaticFieldDeclaration.name;
}
};
and used it for my purpose like:
new ListScope(node/<my_Class>/.methods()) {
public string getName(node<> child) {
child : InstanceMethodDeclaration.name;
}
};
and it works, but the problem the <my_Class> changes depending on what is used on the first field.
I tried this approach:
new ListScope(enclosingNode.ancestor<concept = TestClassRef>.testClass.methods()) {
public string getName(node<> child) {
child : InstanceMethodDeclaration.name;
}
};
But this does return an empty sequence, because the scope initializes instantly when it is created. Just for clarification, "TestClassRef" holds the "testClass" as reference which is a "InstanceMethodDeclaration". Is there anything I'm doing completetly wrong here? I can't find anything in any tutorial or in the documentation.
I appreciate all you help!
Please sign in to leave a comment.
Two guesses:
root
TestMethodRef
TestClassRef
All concepts just extend BaseConcept. In TestMethodRef I created a constrain, to my InstanceMethodDeclaration as a reference scope. This is just defined the same as in my previous post:
new ListScope(referenceNode.ancestor<concept = TestClassRef>.testClass.methods()) {
public string getName(node<> child) {
child : InstanceMethodDeclaration.name;
}
};
I don't know if I did something wrong in the editors, in TestClassRef and TestMethodRef I just defined the two references with link declaration and {name}. In my root I just put my children inside % and that's it. The sequence of my Scope is still empty and I don't know why. I want to fill in my TestMethodRef it says: No variants for "". I would be very grateful if someone can point out the error here :)
Project10.zip (85KB)