[Check, xTend] [message #496590] |
Tue, 10 November 2009 11:19  |
Eclipse User |
|
|
|
Hi,
I am trying to insert in Check a constraint on the value of a property (of type EString) called "conditionToBeShown" of an EClass called "LocationElement".
So I started writing the rule in a Check file:
context SitePack::LocationElement ERROR "Condition is not correct" :
ok, no problem for the first rule, now, it seems that I can use just properties of LocationElement to express the constraints. But I don't know how to extend LocationElement with a method able to judge the property "conditionToBeShown" correctly. I tried using an extension.
So I created a file DslExtensions.ext and tried.
First of all I mapped the Java method containing the verification logic. It was not difficult:
import SitePack
Boolean isConditionTextCorrect(String text):
JAVA it.tomassetti.mdwe.ConditionDsl.isCorrect(java.lang.String);
Boolean isConditionTextCorrect(LocationElement element):
JAVA it.tomassetti.mdwe.ConditionDsl.isCorrect(SitePack.LocationE lement);
as you can imagine both the Java method perform the same operation ( the method receining a LocationElement just calls the other one public static boolean isCorrect(LocationElement element){
return isCorrect(element.getConditionToBeShown());
}).
Now, How can I use one of this extension to verify the constraint inside the Check file?
I tried with:
import DslExtensions;
context SitePack::LocationElement ERROR "Condition is not correct" :
this.isConditionTextCorrect();
Suggestions? Documentation that I missed? Am I totally wrong?
|
|
|
|
|
|
Re: [Check, xTend] [message #496812 is a reply to message #496780] |
Wed, 11 November 2009 08:19  |
Eclipse User |
|
|
|
Thank you, now my extension is called from the Check file.
I was so desperate that I was trying to create a Component just to invoke that java function.
Now the extension is called but... I get an error:
Caused by: java.lang.IllegalArgumentException: SitePack::TextInput is not responsible for java type SitePack.LocationElement
at org.eclipse.xtend.typesystem.AbstractTypeImpl.convert(AbstractTypeImpl.java:178)
at org.eclipse.internal.xtend.xtend.ast.JavaExtensionStatement.convertTypesToMethodSignature(JavaExtensionStatement.java:86)
at org.eclipse.internal.xtend.xtend.ast.JavaExtensionStatement.evaluateInternal(JavaExtensionStatement.java:73)
... 15 more
a TextInput is a ECore class having as ancestore LocationElement so I thought I could make use of polymorphism here... was I wrong?
|
|
|
Powered by
FUDForum. Page generated in 0.03730 seconds