Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Error: Cyclic resolution of lazy links
Error: Cyclic resolution of lazy links [message #1754384] Fri, 17 February 2017 07:24 Go to next message
chris yo is currently offline chris yoFriend
Messages: 146
Registered: February 2013
Senior Member
Model:
	greetings+=(Greeting| Test | Greeting2)*;

XID:
	ID | 'Bye' | 'Hello'
;

Greeting2:
	'Change' xName=[Greeting|XID] 'to' str=XID 
;

Greeting:
	'Hello' sample=[Test|XID] 'age' age=INT '!';
Test:
	'Bye' sName=XID '!' 'see' 'you' date=ID';'
;



I created my QualifiedNameProvider like this:
QualifiedName qualifiedName(Greeting obj) {
			return QualifiedName.create(obj.getSample().getSName());
	}


But I get this Cyclic resolution of lazy link error.

1    [main] ERROR xt.linking.lazy.LazyLinkingResource  - Cyclic resolution of lazy links : Greeting2.xName->Greeting2.xName in resource 'test.Mydsl'.
org.eclipse.xtext.linking.lazy.LazyLinkingResource$CyclicLinkingException: Cyclic resolution of lazy links : Greeting2.xName->Greeting2.xName in resource 'test.myDsl'.
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.handleCyclicResolution(LazyLinkingResource.java:302)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:240)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:222)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:223)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:199)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:259)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(BasicEObjectImpl.java:1477)
	at org.myDsl.impl.GreetingImpl.getSample(Unknown Source)
	at org.MyQualifiedNameProvider.qualifiedName(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:296)
	at org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider$2.get(DefaultDeclarativeQualifiedNameProvider.java:64)
	at org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider$2.get(DefaultDeclarativeQualifiedNameProvider.java:1)
	at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:77)
	at org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider.getFullyQualifiedName(DefaultDeclarativeQualifiedNameProvider.java:59)
	at org.eclipse.xtext.naming.IQualifiedNameProvider$AbstractImpl.apply(IQualifiedNameProvider.java:32)
	at org.eclipse.xtext.naming.IQualifiedNameProvider$AbstractImpl.apply(IQualifiedNameProvider.java:1)
	at org.eclipse.xtext.scoping.Scopes$2.apply(Scopes.java:93)
	at org.eclipse.xtext.scoping.Scopes$2.apply(Scopes.java:1)
	at com.google.common.collect.Iterators$8.transform(Iterators.java:794)
	at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:646)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at org.eclipse.xtext.scoping.impl.MultimapBasedSelectable.setExportedObjects(MultimapBasedSelectable.java:106)
	at org.eclipse.xtext.scoping.impl.MultimapBasedSelectable.<init>(MultimapBasedSelectable.java:36)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.internalGetAllDescriptions(ImportedNamespaceAwareLocalScopeProvider.java:236)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider$2.get(ImportedNamespaceAwareLocalScopeProvider.java:223)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider$2.get(ImportedNamespaceAwareLocalScopeProvider.java:1)
	at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:77)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getAllDescriptions(ImportedNamespaceAwareLocalScopeProvider.java:220)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getResourceScope(ImportedNamespaceAwareLocalScopeProvider.java:113)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getResourceScope(ImportedNamespaceAwareLocalScopeProvider.java:102)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:90)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:88)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:88)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:88)
	at org.eclipse.xtext.scoping.impl.DelegatingScopeProvider.delegateGetScope(DelegatingScopeProvider.java:42)
	at org.eclipse.xtext.scoping.impl.DelegatingScopeProvider.getScope(DelegatingScopeProvider.java:38)
	at org.eclipse.xtext.linking.impl.DefaultLinkingService.getScope(DefaultLinkingService.java:59)
	at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:119)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:247)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:222)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:223)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:199)
	at org.eclipse.emf.ecore.util.EcoreUtil.resolve(EcoreUtil.java:259)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResolveProxy(BasicEObjectImpl.java:1477)
	at org.myDsl.impl.GreetingImpl.getSample(Unknown Source)
	at org.MyQualifiedNameProvider.qualifiedName(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java:296)
	at org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider$2.get(DefaultDeclarativeQualifiedNameProvider.java:64)
	at org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider$2.get(DefaultDeclarativeQualifiedNameProvider.java:1)
	at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:77)
	at org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider.getFullyQualifiedName(DefaultDeclarativeQualifiedNameProvider.java:59)
	at org.eclipse.xtext.naming.IQualifiedNameProvider$AbstractImpl.apply(IQualifiedNameProvider.java:32)
	at org.eclipse.xtext.naming.IQualifiedNameProvider$AbstractImpl.apply(IQualifiedNameProvider.java:1)
	at org.eclipse.xtext.scoping.Scopes$2.apply(Scopes.java:93)
	at org.eclipse.xtext.scoping.Scopes$2.apply(Scopes.java:1)
	at com.google.common.collect.Iterators$8.transform(Iterators.java:794)
	at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:646)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at org.eclipse.xtext.scoping.impl.MultimapBasedSelectable.setExportedObjects(MultimapBasedSelectable.java:106)
	at org.eclipse.xtext.scoping.impl.MultimapBasedSelectable.<init>(MultimapBasedSelectable.java:36)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.internalGetAllDescriptions(ImportedNamespaceAwareLocalScopeProvider.java:236)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider$2.get(ImportedNamespaceAwareLocalScopeProvider.java:223)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider$2.get(ImportedNamespaceAwareLocalScopeProvider.java:1)
	at org.eclipse.xtext.util.OnChangeEvictingCache.get(OnChangeEvictingCache.java:77)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getAllDescriptions(ImportedNamespaceAwareLocalScopeProvider.java:220)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getResourceScope(ImportedNamespaceAwareLocalScopeProvider.java:113)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getResourceScope(ImportedNamespaceAwareLocalScopeProvider.java:102)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:90)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:88)
	at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:88)
	at org.eclipse.xtext.scoping.impl.DelegatingScopeProvider.delegateGetScope(DelegatingScopeProvider.java:42)
	at org.eclipse.xtext.scoping.impl.DelegatingScopeProvider.getScope(DelegatingScopeProvider.java:38)
	at org.eclipse.xtext.linking.impl.DefaultLinkingService.getScope(DefaultLinkingService.java:59)
	at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:119)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:247)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:222)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.doResolveLazyCrossReference(LazyLinkingResource.java:189)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:148)
	at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:134)
	at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:498)
	at org.eclipse.xtext.validation.ResourceValidatorImpl.resolveProxies(ResourceValidatorImpl.java:161)
	at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:74)
	at org.generator.Main.runValidator(Unknown Source)
	at org.generator.Main.main(Unknown Source)


