Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Woes migrating to 2.2.1 from 2.0.1 - need help
Woes migrating to 2.2.1 from 2.0.1 - need help [message #858055] Fri, 27 April 2012 01:32 Go to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hi,
In geppetto we have been on version 2.0.1 for some time and decided to
upgrade to 2.2.1.

Now I am facing issues regarding "build clean" and my linker not being
called. The symptoms are that problems reported by validation are
handled correctly, but problems added by the linker are not.

"Build clean" no longer seem to trigger linking of everything (it does
not hit my breakpoint). All I get is that the markers from linking
disappear, but the linker is then not called.

If I open a file, it gets validated and error markers appear. I have to
open each file to see all the errors.
In the console I sometimes see messages like this (when a file with
errors is opened):
!ENTRY org.eclipse.core.resources 4 376 2012-04-27 02:12:45.951
!MESSAGE Marker id 224733 not found.


I debugged and found that in 2.0.1 I received two calls to the linker
when doing a clean - in 2.2.1 only one.

What I do in MyLinker#afterModelLinked (in a separate class) is:

@Inject
private org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
indexProvider;

IResourceDescriptions descriptionIndex =
indexProvider.getResourceDescriptions(resource);
IResourceDescription descr =
descriptionIndex.getResourceDescription(resource.getURI());

When doing a "build clean", desc becomes null. So in 2.0.1, I just
waited for the second call, and then did the linking - if descr is null,
I just return from MyLinker#afterModelLinked.

Are there any particular things that changed that I should have taken
care of?


I also tried updating to 2.3.0, but there I found that xtext.builder and
xtext.ui requires xtext.xbase (and as a consequence many additional
depdendencies). I really don't want to include xbase since it is not
used. Should this be reported as a bug, or is the dependency on xbase
suppose to be there - if so, for what?

Regards
- henrik
Re: Woes migrating to 2.2.1 from 2.0.1 - need help [message #858745 is a reply to message #858055] Fri, 27 April 2012 09:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I avoid the dependencies by having a separate 'build'; plugin for the
*.mwe2 and ... releng scripts. Worth doing even for 2.0 or 1.0.

Regards

Ed Willink



On 27/04/2012 02:32, Henrik Lindberg wrote:
> Hi,
> In geppetto we have been on version 2.0.1 for some time and decided to
> upgrade to 2.2.1.
>
> Now I am facing issues regarding "build clean" and my linker not being
> called. The symptoms are that problems reported by validation are
> handled correctly, but problems added by the linker are not.
>
> "Build clean" no longer seem to trigger linking of everything (it does
> not hit my breakpoint). All I get is that the markers from linking
> disappear, but the linker is then not called.
>
> If I open a file, it gets validated and error markers appear. I have
> to open each file to see all the errors.
> In the console I sometimes see messages like this (when a file with
> errors is opened):
> !ENTRY org.eclipse.core.resources 4 376 2012-04-27 02:12:45.951
> !MESSAGE Marker id 224733 not found.
>
>
> I debugged and found that in 2.0.1 I received two calls to the linker
> when doing a clean - in 2.2.1 only one.
>
> What I do in MyLinker#afterModelLinked (in a separate class) is:
>
> @Inject
> private org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
> indexProvider;
>
> IResourceDescriptions descriptionIndex =
> indexProvider.getResourceDescriptions(resource);
> IResourceDescription descr =
> descriptionIndex.getResourceDescription(resource.getURI());
>
> When doing a "build clean", desc becomes null. So in 2.0.1, I just
> waited for the second call, and then did the linking - if descr is
> null, I just return from MyLinker#afterModelLinked.
>
> Are there any particular things that changed that I should have taken
> care of?
>
>
> I also tried updating to 2.3.0, but there I found that xtext.builder
> and xtext.ui requires xtext.xbase (and as a consequence many
> additional depdendencies). I really don't want to include xbase since
> it is not used. Should this be reported as a bug, or is the dependency
> on xbase suppose to be there - if so, for what?
>
> Regards
> - henrik
Re: Woes migrating to 2.2.1 from 2.0.1 - need help [message #858797 is a reply to message #858055] Fri, 27 April 2012 09:45 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Henrik,

I'm not aware of any deps to xbase itself from the xtext core bundles.
We use the xbase.lib which contains very few utilitiy classes and has no
actual dependencies. What problems did you face with that?

We loaded the resource twice in Xtext 2.0. This happens only once, now,
thus the linking is not triggered twice. You may want to checkout
LazyLinkingResource#resolveLazyCrossReferences. It may be possible to
trigger the #afterModelLinked stuff manually prior to resolving the
cross references.

If I'm not mistaken the concept of the
org.eclipse.xtext.resource.DerivedStateAwareResource may help.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 27.04.12 03:32, schrieb Henrik Lindberg:
> Hi,
> In geppetto we have been on version 2.0.1 for some time and decided to
> upgrade to 2.2.1.
>
> Now I am facing issues regarding "build clean" and my linker not being
> called. The symptoms are that problems reported by validation are
> handled correctly, but problems added by the linker are not.
>
> "Build clean" no longer seem to trigger linking of everything (it does
> not hit my breakpoint). All I get is that the markers from linking
> disappear, but the linker is then not called.
>
> If I open a file, it gets validated and error markers appear. I have to
> open each file to see all the errors.
> In the console I sometimes see messages like this (when a file with
> errors is opened):
> !ENTRY org.eclipse.core.resources 4 376 2012-04-27 02:12:45.951
> !MESSAGE Marker id 224733 not found.
>
>
> I debugged and found that in 2.0.1 I received two calls to the linker
> when doing a clean - in 2.2.1 only one.
>
> What I do in MyLinker#afterModelLinked (in a separate class) is:
>
> @Inject
> private org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
> indexProvider;
>
> IResourceDescriptions descriptionIndex =
> indexProvider.getResourceDescriptions(resource);
> IResourceDescription descr =
> descriptionIndex.getResourceDescription(resource.getURI());
>
> When doing a "build clean", desc becomes null. So in 2.0.1, I just
> waited for the second call, and then did the linking - if descr is null,
> I just return from MyLinker#afterModelLinked.
>
> Are there any particular things that changed that I should have taken
> care of?
>
>
> I also tried updating to 2.3.0, but there I found that xtext.builder and
> xtext.ui requires xtext.xbase (and as a consequence many additional
> depdendencies). I really don't want to include xbase since it is not
> used. Should this be reported as a bug, or is the dependency on xbase
> suppose to be there - if so, for what?
>
> Regards
> - henrik
Re: Woes migrating to 2.2.1 from 2.0.1 - need help [message #858995 is a reply to message #858797] Fri, 27 April 2012 11:57 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-27-04 11:45, Sebastian Zarnekow wrote:
> I'm not aware of any deps to xbase itself from the xtext core bundles.
> We use the xbase.lib which contains very few utilitiy classes and has no
> actual dependencies. What problems did you face with that?
>
Closing the loop on this first;
You are right, it was only xbase.lib - my mistake.
I managed to run geppetto with 2.3 (same issue with global state though
- will continue that in separate post).

Regards
- henrik
Re: Woes migrating to 2.2.1 from 2.0.1 - need help [message #859092 is a reply to message #858797] Fri, 27 April 2012 12:59 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-27-04 11:45, Sebastian Zarnekow wrote:
> We loaded the resource twice in Xtext 2.0. This happens only once, now,
> thus the linking is not triggered twice. You may want to checkout
> LazyLinkingResource#resolveLazyCrossReferences. It may be possible to
> trigger the #afterModelLinked stuff manually prior to resolving the
> cross references.
>
> If I'm not mistaken the concept of the
> org.eclipse.xtext.resource.DerivedStateAwareResource may help.
>

I am sorry, but I don't understand. I think you are saying that in 2.0
resources were loaded twice, but since (some version) they are only
loaded once.

I do get a call to #afterModelLinked, but this logic;

@Inject
private org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
indexProvider;

IResourceDescriptions descriptionIndex =
indexProvider.getResourceDescriptions(resource);
IResourceDescription descr =
descriptionIndex.getResourceDescription(resource.getURI());

gives me a null IResourceDescription

should I just do:

// get the current (possibly dirty) description
IResourceDescription dirty =
resourceServiceProvider.getResourceDescriptionManager().getResourceDescription(
resource);

and use the dirty description?

(will try that and see what happens)

Regards
- henrik
Re: Woes migrating to 2.2.1 from 2.0.1 - need help [message #859125 is a reply to message #859092] Fri, 27 April 2012 13:20 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-27-04 14:59, Henrik Lindberg wrote:

> should I just do:
>
> // get the current (possibly dirty) description
> IResourceDescription dirty =
> resourceServiceProvider.getResourceDescriptionManager().getResourceDescription(
>
> resource);
>
> and use the dirty description?
>
> (will try that and see what happens)
>
When I do this, I see that the "build clean" is not done in the required
build order so I get many "false negatives" for references not yet in
the index (at least that is what I think is happening).

What I have is:
a PPLinker that extends LazyLinker and in its #afterModelLinked I
perform all the linking. This is where I compute all the imports, and
unresolved references, and produce errors/warnings.

Kind of stuck at this point regarding what to look at next...

(Help)

- henrik
Re: Woes migrating to 2.2.1 from 2.0.1 - need help [message #859223 is a reply to message #858797] Fri, 27 April 2012 14:17 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-27-04 11:45, Sebastian Zarnekow wrote:

> We loaded the resource twice in Xtext 2.0. This happens only once, now,
> thus the linking is not triggered twice. You may want to checkout
> LazyLinkingResource#resolveLazyCrossReferences. It may be possible to
> trigger the #afterModelLinked stuff manually prior to resolving the
> cross references.
>

So, I think you are saying - override
LazyLinkingResource#resolveLaxyCrossReferences and then trigger my code
that is normally triggered from #afterModelLinked.

I will try that - and do like I do now and do no linking if I do not get
a resource description (i.e. the "build clean" run).

> If I'm not mistaken the concept of the
> org.eclipse.xtext.resource.DerivedStateAwareResource may help.
>

Looked into DerivedStateAwareResource, but seems difficult to produce
warnings and errors while producing the "derived state".

- henrik
Re: Woes migrating to 2.2.1 from 2.0.1 - need help [message #859414 is a reply to message #859223] Fri, 27 April 2012 16:19 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
CIGAR !

I changed the code - instead of doing the custom linking in
the LazyLinker#afterModelLinked, I now do it in
LazyLinkingResource#resolveLazyCrossReferences.

This is what I do:

public class PPResource extends LazyLinkingResource {
@Inject
private DocumentationAssociator documentationAssociator;

@Inject
PPResourceLinker resourceLinker;

@Override
public void resolveLazyCrossReferences(CancelIndicator mon) {
super.resolveLazyCrossReferences(mon);

final ListBasedDiagnosticConsumer diagnosticsConsumer = new
ListBasedDiagnosticConsumer();
IMessageAcceptor acceptor = new
DiagnosticConsumerBasedMessageAcceptor(diagnosticsConsumer);
EObject model = this.getParseResult().getRootASTElement();
documentationAssociator.linkDocumentation(model, acceptor);
resourceLinker.link(model, acceptor, false);

if(!isValidationDisabled()) {
getErrors().addAll(diagnosticsConsumer.getResult(Severity.ERROR));

getWarnings().addAll(diagnosticsConsumer.getResult(Severity.WARNING));
}

}
}

Do you see any problems with moving the responsibility to this class,
doing what I do above?

Regards
- henrik

On 2012-27-04 16:17, Henrik Lindberg wrote:
> On 2012-27-04 11:45, Sebastian Zarnekow wrote:
>
>> We loaded the resource twice in Xtext 2.0. This happens only once, now,
>> thus the linking is not triggered twice. You may want to checkout
>> LazyLinkingResource#resolveLazyCrossReferences. It may be possible to
>> trigger the #afterModelLinked stuff manually prior to resolving the
>> cross references.
>>
>
> So, I think you are saying - override
> LazyLinkingResource#resolveLaxyCrossReferences and then trigger my code
> that is normally triggered from #afterModelLinked.
>
> I will try that - and do like I do now and do no linking if I do not get
> a resource description (i.e. the "build clean" run).
>
>> If I'm not mistaken the concept of the
>> org.eclipse.xtext.resource.DerivedStateAwareResource may help.
>>
>
> Looked into DerivedStateAwareResource, but seems difficult to produce
> warnings and errors while producing the "derived state".
>
> - henrik
Re: Woes migrating to 2.2.1 from 2.0.1 - need help [message #860042 is a reply to message #859414] Fri, 27 April 2012 23:05 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2012-27-04 18:19, Henrik Lindberg wrote:
> CIGAR !
>
Actually, I got too many Cigars...

Posting what looks like the solution here, for anyone else that may
stumble on this in the future.

The LazyLinkingResource#resolveLazyCrossReferences can/will be called a
number of times - in my typical case, 4 times resulting in 4 copies of
every diagnostic.

So, to round off the implementation, I added a guard around the linking
the same way as the DerivedStateAwareResource handled the same thing.
(Too much work to actually use this Resource as it also required a
specialized ResourceDescription (I already have one that does a number
of things), and I also did not want the result to depend on someone
getting the content of the resource (I only have side effects in terms
of diagnostics).

Now, much better.

Regards
- henrik

> I changed the code - instead of doing the custom linking in the
> LazyLinker#afterModelLinked, I now do it in
> LazyLinkingResource#resolveLazyCrossReferences.
>
> This is what I do:
>
> public class PPResource extends LazyLinkingResource {
> @Inject
> private DocumentationAssociator documentationAssociator;
>
> @Inject
> PPResourceLinker resourceLinker;
>
> @Override
> public void resolveLazyCrossReferences(CancelIndicator mon) {
> super.resolveLazyCrossReferences(mon);
>
> final ListBasedDiagnosticConsumer diagnosticsConsumer = new
> ListBasedDiagnosticConsumer();
> IMessageAcceptor acceptor = new
> DiagnosticConsumerBasedMessageAcceptor(diagnosticsConsumer);
> EObject model = this.getParseResult().getRootASTElement();
> documentationAssociator.linkDocumentation(model, acceptor);
> resourceLinker.link(model, acceptor, false);
>
> if(!isValidationDisabled()) {
> getErrors().addAll(diagnosticsConsumer.getResult(Severity.ERROR));
>
> getWarnings().addAll(diagnosticsConsumer.getResult(Severity.WARNING));
> }
>
> }
> }
>
> Do you see any problems with moving the responsibility to this class,
> doing what I do above?
>
> Regards
> - henrik
>
> On 2012-27-04 16:17, Henrik Lindberg wrote:
>> On 2012-27-04 11:45, Sebastian Zarnekow wrote:
>>
>>> We loaded the resource twice in Xtext 2.0. This happens only once, now,
>>> thus the linking is not triggered twice. You may want to checkout
>>> LazyLinkingResource#resolveLazyCrossReferences. It may be possible to
>>> trigger the #afterModelLinked stuff manually prior to resolving the
>>> cross references.
>>>
>>
>> So, I think you are saying - override
>> LazyLinkingResource#resolveLaxyCrossReferences and then trigger my code
>> that is normally triggered from #afterModelLinked.
>>
>> I will try that - and do like I do now and do no linking if I do not get
>> a resource description (i.e. the "build clean" run).
>>
>>> If I'm not mistaken the concept of the
>>> org.eclipse.xtext.resource.DerivedStateAwareResource may help.
>>>
>>
>> Looked into DerivedStateAwareResource, but seems difficult to produce
>> warnings and errors while producing the "derived state".
>>
>> - henrik
>
Previous Topic:What is wrong in my grammar?
Next Topic:failure on XVariableDeclaration resolution in XBaseInterpreter
Goto Forum:
  


Current Time: Thu Apr 18 04:35:22 GMT 2024

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

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

Back to the top