Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Resolving unresolved reference using IDerivedStateComputer
Resolving unresolved reference using IDerivedStateComputer [message #1840047] Tue, 06 April 2021 07:27 Go to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
I have implemented IDerivedStateComputer to resolve unresolved references in the model.

At the initial level to test whether IDerivedStateComputer implementation will work or not, I just added some dummy data to resolve the unresolved references.
public void installDerivedState(DerivedStateAwareResource resource, boolean preLinkingPhase) {
// other code
if (ab.eIsProxy()) {
Alphabet gNew = cidlInt.createABC();
gNew.setName("ABC");
resource.getContents().add(gNew);
}
}


The above implementation resolved unresolved references but it created a validation error.

Validation error: "There are one or more Objects in the same location."

Questions:
1) installDerivedState() is getting called multiple times for a single resource(resourceName abc.dsl).
Ex : 6 to 7 times with preLinkingPhase false.

I assume multiple calls to installDerivedState() creating an issue(Validation error).

2) How do I derive unresolved reference object name
I tried using NodeModelUtils.findNodesForFeature but it returned empty list.

Please share your thoughts it would be helpful.

[Updated on: Tue, 06 April 2021 07:39]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840048 is a reply to message #1840047] Tue, 06 April 2021 07:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
it should be called only twice. make sure you dont confuse build and multiple edits.
i also assume the error comes from EMF itself. or even somewhere from your code. (can you post the exact error message)
and of course you should write the code in a way that there is only one ABC in the list after n calls

NodeModelUtils.findNodesForFeature will do the job if you call it properly.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840063 is a reply to message #1840048] Tue, 06 April 2021 09:09 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Thank you Christian for the quick reply.

Yes, you are right
1) Validation error code is present in our code base.

Why my IDerivedStateComputer implementation cause such an error(There are one or more Objects in the same location.)?


2) When I call NodeModelUtils.findNodesForFeature using proxy object it's returning an empty list. When I debug the code call tree(NodeModelUtils.findNodesForFeature) to getNode returned null.
If I pass resolved object I am able to get Nodes.

Note: Want to suppress linker issues by creating a dummy object for unresolved reference

Please do share your thoughts
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840069 is a reply to message #1840063] Tue, 06 April 2021 10:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
2) When I call NodeModelUtils.findNodesForFeature using proxy object it's returning an empty list. When I debug the code call tree(NodeModelUtils.findNodesForFeature) to getNode returned null.
why do you call it on a proxy, you need to call it at the refernce owner, not the target


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840112 is a reply to message #1840069] Wed, 07 April 2021 01:26 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Thanks, Christian, If you can answer my first question it would be a great help Why my IDerivedStateComputer implementation cause such an error(There are one or more Objects in the same location.)?
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840117 is a reply to message #1840112] Wed, 07 April 2021 03:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
I don't know as I don't know where the error is coming from
so you should debug and find out


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 07 April 2021 04:21]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840156 is a reply to message #1840117] Wed, 07 April 2021 16:50 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Thank you! Christian.
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840164 is a reply to message #1840156] Thu, 08 April 2021 02:09 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Why installDerivedState() is getting called with different worker threads with the same resource? When I log 5 different thread called installDerivedState() with preLinkingPhase: false and one called with 2preLinkingPhase:true.

Worker-2 preLinkingPhase: false/resource/Core/abc.dsl
Worker-5 preLinkingPhase: false/resource/Core/abc.dsl
Worker-13 preLinkingPhase: false/resource/Core/abc.dsl
Worker-0 preLinkingPhase: false/resource/Core/abc.dsl
Worker-3 preLinkingPhase: false/resource/Core/abc.dsl


Question: What is the motive behind calling installDerivedState() with different threads even resource is the same(abc.dsl).

I think validation error and thread calls are correlated.

Please share your thoughts.



[Updated on: Thu, 08 April 2021 03:28]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840171 is a reply to message #1840164] Thu, 08 April 2021 04:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
Can you please post the stacktraces for all

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840199 is a reply to message #1840171] Thu, 08 April 2021 13:54 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Sorry for the late reply. I just added sop to get the thread name. Below debug logs for reference. log generated after adding new component Sub7878
  • Attachment: log.txt
    (Size: 3.02KB, Downloaded 1 time)

[Updated on: Thu, 08 April 2021 13:57]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840202 is a reply to message #1840199] Thu, 08 April 2021 14:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
i dont see any stacktraces for the worker threads so i cannot see what they are doing

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840220 is a reply to message #1840202] Fri, 09 April 2021 06:04 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
I have captured the thread dump after 20 seconds each. 3 thread dump attached.

Thread 18,16,22,21.
Please le me know your thoughts.

Worker-18preLinkingPhase: false/resource/CNRTest/Src/EBS/EbsPartition/CNRTest/CNRTest_generic/CNRTestCore/CNRTest.dsl
Worker-16preLinkingPhase: true/resource/CNRTest/Src/EBS/EbsPartition/CNRTest/CNRTest_generic/CNRTestCore/CNRTest.dsl
Worker-16preLinkingPhase: false/resource/CNRTest/Src/EBS/EbsPartition/CNRTest/CNRTest_generic/CNRTestCore/CNRTest.dsl
Worker-22preLinkingPhase: false/resource/CNRTest/Src/EBS/EbsPartition/CNRTest/CNRTest_generic/CNRTestCore/CNRTest.dsl
Worker-21preLinkingPhase: false/resource/CNRTest/Src/EBS/EbsPartition/CNRTest/CNRTest_generic/CNRTestCore/CNRTest.dsl
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840224 is a reply to message #1840220] Fri, 09 April 2021 06:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
i see one for the editor and one for the build.
this is expected

