[Xtext] Strange behavior on adding error marker(Bug ?) [message #27176] |
Thu, 29 January 2009 06:11  |
Eclipse User |
|
|
|
Hi Xtext team,
i use a visitor class(generated EMF Switch-class) to run through my model
and make few checks on it. If there is an error in the model, an error
marker should be added to the source file :
(example)
public Object caseElement(Element object) {
if(object.getName().equals("")) {
// good case
} else {
// bad case
NodeAdapter nodeAdapter = NodeUtil.getNodeAdapter(object);
CompositeNode node = nodeAdapter.getParserNode();
for(LeafNode lnode : node.getLeafNodes()) {
XtextLinkingDiagnostic diagnostic =
new XtextLinkingDiagnostic(lnode, "bad case");
object.eResource().getErrors().add(diagnostic);
}
}
return object;
}
My problem is that the error marker are not added to the editor, but it
works with the warnings marker :
object.eResource().getWarnings.add(diagnostic);
is it a bug or should i run something to update the error markers manually
?
thanx for the answer
|
|
|
|
Re: [Xtext] Strange behavior on adding error marker(Bug ?) [message #27254 is a reply to message #27215] |
Thu, 29 January 2009 08:05   |
Eclipse User |
|
|
|
Hi Sebastian,
yes, the marker are cleared. I invoke the analyzer in the reconcile method
of my reconciling strategy, which subclasses the
XtextDocumentReconcileStrategy.
I don't think, that its fault of my code, because there is no problems
with warnings marker.
here you can find a little example, please review the ModelSwitcher class
in the PartListener.java file in the org.xtext.example.mydsl.ui plugin :
http://depositfiles.com/files/l4xfv0uq8
Sebastian Zarnekow wrote:
> Hi Aleksey,
> most likely your error markers are cleared on a reparse during the
> resource lifecycle. How do you invoke your validating visitor?
> Regards
> Sebastian
> Aleksey wrote:
>> Hi Xtext team,
>>
>> i use a visitor class(generated EMF Switch-class) to run through my
>> model and make few checks on it. If there is an error in the model, an
>> error marker should be added to the source file :
>> (example)
>> public Object caseElement(Element object) {
>> if(object.getName().equals("")) {
>> // good case
>> } else {
>> // bad case
>> NodeAdapter nodeAdapter = NodeUtil.getNodeAdapter(object);
>> CompositeNode node = nodeAdapter.getParserNode();
>> for(LeafNode lnode : node.getLeafNodes()) {
>> XtextLinkingDiagnostic diagnostic = new
>> XtextLinkingDiagnostic(lnode, "bad case");
>> object.eResource().getErrors().add(diagnostic);
>> }
>> }
>> return object;
>> }
>>
>> My problem is that the error marker are not added to the editor, but it
>> works with the warnings marker :
>> object.eResource().getWarnings.add(diagnostic);
>>
>> is it a bug or should i run something to update the error markers
>> manually ?
>>
>> thanx for the answer
>>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03473 seconds