How to detect parse errors when loading from ResourceSet? [message #1391675] |
Tue, 01 July 2014 08:34 |
|
Hey!
I have a slight Problem with Xtext 2.6.0 (and possibly all other versions ):
I have some code to read my model files and put them all together on one big bunch. it looks like this currently:
/**
* Loads the model from a set of spread out recources,
* resolving all Proxies and patching the model
*/
def load(ModelResourceProvider provider) {
var fcnt = 0
for (URI uri : provider.resources) {
// fill up resource set.
val rsrc = resourceSet.getResource(uri, true);
for(item : rsrc.warnings) {
log.warn(uri.lastSegment + ":" + item.line + ":" + item.column + ": " + item.message)
}
val diag = Diagnostician.INSTANCE.validate(rsrc.contents.get(0));
switch (diag.severity) {
case Diagnostic.ERROR: {
log.error(uri.lastSegment + " contains errors:")
diag.children.logIt
}
case Diagnostic.WARNING: {
log.warn(uri.lastSegment + " contains warnings:")
diag.children.logIt
}
}
fcnt += 1
}
for (Resource r : resourceSet.resources) {
EcoreUtil2.resolveLazyCrossReferences(r, null);
}
contents = resourceSet.resources.map(r|r.allContents.toIterable).flatten.filter(TopLevelElement)
packages = resourceSet.resources.map(r|r.allContents.toIterable).flatten.filter(Package)
patcher.patch(contents)
}
my files look somewhat like this:
package dbtest;
abstract persistent AbstractContExt {
directed connection [*] to ContInt2 int2 [0..1];
}
which loads fine, yields no warnings, all is well but... when i put a syntax error in there:
package dbtest;
abstract persistent AbstractContExt {
an error;
directed connection [*] to ContInt2 int2 [0..1];
}
the code /still/ loads the file fine (!?@!). I just get an empty AbstractContExt instance... what is going on here? Which kind of "give me errors" switch did I miss?
Thanks a lot in advance
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03323 seconds