Home » Modeling » OCL » AST AbstractVisitor get occurances of operation arguments in operation's body
AST AbstractVisitor get occurances of operation arguments in operation's body [message #1015085] |
Wed, 27 February 2013 06:52  |
Eclipse User |
|
|
|
Hi,
I would like to know where precisely argument/arguments are being used in operation's body.
I have tried to extend AbstractVisitor and i have tried to override "handleOperationCallExp" but it does not serve the purpose.
Do you have any clue which method would be the one in AbstractVisitor to get the argument usage in operation's body?
thanks!
Cheers,
|
|
| | | |
Re: AST AbstractVisitor get occurances of operation arguments in operation's body [message #1015120 is a reply to message #1015112] |
Wed, 27 February 2013 09:19   |
Eclipse User |
|
|
|
String body = "here i am fetching the body of ocl operation"
OCL<?, EClassifier, EOperation, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl1;
ocl1 = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
OCLHelper<EClassifier, EOperation, ?, Constraint> helper = ocl1.createOCLHelper();
helper.setOperationContext(eClass, eOperation);
OCLExpression<EClassifier> query = helper.createQuery(body);
TestVisitor visitor = new TestVisitor(param);
Visitable accept = query.accept(visitor);
In my TestVisitor class i have implemented following
@Override
protected Visitable handleVariable(
Variable<EClassifier, EParameter> variable, Visitable initResult) {
System.out.println(variable);
return super.handleVariable(variable, initResult);
}
it just prints all parts of all let statements defined inside operation... it does not print arguments of operation.
Do you have any idea where i am going wrong?
[Updated on: Wed, 27 February 2013 09:20] by Moderator
|
|
|
Re: AST AbstractVisitor get occurances of operation arguments in operation's body [message #1015133 is a reply to message #1015120] |
Wed, 27 February 2013 09:38   |
Eclipse User |
|
|
|
Hi
For the classic Ecore-based OCL, the Visitors support a user-coded
traversal of a tree of OCL model objects (but not Ecore objects).
Since many parent-child traversals are regular the handleXXX methods
factor out some common usage. Very helpful when the common usage is what
you want. A bit confusing when it isn't. In principle you should plan to
do all the vistXXX for your own full traversal, but reuse the handleXXX
if it happens to do what you want.
If something doesn't happen, it's because you didn't program it.
Regards
Ed Willink
On 27/02/2013 14:19, ModelGeek Mising name wrote:
> String body = "here i am fetching the body of ocl operation"
> OCL<?, EClassifier, EOperation, ?, ?, ?, ?, ?, ?, Constraint, EClass,
> EObject> ocl1;
> ocl1 = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
> OCLHelper<EClassifier, EOperation, ?, Constraint> helper =
> ocl1.createOCLHelper();
> helper.setOperationContext(eClass, eOperation);
> OCLExpression<EClassifier> query = helper.createQuery(body);
> TestVisitor visitor = new TestVisitor(param);
> Visitable accept = query.accept(visitor);
>
> In my TestVisitor class i have implemented following
>
>
> @Override
> protected Visitable handleVariable(
> Variable<EClassifier, EParameter> variable, Visitable
> initResult) {
> System.out.println(variable);
> return super.handleVariable(variable, initResult);
> }
>
> it just prints all parts of all let statements... it does not print
> arguments of operation.
>
> Do you have any idea where i am going wrong?
>
|
|
| |
Re: AST AbstractVisitor get occurances of operation arguments in operation's body [message #1015209 is a reply to message #1015120] |
Wed, 27 February 2013 13:34  |
Eclipse User |
|
|
|
Hi,
You are implementing the handleVariable call-back, not
handleVariableExp. They are two different things!
cW
On 2013-02-27 14:19:49 +0000, ModelGeek Mising name said:
> String body = "here i am fetching the body of ocl operation"
> OCL<?, EClassifier, EOperation, ?, ?, ?, ?, ?, ?, Constraint, EClass,
> EObject> ocl1;
> ocl1 = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
> OCLHelper<EClassifier, EOperation, ?, Constraint> helper =
> ocl1.createOCLHelper();
> helper.setOperationContext(eClass, eOperation);
> OCLExpression<EClassifier> query = helper.createQuery(body);
> TestVisitor visitor = new TestVisitor(param);
> Visitable accept = query.accept(visitor);
>
> In my TestVisitor class i have implemented following
>
>
> @Override
> protected Visitable handleVariable(
> Variable<EClassifier, EParameter> variable, Visitable initResult) {
> System.out.println(variable);
> return super.handleVariable(variable, initResult);
> }
>
> it just prints all parts of all let statements... it does not print
> arguments of operation.
>
> Do you have any idea where i am going wrong?
|
|
|
Goto Forum:
Current Time: Tue Jul 22 18:05:06 EDT 2025
Powered by FUDForum. Page generated in 0.04181 seconds
|