Resolving unresolved reference using IDerivedStateComputer [message #1840047] |
Tue, 06 April 2021 07:27 |
Nagaraj Kandoor Messages: 56 Registered: May 2020 |
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 #1840164 is a reply to message #1840156] |
Thu, 08 April 2021 02:09 |
Nagaraj Kandoor Messages: 56 Registered: May 2020 |
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 #1840229 is a reply to message #1840228] |
Fri, 09 April 2021 08:26 |
|
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
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 #1840633 is a reply to message #1840231] |
Wed, 21 April 2021 06:03 |
Nagaraj Kandoor Messages: 56 Registered: May 2020 |
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 #1841068 is a reply to message #1840761] |
Mon, 03 May 2021 03:49 |
Nagaraj Kandoor Messages: 56 Registered: May 2020 |
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06484 seconds