Home » Modeling » TMF (Xtext) » Multiple usages for the current input string
| | | |
Re: Multiple usages for the current input string [message #49395 is a reply to message #49304] |
Mon, 08 June 2009 21:47 |
Juergen Denner Messages: 3 Registered: July 2009 |
Junior Member |
|
|
Hi Sven,
> Why can't you just compute the name like this? :
>
> String getName() {
> return getReferencedObject().getName();
> }
If I do it like this, I end up with a NPE.
Thread [main] (Suspended (exception NullPointerException))
ReferringTypeImpl.getName() line: 178
ReferringTypeImpl.eGet(int, boolean, boolean) line: 214
ReferringTypeImpl(BasicEObjectImpl).eGet(EStructuralFeature, boolean,
boolean) line: 1013
ReferringTypeImpl(BasicEObjectImpl).eGet(EStructuralFeature, boolean)
line: 1005
ReferringTypeImpl(BasicEObjectImpl).eGet(EStructuralFeature) line: 1000
ReferringHostImpl(BasicEObjectImpl).eURIFragmentSegment(EStr ucturalFeature,
EObject) line: 359
LazyLinkingResource(ResourceImpl).getURIFragment(EObject) line: 678
LazyLinkingResource(XtextResource).getURIFragment(EObject) line: 179
LazyURIEncoder.encode(EObject, EReference, AbstractNode) line: 42
LazyLinker.createProxy(EObject, AbstractNode, EReference) line: 124
LazyLinker.createAndSetProxy(EObject, AbstractNode, EReference) line:
113
LazyLinker.installProxies(EObject, IDiagnosticProducer,
Multimap<Setting,AbstractNode>) line: 84
LazyLinker.doLinkModel(EObject, IDiagnosticConsumer) line: 59
LazyLinker(AbstractCleaningLinker).linkModel(EObject,
IDiagnosticConsumer) line: 24
LazyLinkingResource(XtextResource).doLinking() line: 141
LazyLinkingResource(XtextResource).doLoad(InputStream, Map<?,?>) line:
161
LazyLinkingResource.doLoad(InputStream, Map<?,?>) line: 43
LazyLinkingResource(XtextResource).reparse(String) line: 85
XtextReconciler$1.process(XtextResource) line: 147
XtextReconciler$1.process(Object) line: 1
XtextReconciler$1(IUnitOfWork$Void<T>).exec(T) line: 36
XtextDocument$XtextDocumentLocker(IStateAccess$AbstractImpl<P >).modify(IUnitOfWork<T,P>)
line: 57
XtextDocument.modify(IUnitOfWork<T,XtextResource>) line: 135
XtextReconciler.handleInputDocumentChanged(IDocument, IDocument) line:
141
XtextReconciler.access$3(XtextReconciler, IDocument, IDocument) line:
133
XtextReconciler$TextInputListener.inputDocumentChanged(IDocu ment,
IDocument) line: 88
ProjectionViewer(TextViewer).fireInputDocumentChanged(IDocum ent,
IDocument) line: 2870
ProjectionViewer(TextViewer).setDocument(IDocument) line: 2919
ProjectionViewer(SourceViewer).setDocument(IDocument, IAnnotationModel,
int, int) line: 545
ProjectionViewer.setDocument(IDocument, IAnnotationModel, int, int)
line: 375
ProjectionViewer(SourceViewer).setDocument(IDocument, IAnnotationModel)
line: 500
XtextEditor(AbstractTextEditor).initializeSourceViewer(IEdit orInput)
line: 3951
XtextEditor(AbstractTextEditor).createPartControl(Composite) line: 3466
XtextEditor(StatusTextEditor).createPartControl(Composite) line: 53
XtextEditor(AbstractDecoratedTextEditor).createPartControl(C omposite)
line: 427
XtextEditor.createPartControl(Composite) line: 210
....
The problem 'starts' here:
...
ReferringHostImpl(BasicEObjectImpl).eURIFragmentSegment(EStr ucturalFeature,
EObject) line: 359
LazyLinkingResource(ResourceImpl).getURIFragment(EObject) line: 678
LazyLinkingResource(XtextResource).getURIFragment(EObject) line: 179
...
The eURIFragmentSegment(...) function is invoked before the Xtext linking
has happened. Due to that, referencedObject of ReferringTypeImpl is still
null.
To compute eURIFragmentSegment, EMF must invoke getName() and getName()
relies on a referencedObject.
Everything works perfectly, as long as I do not use EMF's EKeys feature. But
in my scenario I have additional EMF resources with objects pointing to
ReferringType instances and they need to be identified by name.
I hope that I could shed some light on the situation.
Cheers,
J
|
|
|
Re: Multiple usages for the current input string [message #49577 is a reply to message #49395] |
Tue, 09 June 2009 08:23 |
Sven Efftinge Messages: 1823 Registered: July 2009 |
Senior Member |
|
|
Hi Jürgen,
could you please try to come up with a small example which reproduces
your problem?
You can send it to me, or attach it to a bugzilla.
Cheers,
Sven
Jürgen Denner schrieb:
> Hi Sven,
>
>> Why can't you just compute the name like this? :
>>
>> String getName() {
>> return getReferencedObject().getName();
>> }
>
> If I do it like this, I end up with a NPE.
>
> Thread [main] (Suspended (exception NullPointerException))
> ReferringTypeImpl.getName() line: 178
> ReferringTypeImpl.eGet(int, boolean, boolean) line: 214
> ReferringTypeImpl(BasicEObjectImpl).eGet(EStructuralFeature, boolean,
> boolean) line: 1013
> ReferringTypeImpl(BasicEObjectImpl).eGet(EStructuralFeature, boolean)
> line: 1005
> ReferringTypeImpl(BasicEObjectImpl).eGet(EStructuralFeature) line: 1000
> ReferringHostImpl(BasicEObjectImpl).eURIFragmentSegment(EStr ucturalFeature,
> EObject) line: 359
> LazyLinkingResource(ResourceImpl).getURIFragment(EObject) line: 678
> LazyLinkingResource(XtextResource).getURIFragment(EObject) line: 179
> LazyURIEncoder.encode(EObject, EReference, AbstractNode) line: 42
> LazyLinker.createProxy(EObject, AbstractNode, EReference) line: 124
> LazyLinker.createAndSetProxy(EObject, AbstractNode, EReference) line:
> 113
> LazyLinker.installProxies(EObject, IDiagnosticProducer,
> Multimap<Setting,AbstractNode>) line: 84
> LazyLinker.doLinkModel(EObject, IDiagnosticConsumer) line: 59
> LazyLinker(AbstractCleaningLinker).linkModel(EObject,
> IDiagnosticConsumer) line: 24
> LazyLinkingResource(XtextResource).doLinking() line: 141
> LazyLinkingResource(XtextResource).doLoad(InputStream, Map<?,?>) line:
> 161
> LazyLinkingResource.doLoad(InputStream, Map<?,?>) line: 43
> LazyLinkingResource(XtextResource).reparse(String) line: 85
> XtextReconciler$1.process(XtextResource) line: 147
> XtextReconciler$1.process(Object) line: 1
> XtextReconciler$1(IUnitOfWork$Void<T>).exec(T) line: 36
> XtextDocument$XtextDocumentLocker(IStateAccess$AbstractImpl<P >).modify(IUnitOfWork<T,P>)
> line: 57
> XtextDocument.modify(IUnitOfWork<T,XtextResource>) line: 135
> XtextReconciler.handleInputDocumentChanged(IDocument, IDocument) line:
> 141
> XtextReconciler.access$3(XtextReconciler, IDocument, IDocument) line:
> 133
> XtextReconciler$TextInputListener.inputDocumentChanged(IDocu ment,
> IDocument) line: 88
> ProjectionViewer(TextViewer).fireInputDocumentChanged(IDocum ent,
> IDocument) line: 2870
> ProjectionViewer(TextViewer).setDocument(IDocument) line: 2919
> ProjectionViewer(SourceViewer).setDocument(IDocument, IAnnotationModel,
> int, int) line: 545
> ProjectionViewer.setDocument(IDocument, IAnnotationModel, int, int)
> line: 375
> ProjectionViewer(SourceViewer).setDocument(IDocument, IAnnotationModel)
> line: 500
> XtextEditor(AbstractTextEditor).initializeSourceViewer(IEdit orInput)
> line: 3951
> XtextEditor(AbstractTextEditor).createPartControl(Composite) line: 3466
> XtextEditor(StatusTextEditor).createPartControl(Composite) line: 53
> XtextEditor(AbstractDecoratedTextEditor).createPartControl(C omposite)
> line: 427
> XtextEditor.createPartControl(Composite) line: 210
> ....
>
> The problem 'starts' here:
> ...
> ReferringHostImpl(BasicEObjectImpl).eURIFragmentSegment(EStr ucturalFeature,
> EObject) line: 359
> LazyLinkingResource(ResourceImpl).getURIFragment(EObject) line: 678
> LazyLinkingResource(XtextResource).getURIFragment(EObject) line: 179
> ...
>
> The eURIFragmentSegment(...) function is invoked before the Xtext linking
> has happened. Due to that, referencedObject of ReferringTypeImpl is still
> null.
> To compute eURIFragmentSegment, EMF must invoke getName() and getName()
> relies on a referencedObject.
>
> Everything works perfectly, as long as I do not use EMF's EKeys feature. But
> in my scenario I have additional EMF resources with objects pointing to
> ReferringType instances and they need to be identified by name.
>
> I hope that I could shed some light on the situation.
>
> Cheers,
> Jürgen
>
>
> "Sven Efftinge" <sven.efftinge@itemis.de> wrote in message
> news:h0jkjn$nco$1@build.eclipse.org...
>> Jürgen Denner schrieb:
>>> 1. A new ReferringType instance is created.
>>> 2. The instance is added to the refs collection of ReferringHost.
>>> 3. A proxy reference to the new instance is created and used internally
>>> by Xtex (referencedObject is still null. I.e. the name is not known).
>> Why is referencedObject still null? It should contain the lazy linking
>> proxy which automatically is replaced with the real object when accessed
>> the first time.
>>
>>> 4. During the linking phase, the referencedObject gets filled. But now
>>> the instance URI changes and the proxy reference get invalid.
>> Sorry, I don't get it.
>>
>> Usually one shouldn't need to care about the lazy linking proxies.
>>
>> Assuming that your grammar just declares the linking and your meta model
>> contains an addition derived "name"-attribute. Why can't you just compute
>> the name like this? :
>>
>> String getName() {
>> return getReferencedObject().getName();
>> }
>>
>> Sven
>
>
|
|
|
Goto Forum:
Current Time: Thu Dec 26 15:52:13 GMT 2024
Powered by FUDForum. Page generated in 0.02631 seconds
|