Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Customize code checker
Customize code checker [message #901966] Wed, 15 August 2012 10:57 Go to next message
Charalampos Alexopoulos is currently offline Charalampos AlexopoulosFriend
Messages: 13
Registered: July 2012
Junior Member
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 11:42 Go to previous message
Charalampos Alexopoulos is currently offline Charalampos AlexopoulosFriend
Messages: 13
Registered: July 2012
Junior Member
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);
}
}
}
Previous Topic:parsing DSL in a Java application
Next Topic:Deploying Xtext parser along with the code generator
Goto Forum:
  


Current Time: Fri Apr 19 22:43:50 GMT 2024

Powered by FUDForum. Page generated in 0.03746 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top