Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext2.0] Validation
[Xtext2.0] Validation [message #705166] Fri, 29 July 2011 14:15 Go to next message
Marcel   is currently offline Marcel Friend
Messages: 5
Registered: July 2011
Junior Member
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 15:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtext2.0] Validation [message #705722 is a reply to message #705219] Sat, 30 July 2011 08:32 Go to previous message
Marcel   is currently offline Marcel Friend
Messages: 5
Registered: July 2011
Junior Member
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: Sat Apr 20 03:49:34 GMT 2024

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

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

Back to the top