Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Error "Cyclic linking detected" in editor window(While processing a reference in a ScopeProvider the editor view shows an error "Cyclic linking detected")
Error "Cyclic linking detected" in editor window [message #1563697] Wed, 14 January 2015 10:46 Go to next message
Jonathan Koscielny is currently offline Jonathan KoscielnyFriend
Messages: 14
Registered: August 2013
Junior Member
My DSL uses Xbase for referencing JVM types. Therefore I need to customize the "XImportSectionNamespaceScopeProvider" to find/build the correct XimportSection. Now I have an unexpected behavior of the editor and of the model. My DSL file currently looks like this:

delta MyDelta {
	adds {
		package my.pkg;
		import java.util.List;
		public class MyClass 
				implements List
						{
		} 
	}
	modifies my.pkg.MyClass { // (1)
								 	  
		adds import java.util.ArrayList; // (2)
		adds superclass ArrayList<String>;
	}
}


and the corresponding grammar fragment looks like this:

Delta:
	'delta' dName=ValidID '{' deltaActions+=DeltaAction* '}';

DeltaAction:
	AddsUnit | ModifiesUnit | RemovesUnit;

AddsUnit:
	{AddsUnit} 'adds' '{' unit=JavaCompilationUnit? '}';

ModifiesUnit:
	'modifies' unit=[ClassOrInterface|QualifiedName] '{'
	modifiesPackage=ModifiesPackage?
	modifiesImports+=ModifiesImport*
	modifiesSuperclass=ModifiesInheritance?
	'}';

ModifiesPackage:
	'modifies' 'package' name=QualifiedName ';';

ModifiesImport:
	AddsImport | RemovesImport;

AddsImport:
	'adds' importDecl=XImportDeclaration;

RemovesImport:
	'removes' importDecl=XImportDeclaration;

JavaCompilationUnit:
	=> (annotations+=Annotation*
	'package' name=QualifiedName EOL)?
	importSection=XImportSection?
	typeDeclarations+=ClassOrInterfaceDeclaration;

ClassOrInterfaceDeclaration:
	annotations+=Annotation* modifiers+=Modifier* classOrInterface=ClassOrInterface;

ClassOrInterface:
	ClassDeclaration | InterfaceDeclaration | EnumDeclaration | AnnotationTypeDeclaration;

ClassDeclaration:
	'class' name=QualifiedName typeParameters=TypeParameters?
	('extends' superClass=JvmTypeReference)?
	('implements' interfaces=Typelist)?
	body=ClassBody;


My extended XImportSectionNamespaceScopeProvider works fine and its result is as it should be, mostly. But there is a strange behaviour of the dsl editor or validation:

I am currently working on providing the namespace scope for a ModifiesUnit. To do that, I use the reference to ClassOrInterface to copy its XImportSection and add all added import declarations. Here, I don't know what is going internally! There are two mysterias things going on!

1.) If I request the refernced ClassOrInterface, the editor shows the follwoing error on the qualified name at (1): "Cyclic linking detected : ModifiesUnit.unit->ModifiesUnit.unit" My question is: what does it mean? Why does this error occur?

I also figured out a strange thing there: I store the ClassOrInterface in a local variable and then print it to the command line. The output is the following:
org.deltaj.scoping.deltaJ.impl.ClassOrInterfaceImpl@4642f064 (eProxyURI: platform:/resource/Test/src/My.dj#xtextLink_::0.0.0.1.1::0::/2)
org.deltaj.scoping.deltaJ.impl.ClassDeclarationImpl@1c70366 (name: MyClass)


Why do I get two references there? I think this could rely on the ParserRule ClassOrInterface which only is an abstract super rule of ClassDeclaration. But why is Xtext not able to resolve the reference for the ClassOrInterface?

2.) In some cases, the attribute importDecl of the XImportDeclaration at (2) seems to be empty, but it never is.

I asked this question on stackoverflow, too. See https://stackoverflow.com/questions/27944517/error-cyclic-linking-detected-in-editor-window

[Updated on: Wed, 14 January 2015 15:14]

Report message to a moderator

