Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xtext] Strange behavior on adding error marker(Bug ?)
[Xtext] Strange behavior on adding error marker(Bug ?) [message #27176] Thu, 29 January 2009 06:11 Go to next message
Eclipse UserFriend
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 #27215 is a reply to message #27176] Thu, 29 January 2009 07:37 Go to previous messageGo to next message
Eclipse UserFriend
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
>
Re: [Xtext] Strange behavior on adding error marker(Bug ?) [message #27254 is a reply to message #27215] Thu, 29 January 2009 08:05 Go to previous messageGo to next message
Eclipse UserFriend
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
>>
Re: [Xtext] Strange behavior on adding error marker(Bug ?) [message #27287 is a reply to message #27254] Thu, 29 January 2009 08:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Aleksey,

thanks for the sample project.
I'm afraid that you added your validator only in the ui as a document
content observer. I would expect the error information even in headless
mode (e.g. when using the generator). That's why you should work with
the resouce more or less directly.

A reasonable way to validate your model is to register an EMF Validator
(see
http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse. emf.validation.doc/tutorials/validationAdapterTutorial.html
). Up to now, we do not provide an Xtext-ish way to implement model
validation, but expect something to appear soon.

Btw: The problem with your approach is, that the document change event
triggers a reparse on the Xtext resource that will start after a short
delay. Your validator creates the error markers immediatly in the first
place and the parser will clear them afterwards.
The (partial) parser does not remove any warnings, that's why they will
most likely never disappear from the problems view until you remove them
by hand. But that's only a guess.

Regards
Sebastian
Re: [Xtext] Strange behavior on adding error marker(Bug ?) [message #27321 is a reply to message #27287] Thu, 29 January 2009 08:56 Go to previous message
Eclipse UserFriend
Hi Sebastian,

thank you for the link and the answer, i'll try it out.
Previous Topic:[TCS} source access
Next Topic:[Xtext] ui plugin missing extensions
Goto Forum:
  


Current Time: Sun Apr 27 00:50:15 EDT 2025

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

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

Back to the top