Customize code checker [message #901966] |
Wed, 15 August 2012 06:57  |
Eclipse User |
|
|
|
Hi
The language that i implement support predefined functions like:
cylinder(r1, r2, r, h)
Except the conventional way to call this function, you can also can call it using parameters names like:
cylinder(r1=5, r2=3, h=20)
or
cylinder(h=20, r=30)
As you can see from the above example, you can not only use as many of the parameters you want but you can also mix the order. To implement this i make the following simplified grammar:
Code:
(cube+=Cylinder)*
;
Cylinder:
'cylinder' '(' (var+=Var (',' var+=Var)*)?')' ';'
;
Var:
name=ID '=' NUMBER
;
terminal NUMBER returns ecore::EBigDecimal:
('0'..'9')* ('.' ('0'..'9')+)?;
terminal INT returns ecore::EInt:
'this one has been deactivated';
I thing that what i need is to do a parameters validation in the CylinderImpl class. So what i did so far is to do the checkout in "eIsSet" method of "CylinderImpl.java", but i don't know how to throw a warning or error message to the editor.
Thank you in advance
Charalampos Alexopoulos
|
|
|
Re: Customize code checker [message #901978 is a reply to message #901966] |
Wed, 15 August 2012 07:42  |
Eclipse User |
|
|
|
Sorry, i didn't do my homework right before i post.
In package 'validation' is a class [myprojectname]JavaValidator.java in which i can do the job like:
@Check
public void checkCubeParameters(Cube cube)
{
for (int i = 0; i < cube.getVar().size(); i++)
{
Var var = (Var) (cube.getVar().get(i));
String name = var.getName();
if (!name.equals("size") & !name.equals("center"))
{
warning("Not a valid parameter '" + name + "'. Expecting 'size' or 'center'", OpenSCADPackage.Literals.CUBE__VAR);
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.05620 seconds