Building a standalone program parsing a file, I used the first option of http://www.davehofmann.de/?p=101
A validation is defined that give an error (red under line in eclipse) if text does not start with a capital letter.
The standalone parser does not give an error of an input file that does not pass the validation. How can I ask the standalone implementation also the verify the validations?
Update 1
The classed used to parse the grammar with checkResource
included:
class XtextParser {
@Inject
private IParser parser;
new() {
var injector = new MyDslStandaloneSetup().
createInjectorAndDoEMFRegistration();
injector.injectMembers(this)
}
def EObject parse(Reader reader) throws IOException {
var result = parser.parse(reader)
if (result.hasSyntaxErrors()) {
throw new ParseException("Provided input contains syntax errors.")
}
var resource = result.getRootASTElement().eResource()
//resource is null
//checkResource(resource)
return result.getRootASTElement();
}
@Inject IResourceValidator resourceValidator
def void checkResource(Resource resource) {
val issues = resourceValidator.validate(resource,
CheckMode.ALL, CancelIndicator.NullImpl)
for (issue : issues) {
switch issue.severity {
case ERROR:
println("ERROR: " + issue.message)
case WARNING:
println("WARNING: " + issue.message)
}
}
}
}