Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xtext2.0] Validation
[Xtext2.0] Validation [message #705166] Fri, 29 July 2011 10:15 Go to next message
Eclipse UserFriend
Hello,

i have worked before with the validation package in the older version of xtext.
Since Version 2.0 it seems not so easy to write some simple check methods.

The example in the DomainmodelJavaValidator.java File looks like this:

@Check
public void checkGreetingsStartsWithCapital(Greeting greeting){
if(!Character.isUpperCase(greeting.getName().charAt(0))) {
warning("Name should start with a capital", MyDslPackage.Literals.GREETING__NAME);
}
}

In the old version is was possible to use this example but now
i have to put in an EStructuralFeature instead of a simple integer (MyDslPackage.Literals.GREETING__NAME).
i would guess that the error and warning methods were altered.

Can someone give me a new example for the simple warning above?

thank u
Re: [Xtext2.0] Validation [message #705219 is a reply to message #705166] Fri, 29 July 2011 11:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

don't understand your problem:

Xtext 2.0

public class MyDslJavaValidator extends AbstractMyDslJavaValidator {

	@Check
	public void checkGreetingStartsWithCapital(Greeting greeting) {
		if (!Character.isUpperCase(greeting.getName().charAt(0))) {
			warning("Name should start with a capital", MyDslPackage.Literals.GREETING__NAME);
		}
	}

}


Xtext 1.0.x

	@Check
	public void checkGreetingStartsWithCapital(Greeting greeting) {
		if (!Character.isUpperCase(greeting.getName().charAt(0))) {
			warning("Name should start with a capital", MyDslPackage.GREETING__NAME);
		}
	}


~Christian
Re: [Xtext2.0] Validation [message #705722 is a reply to message #705219] Sat, 30 July 2011 04:32 Go to previous message
Eclipse UserFriend
ok, thank you.
The "Literals" reference was missing.
Previous Topic:Local Scope and Shadowing
Next Topic:generated EPackage's Literals not generated; why?
Goto Forum:
  


Current Time: Fri Nov 07 17:23:29 EST 2025

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

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

Back to the top