Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validation fragments
Validation fragments [message #1696918] Fri, 29 May 2015 11:36 Go to next message
Anakreontas Mentis is currently offline Anakreontas MentisFriend
Messages: 85
Registered: October 2014
Member
My project's Generate.mwe2 file contains a fragment for validation:
fragment = validation.ValidatorFragment auto-inject {
// composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
which produced an xtend file named MyDslValidator.xtend.
I defined methods in the xtend class annotated with @check but they don't seem to apply. If I enter invalid input (which is syntactically correct) eclipse does not report errors or warnings.

The documentation also refers to a second fragment named org.eclipse.xtext.generator.validation.JavaValidatorFragment. This resulted in a Java file under the validation package. Except for the implementation language, what is the difference between the two fragments?
Re: Validation fragments [message #1696919 is a reply to message #1696918] Fri, 29 May 2015 11:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
How does your check rule look like

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation fragments [message #1696923 is a reply to message #1696919] Fri, 29 May 2015 12:00 Go to previous message
Anakreontas Mentis is currently offline Anakreontas MentisFriend
Messages: 85
Registered: October 2014
Member
My bad. Ignore this question.

I had a misconception about validation. In the xtext implementation I provided a Boolean method that returned true if the invariant hold. When I added the fragment for the Java validator, the generated file contained an example that showed I should implement void methods and use the warning and error methods to indicate problems.
Previous Topic:Get absolute path of .mydsl file in doGenerate(Resource resource, IFileSystemAccess fsa)
Next Topic:Content Assist Contexts
Goto Forum:
  


Current Time: Fri Apr 26 00:25:34 GMT 2024

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

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

Back to the top