Re: Error &quot;Cyclic linking detected&quot; in editor window [message #1565305 is a reply to message #1563697] Thu, 15 January 2015 07:43 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jonathan,

with seeing the code that is executed, it is hard to tell what's going
on there, e.g. I've no clue what you are refering to by 'store the
ClassOrInterface in a local variable and print it'. Where do you store
it and when do you print it. Anyway: you may want to extract a
reproducable test case and create a ticket from that and provide the
code on Github so someone can take a look.
My gut feeling is that you modify some XImportSection on the EMF level
by accident and therefore confuse the processing of the file. Do you
call XImportSection.getImportDeclarations().add() somewhere?

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Error &quot;Cyclic linking detected&quot; in editor window [message #1565424 is a reply to message #1565305] Thu, 15 January 2015 09:14 Go to previous messageGo to next message
Jonathan Koscielny is currently offline Jonathan KoscielnyFriend
Messages: 14
Registered: August 2013
Junior Member
Hi Sebastian,

I have uploaded both source files here. Then you can see, what is going on.
Quote:
e.g. I've no clue what you are refering to by 'store the
ClassOrInterface in a local variable and print it'. Where do you store
it and when do you print it.

When I started to implement the algorithm which provides the XImportSection for a 'ModifiesUnit' I first called
val classOrInterface = u.unit

and the result was the "cyclic linking error" which was shown in the ditor. I then tried to iterate through the classOrInterfaces parent elements to find its XImportSection, but I failed. OK, this was the point where I printed it out.
val classOrInterface = u.unit
println(classOrInterface)

with the result
org.deltaj.scoping.deltaJ.impl.ClassOrInterfaceImpl@4642f064 (eProxyURI: platform:/resource/Test/src/My.dj#xtextLink_::0.0.0.1.1::0::/2)
org.deltaj.scoping.deltaJ.impl.ClassDeclarationImpl@1c70366 (name: MyClass)

You can see how I have solved it in the attached 'ImportSectionSearcher' class.

Quote:

My gut feeling is that you modify some XImportSection on the EMF level
by accident and therefore confuse the processing of the file. Do you
call XImportSection.getImportDeclarations().add() somewhere?

No, I use 'EcoreUtil2.copy(EObject)' to copy the XImportSection before modifying it. Later on (in the Xbase implementation) it is converted into a list of ImportNormalizers or s.th. like that. So it was the easiest way for me to copy it there and add additional import statements.

All in all my implementation works. But I figured out the following unexpected behaviour: Immediately after calling the 'ModifiesUnit.getUnit()' method which does not return a child of type ClassOrInterface but a referenced EObject of type ClassOrInterface, the editor shows the "Cyclic linking detected" error.

This my question is all about, every other problem is solved here Wink.
Re: Error &amp;quot;Cyclic linking detected&amp;quot; in editor window [message #1565437 is a reply to message #1565424] Thu, 15 January 2015 09:21 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jonathan,

since the snippet you provided is not self contained, I can only make an
educated guess:

modifiedSection.importDeclarations.add(imp.importDecl)

Here you remove importDecl from imp since it is added to the containment
list of your modifiedSection. This may cause trouble.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Error &quot;Cyclic linking detected&quot; in editor window [message #1565508 is a reply to message #1563697] Thu, 15 January 2015 10:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I find that when I have a cyclic linking error, setting a breakpoint on
the error enables the stack to be examined. It usually has two bites at
resolveProxy. The first one is the error, since it fails to resolve the
proxy by itself, instead it provokes a recursion.

You must ensure that proxies are resolved in a resolveable order.

In particular for A::B::C you must resolve A before B before C to avoid
a cycle.

Regards

Ed Willink
Re: Error &quot;Cyclic linking detected&quot; in editor window [message #1565783 is a reply to message #1565508] Thu, 15 January 2015 13:33 Go to previous messageGo to next message
Jonathan Koscielny is currently offline Jonathan KoscielnyFriend
Messages: 14
Registered: August 2013
Junior Member
Mh, that is difficult, I think. Because I do not have to implement a ScoprProvider for this reference. It is resolved correctly by Xtext itself (as long as I do not call the getter method of this reference.)
Re: Error &quot;Cyclic linking detected&quot; in editor window [message #1573777 is a reply to message #1565783] Mon, 19 January 2015 23:24 Go to previous message
Jonathan Koscielny is currently offline Jonathan KoscielnyFriend
Messages: 14
Registered: August 2013
Junior Member
I have found a solution for my problem. It is described in the Stackoverflow link which I shared in the first post.
Previous Topic:Kepler TypeNotFoundException
Next Topic:How to reimport xtext project
Goto Forum:
  


Current Time: Sat Apr 27 01:19:03 GMT 2024

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

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

Back to the top