Home » Modeling » OCL » AST AbstractVisitor get occurances of operation arguments in operation's body
| | | |
| 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   |
ModelGeek Mising name Messages: 347 Registered: June 2011 |
Senior Member |
|
|
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] Report message to a 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   |
Ed Willink Messages: 3151 Registered: July 2009 |
Senior Member |
|
|
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  |
Christian W. Damus Messages: 550 Registered: July 2009 |
Senior Member |
|
|
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: Sat May 18 20:24:13 EDT 2013
Powered by FUDForum. Page generated in 0.01702 seconds
|