=> close all editors and do a clean build to test


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 09 April 2021 06:46]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840228 is a reply to message #1840224] Fri, 09 April 2021 08:19 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
did clean build same result. (validation error one or more object in the same location)

Question:

You mean to say installDerivedState() method calls are expected? (installDerivedState got called more than twice)

I just Want to suppress linker issues by creating a dummy object for unresolved reference.

Any suggestions from your side?

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840229 is a reply to message #1840228] Fri, 09 April 2021 08:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
the resource cycle is done

- for the build
- for open editors

its done with prelinking = true and its done with prelinking = false

Again: please debug where the error message you see is coming from. you may debug around the class org.eclipse.emf.common.util.Diagnostic
org.eclipse.xtext.validation.AbstractDeclarativeValidator.createDiagnostic*
org.eclipse.emf.ecore.util.EObjectValidator

derived state computer may be a possibilty for your usecase, but i have never seen it used in production for your usecase, but
implementations i have seen do proper managent of
the discardDerivedState / installDerivedState and also may consider preLinkingPhase parameter



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 09 April 2021 08:28]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840231 is a reply to message #1840229] Fri, 09 April 2021 08:31 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Thank you so much! Will explore your suggestions.
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840633 is a reply to message #1840231] Wed, 21 April 2021 06:03 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Hello Christian,

I have resolved the validation error issue.

I need some inputs for deriving the proxy name for unresolved reference.

Currently, I am deriving proxy name from resource.getErrors()-->Diagnostic di.getMessage() [I will get unresolved references after string manipulation] issue with this approach sometime resource.getErrors() returning empty even resourse has
unresolved references.

Ex:
abc.dsl

CompA{
required interface ABC.InterfaceA{ // ABC is stubed
function A //
}
}


Another way I have tried :
Using NodeModelUtils.findNodesForFeature(ABC{Name of component},DSLPackage.eINSTANCE.getAbstractComponent_RequiredInterfaces());

After using NodeModelUtils -->get grammer element of node and check is proxy or not n.getGrammarElement().eIsProxy()--> it returned false for all node grammer elements even one of node is Unresolved (proxy).


It would be a great help if you share your thoughts.

[Updated on: Wed, 21 April 2021 06:20]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840639 is a reply to message #1840633] Wed, 21 April 2021 08:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
do not resolve any proxies. dont call NodeModelUtils.doSomething(e.getB()) when there is a b=[SomeType] in A.

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840739 is a reply to message #1840639] Fri, 23 April 2021 06:50 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Sorry, Christian I didn't get it. Can you please elaborate a little bit?

What I need:

I need to derive Unresolved reference names.

Ex:
abc.dsl

CompA{
required interface ABC.InterfaceA{ // ABC is stubed----InterfaceA stubed
function A //Since interface is stubed A also stubed
}
}

[Updated on: Fri, 23 April 2021 06:57]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1840741 is a reply to message #1840739] Fri, 23 April 2021 08:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
sorry i dont understand the problem with NodeModelUtils you have.

After using NodeModelUtils -->get grammer element of node and check is proxy or not n.getGrammarElement().eIsProxy()--> it returned false for all node grammer elements even one of node is Unresolved (proxy).


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840745 is a reply to message #1840741] Fri, 23 April 2021 09:16 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
Basically, I want to derive an unresolved reference name.

Approach 1-->resource.getErrors() didn't worked.

Approach 2--> Using NodeModelUtils got all required interface for a component [NodeModelUtils.findNodesForFeature({Name of component},DSLPackage.eINSTANCE.getAbstractComponent_RequiredInterfaces());] as INodes--> Now I am trying check which node is proxy by iterating
for (INode n : nodesForFeature) {
System.out.println(n.getText() + n.getGrammarElement().eIsProxy());
}

But all nodes returned false even one of Node is proxy.[n.getGrammarElement().eIsProxy()]


Any suggestion to get all unresolved reference names in case when a resource has multiple unresolved references.
Re: Resolving unresolved reference using IDerivedStateComputer [message #1840761 is a reply to message #1840745] Fri, 23 April 2021 12:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
i dont understand the proxy thing.
the code you write is executed before proxy resolution
and the grammar element can never be a proxy
it points to the metamodel
so it switches the meta levels


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving unresolved reference using IDerivedStateComputer [message #1841068 is a reply to message #1840761] Mon, 03 May 2021 03:49 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
@Christian Dietrich, Thank you.

I was able to derive unresolved reference names.

Facing some other issue.
After creating objects for unresolved reference Editor marker was resolved but when I do code generation again errors popped up.

PFA of image editor.

Ex:
[05/03 09:15:01] [dsl] [ERROR] ( ERR - Couldn't resolve reference to ProvidedConstant 'hhh'. platform:/resource/CNRTest/Src/ComponentA/ComponentA.dsl:34)


Question:
Why error marker recreated while doing code generation?

Any suggestion to suppress or prevent recreating of errors.


[Updated on: Mon, 03 May 2021 05:17]

Report message to a moderator

Re: Resolving unresolved reference using IDerivedStateComputer [message #1841069 is a reply to message #1841068] Mon, 03 May 2021 04:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13939
Registered: July 2009
Senior Member
no. you have to debug

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolving unresolved reference using IDerivedStateComputer [message #1841070 is a reply to message #1841069] Mon, 03 May 2021 05:00 Go to previous message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 16
Registered: May 2020
Junior Member
@Christian Dietrich, Thank you.
Previous Topic:xtext-services and iframe
Next Topic:Supporting several versions of a DSL when using the DSL's eclipse plugin
Goto Forum:
  


Current Time: Fri May 14 11:26:13 GMT 2021

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

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

Back to the top