Reputation: 1706
are there any ways to print the content of line if an error occurs during parsing a file via xtext into the log file? Currently, all I get is a line number but this is not enough to find a problem if you do have only a log file.
I didn't find a section in the documentation for this. Do you have any idea or resource to help?
Upvotes: 0
Views: 135
Reputation: 11868
something like
IParser parser = i.getInstance(IParser.class);
IParseResult parseResult = parser.parse(new InputStreamReader(new StringInputStream("element a\nelement a\nxxxx")));
for (INode e : parseResult.getSyntaxErrors()) {
System.out.println(e.getSyntaxErrorMessage());
System.out.println(e.getStartLine());
System.out.println(e.getText());
}
and if that is not enhough
for (INode x : parseResult.getRootNode().getLeafNodes()) {
if (x.getStartLine()==e.getStartLine()) {
System.out.print(x.getText());
}
}
System.out.println();
Upvotes: 1