What should my QualifiedNameProvider be if I am referring to a cross-reference?
Re: Error: Cyclic resolution of lazy links [message #1754386 is a reply to message #1754384] Fri, 17 February 2017 07:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11491
Registered: July 2009
Senior Member
You may not use cross refs in the nameprovider

You can use nodemodelutils to obtain
The text


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Error: Cyclic resolution of lazy links [message #1776552 is a reply to message #1754386] Fri, 17 November 2017 16:07 Go to previous messageGo to next message
Hans Klein is currently offline Hans KleinFriend
Messages: 4
Registered: November 2017
Junior Member
Hello Christian,
can you please specify when and where to use the 'nodemodelutils'.
I followed your suggestion and used it in the

class MyScopeProvider extends myAbstractScopeProvider
{
	override getScope( EObject ctx, EReference reference )
	{
		if( ctx instanceof pO )
		{
                  // Access to 'c' leads to the error: Cyclic resolution of lazy links
                  scope = Scopes::scopeFor( (ctx as pO).c.atts )
                }
         }
}


within the same context and reference where the Cyclic resolution error occurs, with the same resulting error.
Thanks in advance
Re: Error: Cyclic resolution of lazy links [message #1776569 is a reply to message #1776552] Fri, 17 November 2017 19:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11491
Registered: July 2009
Senior Member
From your post I cannot see where are the reference and where not
You need to take the nodemodel utility on the object holding the reference
And then ask it for the nodes of the reference feature


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Error: Cyclic resolution of lazy links [message #1776635 is a reply to message #1776569] Sun, 19 November 2017 17:06 Go to previous messageGo to next message
Hans Klein is currently offline Hans KleinFriend
Messages: 4
Registered: November 2017
Junior Member
You are right, i missed out the grammar. Here it comes:

Att returns <xcore-file>::Att:
  datatype=[<xcore-file>::ReferenceDatatype|FQN]
  name=ID
;

PO returns <xcore-file>::pO:
  c = [<xcore-file>::oClass|FQN] name=ID
;

OClass returns <xcore-file>::oClass:
  name=ID 
  '('
    _atts+=(Att)*
  ')'
;


And here is the underlying xcore model <XCORE-File>:
abstract class N {
	  String[1] name
}

abstract class R extends N {
	op N[] getF() {	}
}

class oClass extends R {
	contains Att[] _atts
  	refers oClass p
  	op Att[] getAtts() 
  	{
    		var res = new BasicEList(_atts)
  		if (p !== null)
  		{
  			for (attr : p.atts)
  			{
				if(_atts.findFirst[attr.name == name] === null)
				{
					// proceed further
				}
			}
		}
		// proceed further
	}
}

abstract class oI extends R {
	refers oClass[1] c
	op N[] getF() {
		new ArrayList<N>(c.atts).asEList
	}
	refers N[] _psAtts
}

class pO extends oI
{ }

class Att extends R {
  // ... Features
}


Along with the code from friday its complete now. Can you help me?
Thanx in advance.
Re: Error: Cyclic resolution of lazy links [message #1776641 is a reply to message #1776635] Sun, 19 November 2017 20:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11491
Registered: July 2009
Senior Member
But which reference do you want to scope?

Attr..datatype or po.c ?
Maybe you should if else on ref as well and not on ctx only


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Error: Cyclic resolution of lazy links [message #1776804 is a reply to message #1776641] Tue, 21 November 2017 19:04 Go to previous messageGo to next message
Hans Klein is currently offline Hans KleinFriend
Messages: 4
Registered: November 2017
Junior Member
The following reference, which is casted to the appropriate object:

    (ctx as pO).c.atts


so, at least it is the 'pO'.
Re: Error: Cyclic resolution of lazy links [message #1776809 is a reply to message #1776804] Tue, 21 November 2017 20:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11491
Registered: July 2009
Senior Member
Can you please share a complete sample grammar and test model?
And you did not answer which references you are scoping


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Error: Cyclic resolution of lazy links [message #1776813 is a reply to message #1776809] Tue, 21 November 2017 20:40 Go to previous messageGo to next message
Hans Klein is currently offline Hans KleinFriend
Messages: 4
Registered: November 2017
Junior Member
Sorry for it:

po.c

is the answer to your question.
Re: Error: Cyclic resolution of lazy links [message #1776814 is a reply to message #1776813] Tue, 21 November 2017 20:45 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11491
Registered: July 2009
Senior Member
I am not sure if we are talking about the same thing and you fully understand what scoping is

If you say ‚I am scoping p0.c' you are defining which oClasses are valid for that reference.
So you should follow this reference when doing scoping.
Cause

To define what is alllowed you ask: give me the alllowed.
And to get the allowed you need to dine what is allowed


This gives you a inifinte look
This results in the cycling linking error you get


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Previous Topic:Xtext quick fix provider not run?
Next Topic:Request Guidance on Best Practice for Parsing/Content Assist
Goto Forum:
  


Current Time: Mon Dec 11 21:12:19 GMT 2017

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

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