Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping & "Cyclic resolution of lazy links" error
Scoping & "Cyclic resolution of lazy links" error [message #704285] Thu, 28 July 2011 13:09 Go to next message
Julien Bigot is currently offline Julien BigotFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

I am implementing a language where I have implementation dissociated from declaration.

basically something like
struct_decl S {
int public_var;
}

stuct_impl S {
int private_var = 3;
public_var = private_var;
}

i.e. The struct_impl references its associated struct_decl. The elements declared in the struct_decl are accessible from the associated stuct_impl.

For scoping, I use nested scopes with basically this code:
IScope getScope(EObject context, EReference reference) {
	return createScope(getScope(context.eContainer(), reference), context, reference);
}

IScope createScope(IScope parent, EObject context, EReference reference) {
	return SelectableBasedScope.createScope(
		parent,
		new MultimapBasedSelectable(Scopes.scopedElementsFor(context.eContents(), qualifiedNameProvider)),
		reference.getEReferenceType(),
		isIgnoreCase(reference)
	);
};

In addition I handle the top level element and I cache the MultimapBasedSelectable.

In the case of stuct_impl however, this simple scheme isn't enough. I have to allow referencing the elements of the struct_decl.
In order to do that I simply introduced the content of the struct_decl just after that of the stuct_imp, i.e.
IScope getScope(EObject context, EReference reference) {
	IScope parent = getScope(context.eContainer(), reference);
	if ( context instanceof StructImpl ) {
		parent = createScope(parent, context.getDeclaration(), reference);
	}
	return createScope(parent, context, reference);
}


However with this code I get a "Cyclic resolution of lazy links" error. From the call stack, it seems that accessing the declaration reference starts the reference resolution process that launch the scoping process thus inducing a cycle ...
Re: Scoping & "Cyclic resolution of lazy links" error [message #704344 is a reply to message #704285] Thu, 28 July 2011 14:18 Go to previous message
Julien Bigot is currently offline Julien BigotFriend
Messages: 26
Registered: July 2009
Junior Member
I managed to get rid of the error by replacing the call to "getDeclaration()" by a call to "eGet(HlaPackage.eINSTANCE.getStructImpl_Declaration(), false)" and only inserting the intermediate scope if "eIsProxy()" is false.
The resulting code looks like:
IScope getScope(EObject context, EReference reference) {
	IScope parent = getScope(context.eContainer(), reference);
	if ( context instanceof StructImpl ) {
		EObject declaration = (EObject) context.eGet(HlaPackage.eINSTANCE.getStructImpl_Declaration(), false);
		if ( !declaration.eIsProxy() ) parent = createScope(parent, context.getDeclaration(), reference);
	}
	return createScope(parent, context, reference);
}


I don't know if it's the right way to do it or if there's a cleaner way ...
Previous Topic:Error: The code of method ruleElement() is exceeding the 65535 bytes limit
Next Topic:scope and qualified name
Goto Forum:
  


Current Time: Sun Apr 11 08:12:22 GMT 2021

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

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

Back to the top