Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problem with unresolved proxy serialization(Xtext fails while unresolved proxy serialization)
Problem with unresolved proxy serialization [message #915882] Tue, 18 September 2012 06:38 Go to next message
George Suaridze is currently offline George SuaridzeFriend
Messages: 5
Registered: October 2011
Junior Member
Hello, something wrong with unresolved proxy serialization.

Use case:
1. read model from file, which contains unresolvable object;
2. if I try to save I'll get XtextSerializationException


I looked through the code, while model serialization CrossReferenceSerializer gets text from node if object is unresolvable proxy and that is right, but node is null for this proxy.
Then I looked at AbstractParseTreeConstructor, as I understand it recreates token tree and tries to link tokens with existing nodemodel in AbstractParseTreeConstructor.assignNodesByMatching method.

For crossreferences it executes method in the calss CrossReferenceSerializer:

public class CrossReferenceSerializer implements ICrossReferenceSerializer {

...

public boolean equalsOrReplacesNode(EObject context, CrossReference crossref, EObject target, INode node) {
		if (crossref != node.getGrammarElement())
			return false;
		EReference ref = GrammarUtil.getReference(crossref);
		if (!ref.isMany())
			return true;
		List<EObject> objects = linkingService.getLinkedObjects(context, ref, node);
		return objects.contains(target);
}

...



public class DefaultLinkingService extends AbstractLinkingService {

...

public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node)
			throws IllegalNodeException {
		final EClass requiredType = ref.getEReferenceType();
		if (requiredType == null)
			return Collections.<EObject> emptyList();

		final String crossRefString = getCrossRefNodeAsString(node);
		if (crossRefString != null && !crossRefString.equals("")) {
			if (logger.isDebugEnabled()) {
				logger.debug("before getLinkedObjects: node: '" + crossRefString + "'");
			}
				
			final IScope scope = getScope(context, ref);
			QualifiedName qualifiedLinkName =  qualifiedNameConverter.toQualifiedName(crossRefString);
			IEObjectDescription eObjectDescription = scope.getSingleElement(qualifiedLinkName);
			if (logger.isDebugEnabled()) {
				logger.debug("after getLinkedObjects: node: '" + crossRefString + "' result: " + eObjectDescription);
			}
			if (eObjectDescription != null) 
				return Collections.singletonList(eObjectDescription.getEObjectOrProxy());
		}
		return Collections.emptyList();
	}

...


as you can see it will always return false for unresolved object, because linkingService uses scope for finding objects, and scope doesn't contain unresolved objects.

How can I solve this problem? Should I post this as a bug?

I attached sample project, to reproduce this.
there is jUnit test to run org.example.domainmodel.SerializeTest



Eclipse Juno. Xtext 2.3.0
Re: Problem with unresolved proxy serialization [message #989980 is a reply to message #915882] Mon, 10 December 2012 10:32 Go to previous message
George Suaridze is currently offline George SuaridzeFriend
Messages: 5
Registered: October 2011
Junior Member
Link to opened bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=390691
Previous Topic:Issue removing whitespace on save
Next Topic:Extended highlighting breaks embedded editor highlighting
Goto Forum:
  


Current Time: Thu Apr 25 05:21:51 GMT 2024

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

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

Back to the top